Please, can you upload on this ticket your input files and the code that you are using to “merge” the documents? I would also like to know the version of Aspose.PDF that you are using.
Hi
thank you for quick response. Unfortunately - the form in question is having some sensitive personal information and not suitable for sharing in support forum. However, i can confirm it sounds like a bug, as we are able to workaround the issue by doing something like below.
basically
we have 3 steps:
a pdf (generated by converting some other file to PDF by ASPOSE total) - call it main.pdf
a pdf which is a dynamic form pdf, call it attachment.pdf
a method will concat attachment.pdf to the end of main.pdf
this process works fine for all other files, but when #2 is an dynamic form pdf it does not work by default (due to xfa form limitations) as this is not handled properly by default in ASPOSE, so we have to write a helper method to process the #2 attachment.pdf like below
public static Aspose.Pdf.Document ByteArrayToPdf(this byte[] attachmentAsPdfByteArray)
{
var msPdf = new MemoryStream(attachmentAsPdfByteArray);
var attachmentAsPdf = new Aspose.Pdf.Document(msPdf);
//fix to handle aspose-issue for dynamic form pdf - start
//refer https://docs.aspose.com/pdf/net/xfa-forms/#convert-xfa-to-acroform
if (attachmentAsPdf.Form.Type == Aspose.Pdf.Forms.FormType.Dynamic)
{
attachmentAsPdf.Form.Type = Aspose.Pdf.Forms.FormType.Standard;
attachmentAsPdf.Flatten(); //need the form as printed
}
//fix to handle aspose-issue for dynamic form pdf - end
return attachmentAsPdf;
}
now aspose can handle the dynamic form pdf and the resultant combined pdf is ok in looks, but creates an error in adobe viewer. image.png (5.1 KB)
This is the issue we reported in this thread.
But we could work around this issue - by saving the attachment.pdf and reopening it again, somehow magically the issue is resolved and adobe is no longer complaining about the pdf generated after concatenation. We believe this should be unnecessary step and purely workaround and imply a bug in aspose, Please consider for fixing in future release.
Fixed code with workaround:
public static Aspose.Pdf.Document ByteArrayToPdf(this byte[] attachmentAsPdfByteArray)
{
var msPdf = new MemoryStream(attachmentAsPdfByteArray);
var attachmentAsPdf = new Aspose.Pdf.Document(msPdf);
//fix to handle aspose-issue for dynamic form pdf - start
//refer https://docs.aspose.com/pdf/net/xfa-forms/#convert-xfa-to-acroform
if (attachmentAsPdf.Form.Type == Aspose.Pdf.Forms.FormType.Dynamic)
{
attachmentAsPdf.Form.Type = Aspose.Pdf.Forms.FormType.Standard;
attachmentAsPdf.Flatten(); //need the form as printed
//workaround to handle font error in adobe - cannot find or create the font - START
var byteArray = attachmentAsPdf.SaveAsByteArray(); //helper method to convert pdf to byte[] using a memory stream
return byteArray.ByteArrayToPdf(); //called recursively, but this time it wont be dynamic form instead standard form
//workaround to handle font error in adobe - cannot find or create the font - END
}
//fix to handle aspose-issue for dynamic form pdf - end
return attachmentAsPdf;
}
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.