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 - http://www.aspose.com/demos/.net-components/aspose.pdf/csharp/pdfdemos/General/Concatenate.aspx
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;
usingAspose.Pdf;
namespace AsposeMerge
{
publicpartialclassForm1 : Form
{
public Form1()
{
InitializeComponent();
}
privatevoid
button1_Click(object sender, EventArgs e)
{
AsposeMerge();
}
privatevoid
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 = newDocument(f1);
Aspose.Pdf.Document doc2 = newDocument(f2);
MemoryStream outStream = newMemoryStream();
try
{
doc1.Pages.Add(doc2.Pages);
doc1.Save(outStream);
using (FileStream
file = newFileStream(outFile,FileMode.Create, FileAccess.Write))
{
byte[] bytes = newbyte[outStream.Length];
outStream.Read(bytes, 0, (int)outStream.Length);
file.Write(bytes, 0, bytes.Length);
outStream.Close();
}
}
catch (Exception
ex)
{
;
}
}
}
}v