ImportXML causing documents to no longer be savable/extended features

We have a fill-able PDF which we want to populate with data from an XML. After the fill a user needs to be able to open the PDF in Acrobat/Reader and change entries and still have rights to save the document.

Dim xmlstream As Object = IO.File.Open(InXML, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)Dim doc As Form = New Form
doc.BindPdf(InPDF)
doc.ImportXml(xmlstream)
xmlstream.Close()
doc.Save(OutPDF)

-When this is done and the saved file is opened in Acrobat and the user tries to save the document they get a “The document could not be saved. There was a problem reading this document (105)” error.
-In Reader when opened a prompt “This document enabled extended features in Adobe Acrobat Reader. The document has been changed since it was created and use of extended features is no longer available. Please contact the author for the original version of this document.”

Removing rights using “RemoveUsageRights” methods stops these errors but only blank versions of the forms are allowed to be saved.

I have scoured 15+ threads in Aspose about this and tried many different solutions, none have so far proved successful.

@jrocke

Thank you for contacting support.

You may preserve extended rights with incremental approach as explained in Preserve Extended Rights when Working with Forms.

We hope this will be helpful. Please feel free to contact us if you need any further assistance.

We are not having any luck with the provided link doing the field individually.

Is no way to do this with the XML import? There are complications with adding additional data in the form we are trying to fill if we have to go field by field which don’t occur when XML importing.(button to “add” additional inventors in this example).

Attached is a XML and PDF example.ADS.zip (1.2 MB)

@jrocke

Thank you for sharing respective data.

We have used below code snippet and generated PDF file has been attached for your kind reference. It no more throws the error about preserving extended rights. ADS - Copy.pdf

// Read the source PDF form with FileAccess of Read and Write.
// We need ReadWrite permission because after modification,
// We need to save the updated contents in same document/file.
FileStream fs = new FileStream(dataDir + "ADS - Copy.pdf", FileMode.Open, FileAccess.ReadWrite);
Document document = new Document(fs);
var xmlstream = System.IO.File.Open(dataDir + "ADS.xml", System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
Form doc = new Form();
doc.BindPdf(document);
doc.ImportXml(xmlstream);
xmlstream.Close();
document.Save();
1 Like

Awesome! Thanks a ton this did work! We mistakenly were saving on the Form, not the Document. Thanks!