Learn how to Change PDF Page Size in C# Using Aspose.PDF for .NET
Created
May 30, 2025 10:01
-
-
Save aspose-com-gists/7f58679a1a4689b48926900fad37fd91 to your computer and use it in GitHub Desktop.
Change PDF Page Size in C# Using Aspose.PDF for .NET
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Step 1: Import Aspose.PDF | |
using Aspose.Pdf; | |
// Step 2: Load the PDF document | |
Document document = new Document("input.pdf"); | |
// Step 3: Resize pages to A3 using PageSize enum | |
foreach (Page page in document.Pages) | |
{ | |
page.Resize(PageSize.A3); | |
} | |
// Step 4: Save the output | |
document.Save("output_a3.pdf"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Step 1: Import the Aspose.PDF namespace | |
using Aspose.Pdf; | |
// Step 2: Load the PDF document | |
Document document = new Document("input.pdf"); | |
// Step 3: Define custom dimensions (e.g., Letter size) | |
double newWidth = 612; // 8.5 inches | |
double newHeight = 792; // 11 inches | |
// Step 4: Loop through each page and apply the new size | |
foreach (Page page in document.Pages) | |
{ | |
page.SetPageSize(newWidth, newHeight); | |
} | |
// Step 5: Save the resized document | |
document.Save("output_custom_size.pdf"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment