Preserve page settings when merging PDFs

I am using Aspose.pdf to merge a number of existing PDFs into one. The existing PDFs have different page margins and orientations - how can I preserve the page layout of each when creating the merged PDF?

Hi Rick,


Thanks for your inquiry. Please check following documentation link for concatenating PDF documents. It preserves the page layout of source documents.

Please feel free to contact us for any further assistance.

Best Regards,

Thank you for the response, but this code is not preserving the entire page layout of the source documents (this is the exact code I have been using). The page layout of the entire PDF appears to be established from the first PDF included in the merge.

If the first PDF is in Landscape, the page height of the entire document is fixed but the width does change; the pages in portrait are truncated at the top with the lower portion of each page kept in the merged document.

If the first PDF is in Portrait, the page width of the entire document is fixed but the height does change; the pages in landscape are truncated at the right with the left side of each page kept in the merged document.

Please help.

Hi Rick,


Thanks for your feedback. Please share your sample code and documents here. We will look into it and guide you accordingly.

We are sorry for the inconvenience caused.

Best Regards,

Here is the code I am running:

Dim licensePDF As Aspose.Pdf.License = New Aspose.Pdf.License
licensePDF.SetLicense("Aspose.Total.lic")

'Open first document
Dim pdfDocument1 As New Document(“C:\aatemp\Aspose\Test1.pdf”)
'Open second document
Dim pdfDocument2 As New Document(“C:\aatemp\Aspose\Test2.pdf”)

'Add pages of second document to the first
pdfDocument1.Pages.Add(pdfDocument2.Pages)

'Save concatenated output file
pdfDocument1.Save(“C:\aatemp\Aspose\output.pdf”)

 
I am attaching the two files I am attempting to merge as well as the merged pdf.

Hi Rick,

Thanks for sharing the resource files.

I have tested the scenario and I am able to reproduce the same problem. For the sake of correction, I have logged it in our issue tracking system as PDFNEWNET-38911. We will investigate this issue in details and will keep you updated on the status of a correction.

We apologize for your inconvenience.

Thanks for the response. This is a critical issue for us - we have a production move scheduled at the end of this month and we are replacing our existing document manager with the Aspose products. I can’t believe that no one has come across this problem before.

Hi Rick,


Thanks for sharing the feedback.

Please note as a normal rule of practice, all issues are resolved in first come first serve basis as we believe its the fairest policy to all the customers. However as a workaround to your problem, please try using following code snippet.

For your reference, I have also attached the resultant file generated over my end.

[C#]

Aspose.Pdf.Facades.PdfFileEditor pdfEditor = new Aspose.Pdf.Facades.PdfFileEditor();

pdfEditor.Concatenate(@“C:\Test1.pdf”, @“C:\Test2.pdf”, @“C:\MergedOutput.pdf”);

Thank you for your quick response. This code worked great!

Rick

Hi Rick,


I am glad to hear that your problem is resolved. Please continue using our API and in the event of any further query, please feel free to contact.

Now concerning to problem related to Document class, we will further investigate the issue and will keep you posted on the status of correction. Please be patient and spare us little time.