Change PDF Page Size with C#

Change PDF Page Size

Aspose.PDF for .NET lets you change PDF page size with simple lines of code in your .NET applications. This topic explains how to update/change the page dimensions (size) of an existing PDF file.

The following code snippet also work with Aspose.PDF.Drawing library.

The Page class contains the SetPageSize(…) method which lets you set the page size. The code snippet below updates page dimensions in a few easy steps:

  1. Load the source PDF file.
  2. Get the pages into the PageCollection object.
  3. Get a given page.
  4. Call the SetPageSize(..) method to update its dimensions.
  5. Call the Document class’ Save(..) method to generate the PDF file with updated page dimensions.

The following code snippet shows how to change the PDF page dimensions to A4 size.

Get PDF Page Size

You can read PDF page size of an existing PDF file using Aspose.PDF for .NET. The following code sample shows how to read PDF page dimensions using C#.