We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problems with Aspose.Pdf Concatenate

Hello, we are having problems with Aspose.Pdf when we try to do a merge. With Aspose.Pdf.Kit it was working well.

The final pdf size is 0Kb.

We tried to do the merge with both ways:

FileStream notaPg1 = new FileStream("doc1.pdf", FileMode.Open);
FileStream notaPg2 = new FileStream("doc2.pdf", FileMode.Open);
String outputFinal = "doc_Final.pdf";

List listFS = new List();
listFS.Add(notaPg1);
listFS.Add(notaPg2);

FileStream notaFinal = new FileStream(Server.MapPath(outputFinal), FileMode.Create);
PdfFileEditor pdfFileEditor = new PdfFileEditor();
pdfFileEditor.Concatenate(listFS.ToArray(), notaFinal);

FileStream notaPg1 = new FileStream("doc1.pdf", FileMode.Open);
FileStream notaPg2 = new FileStream("doc2.pdf", FileMode.Open);
String outputFinal = "doc_Final.pdf";
FileStream notaFinal = new FileStream(Server.MapPath(outputFinal), FileMode.Create);
PdfFileEditor pdfFileEditor = new PdfFileEditor();
int[] pages = new int[] { 1 };
pdfFileEditor.Insert(notaPg1, 1, notaPg2, pages, notaFinal);
notaFinal.Close();
notaPg1.Close();
notaPg2.Close();

Hello Alexandre,

Thanks for using our products.

When concatenating/merging PDF documents, please try using pdfFileEditor.Concatenate(notaPg1, notaPg2, notaFinal); method instead of pdfFileEditor.Insert(notaPg1, 1, notaPg2, pages, notaFinal);. During my testing with Aspose.Pdf for .NET 6.0.0, I am unable to notice any problem. Please take a look over attached resultant PDF document that I have generated.

In case you have any further query, please feel free to contact. We apologize for your inconvenience.