Page 1 of 1

Console: Draw one PDF page on another PDF page.

Posted: Mon Apr 06, 2015 4:58 pm
by Alex
Here is an example that shows how to draw one PDF page on another PDF page:

Code: Select all

public void Test()
{
    using (PdfDocument document1 = new PdfDocument("document1.pdf"))
    {
        using (PdfDocument document2 = new PdfDocument("document2.pdf"))
        {
            DrawPage(document1.Pages[0], document2.Pages[0], document1.Pages[0].MediaBox);
            document1.SaveChanges();
        }
    }
}

public void DrawPage(PdfPage sourcePage, PdfPage topPage, RectangleF rect)
{
    using (PdfGraphics g = sourcePage.GetGraphics())
        g.DrawPageAsForm(topPage, rect);
}