How to merge multiple PDF's of different sizes into one PDF with uniform pages.

I am reading multiple pdf files into a stream and merging into one PDF document.  It works great if all the pages are the same standard size 8.5" x 11'.  Sometimes one of the multiple documents is a different size, so I need to know how to resize the pdf documents to the legal size 8.5" x 14", so the original document is visible and readable.


5 Replies 1 reply marked as answer

SV Surya Venkatesan Syncfusion Team November 8, 2021 02:41 PM UTC

Hi Karla, 

Thank you for contacting Syncfusion support. 

Currently we do not have support to resize the existing PDF document. However, as a workaround we can able to resize the existing PDF documents by using PdfTemplate. So, we recommend to resize the all PDF documents to similar size and merge those PDF documents into one PDF document. Please try the below sample code snippet for resize the existing PDF document pages and let us know the result. 
 
Note: Please assign required resize value for highlighted variables. 
// Create a new instance of PdfLoadedDocument class.  
PdfLoadedDocument document = new PdfLoadedDocument(path);  
  
// Create a new instance of PdfDocument class.   
PdfDocument doc = new PdfDocument();  
   
SizeF size = new SizeF(document.Pages[0].Size.Width + left + right, document.Pages[0].Size.Height + top + bottom);  
  
//Need to set page size here, if not it will use default size.  
doc.PageSettings.Size = size;  
   
for (int i = 0; i < document.Pages.Count; i++)  
{  
   PdfTemplate template = document.Pages[i].CreateTemplate();  
   PdfPage page = doc.Pages.Add();  
  
   // Create Pdf graphics for the page.  
   PdfGraphics g = page.Graphics;  
  
   g.DrawPdfTemplate(template, new PointF(0, 0), new SizeF(page.GetClientSize().Width, page.GetClientSize().Height));  
}  
  
doc.Save("output.pdf”); 

Once resized the existing PdfDocuments then merge those PDF documents. Kindly find the below link to get more details,  

Please let us know if you need any further assistance with this. 

Regards, 
Surya V

Marked as answer

KF Karla Franke December 1, 2021 02:20 PM UTC

We have successfully implemented this solution and it did exactly what I needed.  Thank you so much for your assistance.


Karla




GK Gowthamraj Kumar Syncfusion Team December 2, 2021 06:36 AM UTC

Hi Karla, 
 
Thank you for your update. We are glad to know that the workaround solution resolved your problem. 
 
Please let us know if you need any further assistance with this. 
 
Regards, 
Gowthamraj K 



WI will November 16, 2022 06:24 AM UTC

Drag and drop PDFs to merge them into one file with our PDF combiner. Select PDFs to combine into one file. Select PDFs to combine into one file. Your files will be securely uploaded to Adobe cloud storage


Regards,

Will



AA Anitha Azhagesan Syncfusion Team November 17, 2022 05:45 AM UTC

Thanks for your suggestion. This is also one of the possibilities to achieve 


Loader.
Up arrow icon