How to Crop, Rotate, and Resize PDFs in .NET

How to Crop, Rotate, and Resize PDFs in .NET

Automating PDF page manipulation is essential for design, prepress, and digital archiving. With Aspose.PDF.Plugin for .NET, you can crop margins, rotate orientation, or resize page dimensions in bulk—perfect for large document batches or custom layout requirements.


Cropping PDF Pages (Margins, Bleeds, Custom Sizes)

Cropping trims unwanted whitespace, sets print bleeds, or focuses on specific page content.

using Aspose.Pdf.Plugins;

string input = @"C:\Docs\source.pdf";
string output = @"C:\Docs\cropped.pdf";

var optimizer = new Optimizer();
var cropOptions = new CropOptions()
{
    // Crop rectangle (left, top, width, height) in user units
    CropBox = new Rectangle(50, 50, 500, 700),
    Pages = new[] { 1, 2 } // Crop only pages 1 and 2
};
cropOptions.AddInput(new FileDataSource(input));
cropOptions.AddOutput(new FileDataSource(output));

optimizer.Process(cropOptions);

Rotating PDF Pages (Portrait/Landscape/Custom)

Change page orientation for readability or production needs:

var rotateOptions = new RotateOptions()
{
    Rotation = Rotation.on90, // or .on180, .on270
    Pages = new[] { 2, 4, 6 } // Rotate only even pages
};
rotateOptions.AddInput(new FileDataSource(input));
rotateOptions.AddOutput(new FileDataSource(@"C:\Docs\rotated.pdf"));

optimizer.Process(rotateOptions);

Resizing PDF Pages (Page Size, Scaling)

Adjust all or selected pages to Letter, A4, or custom dimensions:

var resizeOptions = new ResizeOptions()
{
    PageSize = PageSize.PageA4,
    Pages = new[] { 1, 3, 5 } // Resize odd pages
};
resizeOptions.AddInput(new FileDataSource(input));
resizeOptions.AddOutput(new FileDataSource(@"C:\Docs\resized.pdf"));

optimizer.Process(resizeOptions);

Use Cases

  • Crop scanned documents to remove artifacts/borders before OCR or archiving
  • Rotate landscape pages for printing or digital viewing
  • Resize legal, tabloid, or mixed-size documents to standard formats for compliance

Frequently Asked Questions

Q: Can I crop, rotate, or resize only specific pages? A: Yes—specify the Pages property in your options array. Each operation supports per-page selection.

Q: How do I reset a page’s orientation or size? A: Use RotateOptions with .on0 for portrait reset, or ResizeOptions with the desired standard size.

Q: Are changes permanent? A: Yes—output PDFs are saved with changes. Always backup originals if you may need to revert.


Pro Tip: Combine multiple operations in sequence—crop, then resize, then rotate—for complete layout automation. Log changes for compliance in regulated environments.

 English