Dynamic XFA flattening attempt failed

Hi,

Using Aspose.PDF developer v19.2.0, and trying to flatten a pre-filled in dynamic XFA form into a standard PDF.
The intent is to have the form viewable in a regular browser window.
During the process, some fields fail and the result has shifted label elements and it is missing field values. The failing fields are formatted as table cells and contained within a subform-into-form structure.
I can provide the before/after PDFs on a pm.
This is the sequence of code used to flatten for XFA form:

  SetAsposeLicense();
  var doc = new Aspose.Pdf.Document(File.OpenRead("Files/xfa_form_original.pdf"));
  doc.Flatten(new Form.FlattenSettings{UpdateAppearances = true});
  doc.Form.Type = FormType.Standard;
  doc.Save("Files/xfa_form_flatten_aspose.pdf");

@vitralogydev

Thank you for contacting support.

Please note that the file attachments are accessible to thread owner and Aspose staff only. However, you may also share respective files via private message by clicking on my username. After sending the message, please acknowledge here as well, for reference.

just sent a private message containing the before and after PDFs
thank you,

@vitralogydev

Thank you for sharing requested data.

Would you please try below code snippet in your environment and then share your kind feedback with us. We have also attached generated PDF document for your kind reference. xfa_form_original_flattened_19.2.pdf

Document doc = new Document(dataDir + "xfa_form_original.pdf");
foreach (string fieldName in doc.Form.XFA.FieldNames)
{
    try
    {
        XmlNode template = doc.Form.XFA.GetFieldTemplate(fieldName);
        XmlAttribute access = template.OwnerDocument.CreateAttribute("access");
        access.Value = "readOnly";
        template.Attributes.Append(access);
    }
    catch (Exception ex)
    {
        continue;
    }
}
doc.Save(dataDir + "xfa_form_original_flattened_19.2.pdf");

Thank you for your response.

unfortunately, the suggested approach does not help with what we are looking for.
We are trying to accomplish the following:

  • convert the XFA form into a flat PDF so the browser preview will be able to show it correctly
  • during conversion copy all the field values in the flattened PDF, so no information is lost after conversion

Original approach we tried (initial code sequence) does the XFA flattening, and the result is displayed in a web browser preview, but during the process flattening some of the field values are either lost or shifted off their original position:
image.png (138.5 KB)

The suggested approach you provided did not convert the XFA to a PDF (that could be done with a flattening action), also did not capture (lost their value) some of the fields:
image.png (79.3 KB)

Additional to that, since the file is still a XFA form, the web browser preview would fail to show the document as well:
image.png (37.8 KB)

Is there a way to find and figure out why the table fields do not get captured as text during conversion?

Thank you,
VitralogyDev

@vitralogydev

Thank you for sharing further details.

We have been able to notice the problem so we have logged a ticket with ID PDFNET-46065 in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.

@Farhan.Raza I was wondering if you have any updates on PDFNET-46065

If we would have had a paid support option, what would be the expected resolution and release time frame for this issue?
We are pressed to decide which way to go w our implementation, if to stay w Aspose.PDF approach or look for alternatives that can handle XFA PDFs as well.

thank you,
vitralogyDev

@vitralogydev

We are afraid there are not any updates yet. However, we have recorded your concerns and will let you know after initial investigations that how soon can it be resolved with Paid Support. Please be patient and spare us little time.

hi Farhan, any news on this issue?

@vitralogydev

The investigation against earlier logged ticket is currently underway. As soon as investigation is complete, we will surely let you know in this forum thread. Please spare us little time.