Change PDF Page Size with C#
Contents
[
Hide
]
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:
- Load the source PDF file.
- Get the pages into the PageCollection object.
- Get a given page.
- Call the SetPageSize(..) method to update its dimensions.
- Call the Document class’ Save(..) method to generate the PDF file with updated page dimensions.
Please note that the height and width properties use points as basic unit, where 1 inch = 72 points and 1 cm = 1/2.54 inch = 0.3937 inch = 28.3 points.
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#.