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

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


5 Replies

IJ Irfana Jaffer Sadhik Syncfusion Team October 27, 2022 08:12 AM

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 08:51 AM

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 08:50 AM

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 05:30 AM

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 04:49 AM

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.


Loader.
Live Chat Icon For mobile
Up arrow icon