We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Make PDF generated editable JAVA

Hi,
I am trying to make a document editable generated through ASPOSE PDF JAVA 17.3 version. However the Document generated cannot be edited and saved/saved as. It says that the form cannot be filled when opened in Adobe Acrobat Reader.
Please let me know the exact code to enable PDF form security settings for Read/Write mode.

I have used the below code to enable Read/Write mode on the fields in Adobe Reader so that a document can be edited and saved. However this does not work.


com.aspose.pdf.Document newPdfDoc= new com.aspose.pdf.Document(inputStream);

PdfFileSecurity fileSecurity = new PdfFileSecurity(newPdfDoc);

		 DocumentPrivilege documentPrivilege = DocumentPrivilege.getAllowAll();
		 
	 		documentPrivilege.setAllowScreenReaders(true); 
	 		documentPrivilege.setAllowPrint(true); 
	 		documentPrivilege.setAllowFillIn(true);
	 		documentPrivilege.setAllowModifyContents(true);
	 		documentPrivilege.setAllowModifyAnnotations(true);
	 		
	 		documentPrivilege.setAllowCopy(true);
	 		documentPrivilege.setAllowAssembly(true);
	 		
	 		fileSecurity.setPrivilege(documentPrivilege);
	 		
	 		fileSecurity.bindPdf(newPdfDoc);

newPdfDoc.encrypt(“user”, “owner”, documentPrivilege, CryptoAlgorithm.AESx256, false);
ByteArrayOutputStream pdfDocOutputStream = new ByteArrayOutputStream();
newPdfDoc.save(pdfDocOutputStream);


Ownership Legal Entity Shareholding.pdf (108.0 KB)

This document cannot be Saved /Saved as in Adobe Reader. Please try and advise urgently.

I have also tried the code with:
DocumentPrivilege documentPrivilege = DocumentPrivilege.getForbidAll();

But no resolution.
Please find the error attached.
save Error.jpg (31.8 KB)

@pexy_poulose

Thanks for contacting support.

We have tested the scenario in our environment and managed to replicate the same issue which you have reported. Therefore for the sake of correction, we have logged this issue as PDFJAVA-36939 in our issue tracking system. We will further look into the details of the issue and keep you updated with the status of its resolution. Please be patient and spare us little time.

We are sorry for the inconvenience.

Ok thanks. Also please note the issues are:

  1. No fields can be edited.
  2. Document cannot be saved/saved as

Please work on it urgently as our go live date is near.

Thanks

@pexy_poulose

Thanks for writing back.

I have tried to edit form fields value in Adobe Reader and did not notice any issue, as I was able to fill the form fields. Though document was unable to be saved/saved as, and I have logged that information with the issue as well.

Now that issue has been logged in our issue tracking system, the relevant team will look into this as per their development schedule. As soon as we have some updates in this regard, we will inform you. Please be patient and spare us little time.

We are sorry for the inconvenience.

Yes, even I could generate the PDF with editable fields with this line of code:

newPdfDoc.encrypt(“user”, “owner”, documentPrivilege, CryptoAlgorithm.AESx256, false);

However I do not intend to keep this document password protected. Is there any way to avoid using encrypt?

@pexy_poulose

You may save the document without using encrypt() method, like below code snippet. Please note that I have also tried to save the document with below code snippet but did not get much success. The document remained protected to be saved as.

fileSecurity.setPrivilege(documentPrivilege);
fileSecurity.save(dataDir + "Ownership Legal Entity Shareholding_edited.pdf");

Ok,that’s good to know. I have tried this too but along with the combination of encrypt so thought that it is working coz of encrypt method.

@pexy_poulose

Thanks for writing back.

Would you please share if you are facing this issue with specific document, which you have shared, or all the documents? Furthermore, please confirm if you are generating the document with Aspose.Pdf for Java or some other tool. This would really help us in investigation of the issue.

Hi,
It is the same document which was attached earlier that has this issue. This document is generated from ASPOSE PDF for Java and no other API.

@pexy_poulose

Thanks for sharing more details.

As soon as we have some definite updates about the resolution progress of your issue, we will inform you within this forum thread. Please spare us little time.

We are sorry for the inconvenience caused.

Hi ,
Please provide an ETA for this issue.

Thanks.

@pexy_poulose

Thanks for your inquiry.

Please note that we just have logged the issue in our issue tracking system for the investigation purpose and I am afraid that we cannot share any ETA for now as there are other issues in the queue as well which were logged prior to this. Product team will definitely investigate your issue as per their development schedule.

As soon as we have some definite updates about the resolution progress of this issue, we will surely inform you. Your patience and comprehension in this regard will be highly appreciated. Please give us little time.

We are sorry for the inconvenience.

Hi,
Thanks for your reply. Please let the Product team know that this is a high priority issue so it needs to be picked up at the earliest.
We are awaiting a response on this ASAP (a test jar along with the fix) as our go live date of this functionality is next week.

Thanks

@pexy_poulose

Thanks for contacting support.

The product team has investigated your issue and found that there were no restrictions in saved document but it was a restriction of Adobe Reader that has not fully support of XFA Forms. For full-fledged work with XFA Forms Adobe Acrobat Pro should be used.

But the form could be converted to standard and then the document can be easily filled and saved in Acrobat Reader too. Please, see the code snippet below:

Document doc = new Document(dataDir + "Ownership Legal Entity Shareholding.pdf", "user");
doc.getForm().setType(FormType.Standard);
doc.save(dataDir + "Ownership Legal Entity Shareholding_edited.pdf");

For your reference, I have also attached resultant document, obtained from above code snippet. In case of any further assistance, please feel free to contact us.

Ownership Legal Entity Shareholding_edited.pdf (103.8 KB)

Thanks for your quick reply.
I tried the code mentioned and it worked fine to Save and edit fields in the file in Acrobat Reader.

However one of the fields in the file %Shares has a formula based calculation done based on the input field like #Shares.
This formula does not work on the generated document attached. Also , I tried to convert into Dynamic Form as below.

doc.getForm().setType(FormType.Dynamic);

However while converting to Output stream, facing the error :

Issues when saving the aspose PDF document to a stream and converting back as stream for ce document:
The ‘static’ form can’t be converted into ‘dynamic’

Please advise.

Please find the file which is generated (where in % Shares formula is not working) :Ownership Legal Entity Shareholding_FormulaNotWorking.pdf (98.0 KB)

Please find the file which is generated (where in % Shares formula is working correctly in Adobe Reader) .
This file was provided by user.

Ownership Legal Entity Shareholding.pdf (131.3 KB)