Preserve Extended Rights when Working with Forms in Java

Hi there,


I’m trying to open a pdf with fillable form fields and modify some field values, while preserving the reader extended feature so when the user download the modified pdf they’ll still be able to fill in the form and save the pdf just using Adobe Reader.

I found this seems possible in .NET component (Preserve Extended Rights when Working with Forms) How can I do the same thing in Java? I couldn’t find the same page in programmer’s guide for Java. The example given in javadoc is also the same as in the guide for .NET. The incremental Document.save() method does exist in the Java component, but I’m not sure how to specify the output without adding an argument as the document is initialized with InputStream only.

Any help would be appreciated.

Thanks!

Hi Yanyan,


Thanks for your inquiry. After initial investigation that save() method is not working for incremental save in Aspose.Pdf for Java, so we have logged a ticket PDFNEWJAVA-35096 in our issue tracking system for further investigation and resolution. We will notify you as soon as it is resolved.

We are sorry for the inconvenience caused.

Best Regards,

Thanks for you reply. Is there any update on this issue?

Hi Yanyan,


Thanks for your inquiry. We have recently noticed your issue and It is still pending for investigation in the queue with other issues, reported earlier. We will notify you as soon as we made some significant progress towards issue resolution.

We are sorry for the inconvenience caused.

Best Regards,

Hi there,


Is there any update on this issue? Thanks

Hi Yanyan,


Thanks for your inquiry. I am afraid your above reported issue is still not resolved as product team is busy in resolving other issues in the queue, reported earlier. However I have raised the priority of your issue and requested our team to share an ETA at their earliest. We will notify you as soon as we made some significant progress towards issue resolution.

We are sorry for the inconvenience caused.

Best Regards,

Hi Yanyan,


Thanks for your patience.

We have further investigated the issue reported earlier and as per our observations, the document is designed in such a way to edit only annotations and forms. So we can do some allowed changes with keeping extended rights while using file path. Please try using following code snippet.

[Java]

Document document = new Document(myDir + “documentOriginal.pdf”);<o:p></o:p>

TextAnnotation text2 = new TextAnnotation(document.getPages().get_Item(1), new Rectangle(200, 500, 220, 550));

text2.setName ("Text annot with manual popup");

text2.setTitle ("This title not in popup");

text2.setContents ("Description: Text annot with manual popup annotation");

text2.setIcon (TextIcon.Comment);

text2.setColor (Color.getBlue());

text2.setModified (new Date(2000, 11, 22));

document.getPages().get_Item(1).getAnnotations().add(text2);

PopupAnnotation popup2 = new PopupAnnotation(document.getPages().get_Item(1), new Rectangle(100, 400, 400, 500));

popup2.setName ("Manual popup");

popup2.setContents ("Description: Manual popup annotation");

popup2.setModified (new Date(2010, 10, 30));

popup2.setColor (Color.getGreen());

text2.setPopup (popup2);

document.getPages().get_Item(1).getAnnotations().add(popup2);

document.save();

Hi Nayyer,


Thank you for your response. Unfortunately the provided code doesn’t solve the problem for me - What I’m trying to do is edit fields in a fillable form, not adding annotations. So basically I have a pdf file with reader extended feature enabled, and then tried something like:

Document doc = new Document(myDir + “documentOriginal.pdf”);
TextBoxField textBoxField = (com.aspose.pdf.TextBoxField)doc.getForm().get(“topmostSubform[0].Page1[0].OrgName[0]”);
textBoxField.setValue(“Some Org Name”);
doc.save();

The setValue works perfectly, it’s just issue with the save function. I tried saving to a new pdf and saving to original pdf, both caused losing reader extended feature in the resulting pdf. When I open the resulting pdf in Adobe Reader, I got a message saying “This document enabled extended feature in Adobe Reader. The document has been changed since it was created and use of extended feature is no longer available. Please contact the author for the original version of this document.” and all the editable fields are no longer editable in Adobe Reader. This is happening even if I don’t perform any change in form field (i.e. just load the document, and then save it)

I tried with no luck using document loaded with path String, so I was hoping maybe there’s a solution via stream? According to the guide for C# and VB.NET, in order to perform incremental change you have to “open the source file in a Stream object (with read/write file access)”. However in Java new Document() only accepts input stream, so I’m not sure how to perform the document.save() with no argument without specifying the output. Is there any way to enhance the current save method so the incremental save also works in Java?

Please let me know if you have any questions about this issue, or if you need me to provide any additional information. The problem has been sitting there for quite a while and I really hope we can find a way to resolve it asap.

Hi Yanyan,


Thanks for your feedback. I have tested the extended rights scenario with my sample PDF form and I’m unable to notice the issue. We will appreciate it if you please share your sample PDF form here, we will test the scenario and will update you accordingly.

Document doc = new Document(myDir+“PdfFormTest -
Copy.pdf”
);<o:p></o:p>

TextBoxField textBoxField = (com.aspose.pdf.TextBoxField)doc.getForm().get("SingleLineTextField");

textBoxField.setValue("Some Org Name");

doc.save();


We are sorry for the inconvenience caused.

Best Regards,

Hi Tilal,

I tried with a later aspose pdf library and the incremental save() works fine now. It seems that a fix has been made since my initial post, and the problem has now been resolved. Thanks for your help!

Edit: it seems currently this is only working with forms and annotations? Is there any way to make it also work for adding pages?
Hi Yanyan,

yzhang89:
I tried with a later aspose pdf library and the incremental save() works fine now. It seems that a fix has been made since my initial post, and the problem has now been resolved. Thanks for your help!


Thanks for your feedback. It is good to know that you have managed to preserve extended rights while working PDF Forms.

yzhang89:

Edit: it seems currently this is only working with forms and annotations? Is there any way to make it also work for adding pages?

We have logged an enhancement ticket PDFNEWJAVA-35509 in our issue tracking system for the purpose and will keep you updated about the issue resolution progress.

Best Regards,

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan