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.
// 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”); |
We have successfully implemented this solution and it did exactly what I needed. Thank you so much for your assistance.
Karla
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
Thanks for your suggestion. This is also one of the possibilities to achieve