Getting export value from a choice field in a PDF - RadaeePDF.com
Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about iOS development and PDF
  • Page:
  • 1

TOPIC: Getting export value from a choice field in a PDF

Getting export value from a choice field in a PDF 4 months 3 hours ago #14469

  • fuelware
  • fuelware's Avatar Topic Author
  • Away
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 1
  • Thank you received: 0

File Attachment:

File Name:
File Size: 0 KB

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.

Please Log in or Create an account to join the conversation.

Getting export value from a choice field in a PDF 3 months 2 weeks ago #14480

  • emanuele
  • emanuele's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 572
  • Karma: 21
  • Thank you received: 66
Dear user,
sorry for the delay, we are deeply checking your request and the JS used on your pdf file.
Currently, the combo box exposed methods are getComboSel, getComboItem and getComboItemCount.
We are working to give you a complete answer and methods to help you to handle these annotations easily.

Please Log in or Create an account to join the conversation.

Getting export value from a choice field in a PDF 3 months 2 weeks ago #14481

  • emanuele
  • emanuele's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 572
  • Karma: 21
  • Thank you received: 66
Dear user,

you could download the new Swift module version, that now includes getComboItemVal to get the export value of the annotation.
In this case you could use this new method instead of the advanced methods.
You could find the new project here: https://www.radaeepdf.com/download/file/140-radaeepdfswift-1-1-7
The changed files are:
- libRDPDFLib.a
- PDFIOS.h
- PDFObjc.h/m
- PDFLayoutView.m

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum