We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

PDF merge leads to strange results

hi

I try to merge several PDF files into one, and each file can have its own format : A4L, A4P, A3L, A3P, A1 or A0, and some may even have a strange square-like format, mainly because it's been PDF converted from a PNG I guess.

when the individual file has a "standard" format, everything goes to plan, and the final PDF shows each page the way it's intended : it goes from P to L without trouble.

but when there's a "strange" format, it seems that the merge cannot find what to do with it, and keeps the last know format, from the previous merged file, and it results in some truncated page, with huge white borders.

original :

original.jpg


merged :

merge.jpg


I tried two ways for the merge, the automatic one ("source" containing the source files in string):


PdfLoadedDocument finalDoc = new PdfLoadedDocument(fileName);

PdfDocument.Merge(finalDoc, source.ToArray());


and the manual one :

PdfLoadedDocument finalDoc = new PdfLoadedDocument(fileName);

PdfDocument.Merge(finalDoc, source.ToArray());

foreach (var docToAppend in source)

            {

                  PdfLoadedDocument append = new PdfLoadedDocument(docToAppend);

                  finalDoc.Append(append);

                  append.Close(true);

             }


and the result is the same.

I've tried to search in the properties of the PDFLoadedDocument object at runtime, and find nothing containing the format of the file, so I'm pretty much stuck.

any ideas ?

thanks


7 Replies

IJ Irfana Jaffer Sadhik Syncfusion Team October 27, 2022 01:12 PM UTC

Hi Pain,

Based on your update, we suspect the page size is changed after merging the different-sized PDF documents. And we have tried to reproduce the issue on our end with test documents and we could not reproduce the reported issue. So we request you to share the simple sample, input and output PDF files with the exact issue details, it would be more helpful for us to analyze further.

Regards,

Irfana J




PJ PAIN JOHNNY October 27, 2022 01:51 PM UTC

hi,

thank you for your answer.

here's a zip file containing the 2 individual pdfs you can see on my screenshots.

this is all part of a much much bigger C# solution, I'll try to create a small sample solution if you still can't replicate the problem with the two files provided.


Attachment: merge_pb_92d28caa.zip


IJ Irfana Jaffer Sadhik Syncfusion Team October 28, 2022 01:50 PM UTC

Hi PAIN,


We have tried to reproduce the reported behavior with the provided details on our end but it is working properly. we have attached the sample for your reference. Please try this on your end and let us know the result.


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/CreatePDFSample717319772


If you are still facing the issue, we request you share the modified sample, product version with us. so that will be helpful for us to assist you further in this.


Regards,

Irfana J.



PJ PAIN JOHNNY November 18, 2022 10:30 AM UTC

sorry, I didn't see your reply at the time and forgotten about this topic ^^

I'll have a look at it and come back to you.

thanks again.



PJ PAIN JOHNNY November 28, 2022 09:49 AM UTC

hi

I've tried your sample and it works well.

I'll have to see why it keeps doing this in my (huge) solution.

thanks.



PG Peter Groft January 20, 2023 07:51 AM UTC

Click the Select files button above or drag and drop files into the drop zone.
Select the files you want to merge using the Acrobat PDF combiner tool.
Reorder the files if needed.
Click Merge files.
Download the merged PDF. Sign in to organize individual pages or share the file.

Hope You Find This Useful,
Peter



IJ Irfana Jaffer Sadhik Syncfusion Team January 23, 2023 05:06 AM UTC

Thank you for your suggestion


Loader.
Live Chat Icon For mobile
Up arrow icon