Convert XFA to AcroForm and Merge PDFs using Aspose.PDF for .NET

Hi.

We merge pdf documents using such code:

var outputDocument = new Document();

foreach (var documentName in files)
{
var inputDocument = new Document(documentName.Key);
outputDocument.Pages.Add(inputDocument.Pages);
}
outputDocument.Convert(new MemoryStream(), PdfFormat.PDF_A_1B, ConvertErrorAction.Delete);
outputDocument.Save(resultFileName);

And faced with one document wich cannot be merged in such way (attached - Original.pdf).
If we convert it to pdf/a all is working fine (attached - Converted.pdf) but if we try to merge we get document with error in it (attached - Merged.pdf).

I have an assumption that forms in file causes this issue. Is it a Aspose bug or we may fix it in code?

Thanks

Thanks for your inquiry.

Please note you are getting an exception because trying to merge dynamic XFA PDF forms. You should convert dynamic XFA to AcroForms before concatenation, it will resolve the issue. Please check documentation link to convert dynamic XFA Form to Acro Form and following code for concatenation. Hopefully, It will help you to accomplish the task.

string OutputFile = myDir + “Concatenating _XFA_DOM.pdf”;
MemoryStream ms1 = new MemoryStream();
MemoryStream ms2 = new MemoryStream();
string FileA = myDir + “Original.pdf”;
Document mergeDocument = new Document(FileA);
// set the form fields type as standard AcroForm
if (mergeDocument.Form.Type == FormType.Dynamic)
{
 mergeDocument.Form.Type = FormType.Static;
}
mergeDocument.Save(ms1);
string FileB = myDir + “Input.pdf”;
Document nextDocument = new Document(FileB);

// set the form fields type as standard AcroForm
if (nextDocument.Form.Type == FormType.Dynamic)
{
 nextDocument.Form.Type = FormType.Standard;
}

nextDocument.Save(ms2);
mergeDocument = new Document(ms1);
nextDocument = new Document(ms2);
mergeDocument.Pages.Add(nextDocument.Pages);
mergeDocument.Save(OutputFile);
ms1.Close();
ms2.Close();

Please feel free to contact us for any further assistance.

Best Regards

Hi again.
Your approach was good but we still have some issues in converted document (see attached).

1. Wrong formatting in form (font style and size). For example see area 19 in attached document where data became too long and did not fit.

2. Vertical labels in the bottom of the page are horizontal and has ‘undefined value’ value.

uaprogrammer:
Your approach was good but we still have some issues in converted document (see attached).

1. Wrong formatting in form (font style and size). For example see area 19 in attached document where data became too long and did not fit.

2. Vertical labels in the bottom of the page are horizontal and has ‘undefined value’ value.
Hi Mikhail,

Thanks for sharing the details.

I
have tested the scenario where I have tried converting source XFA form to Standard AcroForm and I am able to reproduce the same problems. For the
sake of correction, I have logged it in our issue tracking system as PDFNEWNET-38046. We will
investigate this issue in details and will keep you updated on the status of a
correction. <o:p></o:p>

We apologize for your inconvenience.

[C#]

Document pdfDocument = new Document("c:/pdftest/Original (2).pdf");

pdfDocument.Form.Type = FormType.Standard;

pdfDocument.Save("c:/pdftest/Original_StandardConverted.pdf");

<span style="font-size:11.0pt;font-family:"Calibri","sans-serif";

mso-fareast-font-family:Calibri;mso-fareast-theme-font:minor-latin;mso-bidi-font-family:
“Times New Roman”;mso-ansi-language:EN-US;mso-fareast-language:EN-US;
mso-bidi-language:AR-SA">Please share the thread status with us and expected
ETA to get the issue resolved. <!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman","serif";}

<![endif]–>

Hi Mikhail,


Thanks for your inquiry. I am afraid your reported issue is still not resolved due to other issues, already under investigation and resolution. We will share an ETA as soon as investigation of issue is completed.

We are sorry for the inconvenience caused.

Best Regards,

Hi,

Would you be so kind to provide us with status on the PDFNET-38046 issue?

Best regards,

Oleh

@uaprogrammer

We regret that earlier logged issue has not been yet resolved. However, we have recorded you concerns and will surely inform you as soon as we have some definite updates in this regard. Please spare us little time.

We are sorry for the inconvenience.

Hi,

Would you be so kind to provide us with status on the PDFNET-38046 issue?

Best regards,

Oleh

@uaprogrammer

We apologize for the delay and inconvenience.

The issue is not yet resolved due to other high priority tasks. We will surely inform you as soon as it is resolved. Please spare us some time.

Hi! We are wondering if there are any updates regarding the issue?

B.R.
Oleh

@uaprogrammer

We are afraid that we do not have any updates at the moment regarding ticket resolution. However, we will surely post in this thread as soon as there are some news about fix of the issue or its ETA. We highly appreciate your patience in this regard.

We apologize for the inconvenience.