Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aspose-com-gists/7f58679a1a4689b48926900fad37fd91 to your computer and use it in GitHub Desktop.
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
// 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");
// 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