Scott Coldwell created PDFBOX-3393:
--------------------------------------

             Summary: Javascript actions on form fields cause data to become 
hidden
                 Key: PDFBOX-3393
                 URL: https://issues.apache.org/jira/browse/PDFBOX-3393
             Project: PDFBox
          Issue Type: Improvement
          Components: AcroForm
    Affects Versions: 2.0.2
            Reporter: Scott Coldwell


We have run across numerous PDFs that contain javascript actions on some of the 
form fields.  When trying to set a value for the field, the data is there in 
the field, but only visible if you place the cursor in the field.  And since we 
flatten forms before saving them, it looks as if the data was never populated.  
Some of the actions we've seen are like the following:

AFDate_KeystrokeEx("mm/dd/yyyy")
AFNumber_Keystroke(0, 0, 0, 0, "", true);

As a workaround we are remove any actions associated with a field before 
setting a value by doing the following:

{code}
final PDField field = form.getField(fieldName);

if (field instanceof PDTerminalField)
{
    // Need to clear any actions (typically javascript) from the fields
    ((PDTerminalField)field).setActions(null);
}
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to