Filling PDF form with XML using Aspose.Pdf.Facades.Form.ImportXml

Hi Aspose Team. I’m trying to fill in form from existing PDF document (some kind of template) using Aspose.Pdf.Facades.Form.ImportXml and then export the result as http attachment. Everything is OK except the result is “read-only” in Adobe Reader: no fields could be changed, no buttons are working and so on. Filling Form Fields in resulting document’s properties is setting to Not Allowed…
Xml itself is OK. I have tested it using Form Options - Import Data feature of the Adobe Reader. The result is OK in this case.
I’m using trial version of the Aspose.pdf. Could the issue be caused by the trial version usage?

@VladVinogradCD

It seems that you are experiencing issues with the PDF form being read-only after filling it with XML data using the Aspose.Pdf.Facades.Form.ImportXml method. This can happen for a few reasons, and I will provide some insights that may help you resolve the issue.

  1. PDF Permissions: The resulting PDF may have permissions set that restrict editing. When you save the PDF after importing the XML data, ensure that you are not inadvertently setting permissions that make the form fields read-only.

  2. Trial Version Limitations: While the trial version of Aspose.PDF does have some limitations, it typically does not restrict the functionality of filling forms. However, it is always a good idea to check the documentation or any specific notes regarding the trial version to ensure there are no hidden restrictions.

  3. Code Implementation: Make sure your implementation follows the correct steps for importing XML data. Here’s a basic example of how to use the ImportXml method:

    using System.IO;
    using Aspose.Pdf;
    using Aspose.Pdf.Facades;
    
    namespace Aspose.Pdf.Examples.CSharp.AsposePDFFacades.Forms
    {
        public class ImportDataFromXML
        {
            public static void Run()
            {
                // Path to the documents directory
                string dataDir = "path_to_your_directory/";
    
                // Open the PDF document
                Form form = new Form();
    
                // Open the XML file
                using (FileStream xmlInputStream = new FileStream(dataDir + "input.xml", FileMode.Open))
                {
                    // Import data from XML
                    form.ImportXml(xmlInputStream);
                }
    
                // Save the updated document
                form.Save(dataDir + "ImportDataFromXML_out.pdf");
            }
        }
    }
    
  4. Testing with Adobe Reader: Since you mentioned that the XML works fine when using Adobe Reader’s “Import Data” feature, ensure that the structure of your XML matches what the PDF form expects. Any discrepancies might lead to unexpected behavior.

If you continue to face issues, consider checking the Aspose documentation for any additional settings or methods that might be relevant to your specific use case.

If the problem persists, you might want to reach out to Aspose support for further assistance, especially if you suspect it could be related to the trial version.

Sources:
[1]: Import and Export Data|Aspose.PDF for .NET - Aspose Documentation
[2]: ImportDataFromXML.cs