Hi,
In evaluating your product (aspose-pdf-9.1 for java), I am conducting various compatibility tests with a number of different versions of Adobe forms. I have a few different static PDF forms that I am trying to set the value on a TextBoxField, and save the resulting PDF. I am trying to do so using the following code (taken from here: http://www.aspose.com/docs/display/pdfjava/Modify+Form+Field+in+a+PDF+Document):
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(“test.pdf”);
//I can verify the “some.path.to.field” exists as I am using the Field getFullName() method once
//I call Field[] fields = pdfDocument.getForm().getFields()
WidgetAnnotation anno = pdfDocument.getForm().get(“some.path.to.field”);
if(anno instanceof com.aspose.pdf.TextBoxField){
((com.aspose.pdf.TextBoxField)anno).setValue("shouldBeEdited");
((com.aspose.pdf.TextBoxField)anno).setReadOnly(true);
}
pdfDocument.save("test_edited.pdf");
Now this works fine for my PDFs that are:
PDF Version: 1.6 (Acrobat 7.x)
PDF Version: 1.7 (Acrobat 8.x)
The new field values are never written for my PDFs that are:
PDF Version: 1.7 Adobe Extension Level 3(Acrobat 9.x)
PDF Version: 1.7 Adobe Extension Level 8(Acrobat X)
PDF Version: 1.7 Adobe Extension Level 11(Acrobat XI)
Is it possible to set form field values using the code above with any forms that are Acrobat 9.x and above? Or can I only use the XFA data to set the value of these fields that are Acrobat 9.x and above? This would prove difficult as the Acrobat X and Acrobat XI Forms I am testing with have to XFA Fields.
I am uploading 3 PDFs
PDF Version: 1.7 Adobe Extension Level 3(Acrobat 9.x)
PDF Version: 1.7 Adobe Extension Level 8(Acrobat X)
PDF Version: 1.7 Adobe Extension Level 11(Acrobat XI)
Each of which I cannot successfully set the fields using the code specified earlier. These PDFs were created with Adobe LifeCycle Designer ES4, directly from a sample template, and saved as Static PDFs with 3 different compatibility versions. I did not edit these sample PDFs in any way. I can successfully read the values of Fields using:
Field[] fields = pdfDocument.getForm().getFields();
String someValue = fields[someIndex].getValue();
But no luck setting values and saving them
Thank you.
This Topic is created by codewarior using the Email to Topic plugin.