Hello
I want to insert an existing PDF (A4) into another PDF (a4), but i want to resize the PDF bevor.
I thank you in advance for the help
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(FilePath + "sample1.pdf");
PdfDocument newPdf = new PdfDocument();
foreach (PdfPageBase page in doc.Pages)
{
//Create a new PDF page with Page size =A4 and PDFMargins at 0.
PdfPageBase newPage = newPdf.Pages.Add(PdfPageSize.A4, new PdfMargins(0));
PdfTextLayout loLayout = new PdfTextLayout();
loLayout.Layout = PdfLayoutType.OnePage;
//Copy the contents of page into the new PDF page at the PointF(0,0)
page.CreateTemplate().Draw(newPage, new PointF(0, 0), loLayout);
}
//save the resized PDF to stream
MemoryStream s = new MemoryStream();
newPdf.SaveToStream(s);
//open another PDF
FileStream s1 = File.OpenRead(FilePath + "sample2.pdf");
Stream[] streams = { s1, s };
//merge documents by stream
PdfDocumentBase resultPdf = PdfDocument.MergeFiles(streams);
resultPdf.Save("8145.pdf", FileFormat.PDF);