Resize PDF via C#

Change PDF Page Size. Use Aspose.PDF for .NET to modify PDF documents programmatically

Resize PDF Pages with C#

Do you need to resize PDF? Programmatic modification of PDF documents is an essential part of modern digital workflows. .NET libraries like Aspose.PDF – are stand-alone solutions that don’t rely on other software and are ready for commercial use. They cover all possible needs of professional C# developers.

This C# library enables developers to resize PDF documents quickly and efficiently through programming. This library shows you how easily to update or change the page dimensions in an existing PDF file programmatically with C#. It is a standalone solution for processing PDF documents in C# that does not require the installation of any third-party software.

In order to resize PDF page, we’ll use Aspose.PDF for .NET API which is a feature-rich, powerful and easy-to-use document manipulation API for .NET platform. Open NuGet package manager, search for Aspose.PDF and install. You may also use the following command from the Package Manager Console.

Package Manager Console

PM > Install-Package Aspose.PDF

How to Resize PDF documents


You need Aspose.PDF for .NET to try the code in your environment.

  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.

If you want to resize PDF files for your tasks, this solution can help. With this powerful Aspose.PDF .NET library, you can update or change the page dimensions (size) of an existing files. This professional tool uses C# to resize PDF effectively. The following example demonstrates how to change size of PDF document in C#:

Resize PDF - C#

This sample code shows how to Resize PDF Pages - C#


    // Open document
    Document pdfDocument = new Document(dataDir + "UpdateDimensions.pdf");

    // Get page collection
    PageCollection pageCollection = pdfDocument.Pages;

    // Get particular page
    Page pdfPage = pageCollection[1];

    // Set the page size as A4 (11.7 x 8.3 in) and in Aspose.Pdf, 1 inch = 72 points
    // So A4 dimensions in points will be (842.4, 597.6)
    pdfPage.SetPageSize(597.6, 842.4);

    dataDir = dataDir + "UpdateDimensions_out.pdf";
    // Save the updated document
    pdfDocument.Save(dataDir);

About Aspose.PDF for C# API

Aspose.PDF for C# API provides a wide range of features for working with PDF files. Some of the features include:

  • Create PDF documents from scratch or from HTML, XML, or images.
  • Compress existing PDF documents by adding or removing pages, text, images, and other content.
  • Convert PDF documents to other formats such as HTML, XML, and images.
  • Render PDF documents to images or XPS format.
  • Print PDF documents directly from your application.
  • Digitally sign PDF documents.

You can find more information on Aspose.PDF for C# API in this Aspose documentation