Attachment not found
The attached form contains a number of drop-downs that are used in calculations. The user is able to choose frequency and impact which are mapped to a number using the export value of the dropdown.
The library doesn't seem to directly provide both values from an entry in the Opt array where the entry is a two-item array instead of just a text string so I'm using the code below to get the export value instead of the label (where it exists); annot is the PDFAnnot object and inDoc the PDFDoc object that holds it:
if annot.getComboSel() < annot.getComboItemCount() {
//see if there are export values; if so use them
let obj = inDoc.advanceGetObj(annot.advanceGetRef())
obj?.setDictionary()
let optArray = obj?.dictGetItem(byTag: "Opt")
optArray?.setArray()
if
let optCount = optArray?.arrayGetItemCount(),
optCount > annot.getComboSel(),
let selectedItem = optArray?.arrayGetItem(annot.getComboSel() ),
selectedItem.getType() == 6 //array
{
selectedItem.setArray()
if let exportValue = selectedItem.arrayGetItem(0)?.getNameVal() {
return exportValue as AnyObject
}
}
if let txt = annot.getComboItem(annot.getComboSel()) {
return txt as AnyObject
} else {
return "" as AnyObject
}
}
This gets the export value for these fields in the attached PDF:
impact_row5.0 through impact_row5.5
frequency_row5.0 through frequency_row5.5
frequency_row1.0 through frequency_row1.3
However when used on fields post_freq_1, post_impact_1, post_freq_2.0 through post_freq_2.8 and post_imp_2.0 through post_imp_2.8 the value for optArray is a zero-length array (when it should be a 6 item array). The Opt array for those controls is an indirect reference; when I manually request the object using its reference number and inDoc.advanceGetObj() (226 0 and 229 0 for the post_freq_2.x and post_imp_2.x respectively) I get the appropriate array. However optArray has a type of 6 (=> array?) and no indirect reference. Am I trying to retrieve this incorrectly and is there a better way to do it? Thanks.