
The PDF’s page size determines how its content appears, prints, or processes. We commonly require changing PDF page sizes while preparing for print, converting formats, or standardizing layouts. In this article, you will learn how to change PDF page size of any PDF file in C#. We will walk you through a step-by-step guide with complete code examples.
This article covers the following:
- C# API to change PDF page size
- Resize PDF using built-in standard page sizes like A3, A4, and Letter
- Change PDF page size to custom dimensions
- Resize PDF online
- Explore free resources
C# API to Change PDF Page Size
We will use Aspose.PDF for .NET to change PDF page size in C#. It enables the developers to create, edit, and convert PDF files without needing Adobe Acrobat. The API is easy to integrate, simple to use, works quickly, and helps you change pages or make new PDF files.
To begin, use the NuGet Package Manager to install the Aspose.PDF library:
PM> Install-Package Aspose.PDF
You may also download it from the releases.
After the installation is done, all you have to do is add the right namespaces to your project. You can now use C# to open, edit, and save PDF files.
You will learn how to change the page size of your PDF files using this API in C# with just a few lines of code in the next sections.
Change PDF Page Size using C#
To resize a PDF using the Resize method in Aspose.PDF for .NET, follow these steps:
- Load an existing PDF file using the
Document
class. - Loop through pages and apply
PageSize
enum value using theResize()
method. - Save the changes using the
Save()
method.
The following C# code shows how to resize PDF using built-in standard page sizes like A3, A4, and Letter:
How it Works:
- PageSize.A3: A built-in enumeration that represents standard A3 dimensions (841 x 1190 points).
- Resize(PageSize): A convenient method that resizes each page to the specified standard format.
This approach is best suited when you want to apply a standard print size to your documents quickly and consistently.
Change PDF Page Size with Custom Width and Height
Follow these steps to set exact dimensions for your PDF pages in C# using Aspose.PDF for .NET:
- Load an existing PDF using the
Document
class. - Define the new page dimensions.
- Loop through all the pages and apply the new size using the
SetPageSize()
method. - Save the modified PDF using the
Save()
method.
Please find below a C# code to change PDF page size to custom dimensions:
How it Works:
- Document class: Represents the entire PDF file and allows access to its content.
- Page class: Represents a single page within the document.
- SetPageSize(double width, double height): Method used to set the size of a page in points.
This approach gives you full control over each page’s dimensions, making it ideal for custom formats or layout corrections.
Get a Free License
You can explore the complete feature set of Aspose.PDF with a free temporary license. No restrictions, no upfront cost. It is an ideal way to test full functionality in your project before making a purchase decision.
Resize PDF Online
Try resizing PDFs online using the Aspose PDF Resize Tool. It is free, easy to use, and lets you adjust page sizes quickly and accurately.

Resize PDF – Free Resources
Explore more tools and documentation to enhance your development:
Conclusion
In this blog post, we have experienced various methods to change PDF page size in C# using Aspose.PDF for .NET API. By following this guide, you can effectively change the page size of any PDF file.
If you have any questions or need more help, don’t hesitate to contact us at our free support forum.