Search code examples
scalepdfsharp

PDFsharp - Change page size and scale content


Is it possible to scale a page from e.g. A2 to A1 with PDFsharp? I can set the size of the page via Size, Width and Height. But how can I scale the content of the page?


Solution

  • You can use DrawImage() to draw an existing PDF page on a new PDF page. You can specify the destination rectangle and thus you can scale the page as needed.

    Use the XPdfForm class to access the existing PDF file.

    See the Two Pages on One sample for details:
    http://www.pdfsharp.net/wiki/TwoPagesOnOne-sample.ashx