Fill Duplicate XFA Pages with Data and merge PDF files using Aspose.PDF for .NET

C10jan18.pdf (1.5 MB)

I have the attached PDF, which is a voucher and I have no control over the how this PDF is created. I’m currently filling it out using C# and Aspose, which is going fine.
What I would like to do though, is fill it out multiple times with different data and append all of those copies to a single PDF file.

I’ve tried using

        Document pdfDocument = new Document(physicalPath);
        Document altDocument = new Document(physicalPath);
        pdfDocument.Pages.Add(altDocument.Pages);
        pdfDocument.Save(ms);

to no avail, which I’m suspicious is due to the file being XFA. I have tried converting it to a standard PDF via FormType.Standard, assuming I would be able to then move the pages, but the conversion introduces its own problems. Specifically the layout goes a bit wonky and the narrow column headers break out of their constraints.

Any insight or direction you can provide is much appreciated.

@jjil

Thank you for posting separately.

XFA forms may not be flattened as AcroForm so we have tried to make fields of XFA form read-only with following code:

        Document doc = new Document("PdfDynamicForm.pdf");
        foreach (string fieldName in doc.Form.XFA.FieldNames)
        {
            XmlNode template = doc.Form.XFA.GetFieldTemplate(fieldName);
            XmlAttribute access = template.OwnerDocument.CreateAttribute("access");
            access.Value = "readOnly";
            template.Attributes.Append(access);

        }
        doc.Save("23543.pdf");

However, the concatenated file contains only one page instead of two; so a ticket with ID PDFNET-45821 has been logged in our issue management system for further investigation and resolution. We will let you know as soon as some significant updates will be available in this regard.