We are using Aspose.PDF to merge pdf files. Attached are 2 sample documents that need to be merge, they are the same document, renamed.
Problem Statement: When documents with dynamic fields like drop downs and editable text fields are merged with other such documents, the result is losing these dynamic fields.
Expected Result: We want to preserve these dynamic fields even after the merge.
Aspose’s online example at - How to Merge PDF using C#|Aspose.PDF for .NET is able to do the merge correctly, but when write the same code in a standalone console or windows app, it is still losing these dynamic fields for the first document.
Code Snippet:
using System;
using System.IO;
using System.Windows.Forms;
using Aspose.Pdf;
namespace AsposeMerge
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
AsposeMerge();
}
private void AsposeMerge()
{
string f1 = @"C:\Users\nbdelxy\Desktop\d0ae7428-4eb2-4c59-abd4-2b9fdb373baa.pdf";
string f2 = @"C:\Users\nbdelxy\Desktop\testmergepdfs.pdf";
string outFile = @"C:\Users\nbdelxy\Desktop\testing123.pdf";
Aspose.Pdf.License lic = new Aspose.Pdf.License();
lic.SetLicense("Aspose.Total.lic");
Aspose.Pdf.Document doc1 = new Document(f1);
Aspose.Pdf.Document doc2 = new Document(f2);
MemoryStream outStream = new MemoryStream();
try
{
doc1.Pages.Add(doc2.Pages);
doc1.Save(outStream);
using (FileStream file = new FileStream(outFile, FileMode.Create, FileAccess.Write))
{
byte[] bytes = new byte[outStream.Length];
outStream.Read(bytes, 0, (int)outStream.Length);
file.Write(bytes, 0, bytes.Length);
outStream.Close();
}
}
catch (Exception ex)
{
;
}
}
}
}
We are sorry for the inconvenience caused.
While testing the scenario with the latest version of Aspose.Pdf for NET 8.8.0,
We have managed to reproduce the reported issue and logged it in our bug
tracking system as PDFNEWNET-36386 for further investigation and
resolution. We will notify you via this thread as soon as it is resolved.
Please feel free to contact us for
any further assistance.
In addition to above reply, as a workaround you can use facade package to merge PDF documents. It is working fine with you source document, i.e. preserving form fields. However, we will keep you updated about the resolution progress of original issue.
We tried with Façade solution. It
works but the output is a bit strange. Every time you open the output document,
the dynamic fields seem to shift to different pages. <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Example: First time I open the
output file, fields are not shown in page 10, 12, 16, etc. I close it and
reopen it, now directly jump to end of the document – page 16. You will see
that fields appear but are lost on other pages. Dynamic fields are never shown
on page 9. I am not sure if this is a result of the using the Aspose image tool or the
behavior of merged pdfs with dynamic fields. Do you have any input on this?
Code:
publicvoid
AsposeMergePDFStream()
{
Aspose.Pdf.License lic = new Aspose.Pdf.License();
lic.SetLicense("Aspose.Total.lic");
string f1 = @"C:\Users\nbdelxy\Desktop\testmergepdfs1.pdf";
We tried with Façade solution. It
works but the output is a bit strange. Every time you open the output document,
the dynamic fields seem to shift to different pages. <o:p></o:p>
Example: First time I open the
output file, fields are not shown in page 10, 12, 16, etc. I close it and
reopen it, now directly jump to end of the document – page 16. You will see
that fields appear but are lost on other pages. Dynamic fields are never shown
on page 9. I am not sure if this is a result of the using the Aspose image tool or the
behavior of merged pdfs with dynamic fields. Do you have any input on this?
Hi Robert,
Thanks for sharing the details.
I have tested the above stated scenario and following are my observations.
Open merged document and traverse through pages starting form page 1. The form fields on page 9, 10, 11, 12, 13, 14, 15, 16 fields missing.
Open the document and directly jump to page 16 and traverse in back direction. The form fields on page 2, 3, 4, 5, 6, 7, 8, 9, 13 are missing.
For the sake of correction, I have separately logged this problem as PDFNEWNET-36395 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction. Please be patient and spare us little time.
As we
recently have been able to notice this issue, so development team requires
little time to investigate and figure out the reasons of this problem.
However, as soon as we have made some definite progress towards
its resolution, we would be more than happy to update you with the status of
correction.<o:p></o:p>
Furthermore, please note that you
have reported issue under normal/free support forum and as a normal rule
of practice, issues are resolved in first come and first serve basis; but the
problems logged/reported under Enterprise or Priority support model, have high
precedence in terms of resolution, as compare to issues under normal/free
support model.
Thanks for your inquiry. I am afraid your reported issue (PDFNEWNET-36386) is still not resolved, it is pending for investigation in queue with other priority task. We have requested our development team to investigate the issue and share an ETA at their earliest. We will notify you as soon as we get a feedback.<o:p></o:p>
Thanks for your patience and cooperation.<o:p></o:p>