Transforming PDF pages means scaling, moving, rotating, or resizing content after the PDF exists. Maybe you need to shrink content to add a margin, rotate scanned documents, or extend pages for annotations.
using IronPdf;
// Install via NuGet: Install-Package IronPdf
var pdf = PdfDocument.FromFile("document.pdf");
// Scale content to 80% and shift it 50 points right and down
pdf.Pages[0].Transform(50, 50, 0.8, 0.8);
pdf.SaveAs("transformed.pdf");
The Transform method repositions and scales page content without changing physical page dimensions.
What Can I Transform?
| Operation | What It Does | Method |
|---|---|---|
| Scale | Resize content (shrink/enlarge) | Transform() |
| Translate | Move content on page | Transform() |
| Rotate | Turn pages 90°, 180°, 270° | SetPageRotation() |
| Extend | Add space to page edges | ExtendPage() |
| Resize | Change page dimensions | SetCustomPaperSize() |
Each affects the PDF differently. Let's explore each one.
How Do I Scale Page Content?
Shrink or enlarge content while keeping page size:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
var pdf = PdfDocument.FromFile("full-size.pdf");
// Scale to 50% (half size)
foreach (var page in pdf.Pages)
{
page.Transform(0, 0, 0.5, 0.5);
}
pdf.SaveAs("half-size-content.pdf");
The page stays the same size, but content becomes smaller. Useful for creating margins or fitting oversized content.
How Do I Move Content on a Page?
Translate (shift) content position:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
var pdf = PdfDocument.FromFile("document.pdf");
// Move content 72 points (1 inch) right and down
pdf.Pages[0].Transform(72, 72, 1.0, 1.0);
pdf.SaveAs("shifted.pdf");
Values are in points (72 points = 1 inch). Scale of 1.0 means no size change.
Combine translation with scaling:
// Shrink to 75% and center on page
double scale = 0.75;
double offsetX = 50; // points from left
double offsetY = 50; // points from top
pdf.Pages[0].Transform(offsetX, offsetY, scale, scale);
How Do I Rotate PDF Pages?
Rotate existing pages:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
var pdf = PdfDocument.FromFile("scanned-document.pdf");
// Rotate all pages 90 degrees clockwise
pdf.SetAllPageRotations(PdfPageRotation.Clockwise90);
pdf.SaveAs("rotated.pdf");
Rotation options:
-
PdfPageRotation.None— 0° (original) -
PdfPageRotation.Clockwise90— 90° -
PdfPageRotation.Clockwise180— 180° -
PdfPageRotation.Clockwise270— 270°
Rotate specific pages:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
var pdf = PdfDocument.FromFile("mixed-orientations.pdf");
// Rotate only the first page
pdf.SetPageRotation(0, PdfPageRotation.Clockwise90);
// Rotate pages 2, 3, 4 (indices 1, 2, 3)
pdf.SetPageRotations(new[] { 1, 2, 3 }, PdfPageRotation.Clockwise180);
pdf.SaveAs("selectively-rotated.pdf");
How Do I Extend Page Dimensions?
Add space to page edges:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
var pdf = PdfDocument.FromFile("document.pdf");
// Add 50 points to each edge
pdf.Pages[0].ExtendPage(
left: 50,
right: 50,
top: 50,
bottom: 50,
MeasurementUnit.Points);
pdf.SaveAs("extended.pdf");
Content stays in original position, but page gets larger. Useful for:
- Adding annotation margins
- Creating binding gutters
- Making room for stamps/signatures
How Do I Resize Pages?
Change the actual page dimensions:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
var renderer = new [ChromePdfRenderer](https://ironpdf.com/blog/videos/how-to-render-webgl-sites-to-pdf-in-csharp-ironpdf/)();
// Set custom paper size before rendering
renderer.RenderingOptions.SetCustomPaperSizeInMillimeters(150, 200);
var pdf = renderer.RenderHtmlAsPdf("<h1>Custom Size</h1>");
pdf.SaveAs("custom-size.pdf");
For existing PDFs, combine extend with transform:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
var pdf = PdfDocument.FromFile("letter-size.pdf");
// Extend to A4 dimensions
// Letter: 612 x 792 points
// A4: 595 x 842 points
// Difference: need to extend height by 50 points
pdf.Pages[0].ExtendPage(0, 0, 0, 50, MeasurementUnit.Points);
pdf.SaveAs("extended-to-a4.pdf");
How Do I Scale for Printing?
Fit content to specific paper sizes:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
var pdf = PdfDocument.FromFile("oversized-document.pdf");
// Original page is too large for Letter paper
// Scale down to fit with margins
foreach (var page in pdf.Pages)
{
// Scale to 90% and add 36-point margins (0.5 inch)
page.Transform(36, 36, 0.9, 0.9);
}
pdf.SaveAs("print-ready.pdf");
Scaling ensures content fits on standard paper when printed.
How Do I Create N-Up Layouts?
Multiple pages per sheet (2-up, 4-up):
using IronPdf;
// Install via NuGet: Install-Package IronPdf
public PdfDocument CreateTwoUp(string inputPath)
{
var source = PdfDocument.FromFile(inputPath);
// Scale each page to fit half a page
foreach (var page in source.Pages)
{
page.Transform(0, 0, 0.5, 0.5);
}
// Combine pairs onto single pages
// (This is a simplified example - full implementation
// requires merging and positioning)
return source;
}
N-up layouts save paper by putting multiple source pages on each printed page.
How Do I Transform Specific Pages?
Apply different transforms to different pages:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
var pdf = PdfDocument.FromFile("mixed-document.pdf");
// First page: title page, no transform
// Pages 2-10: content, scale down
for (int i = 1; i < Math.Min(10, pdf.PageCount); i++)
{
pdf.Pages[i].Transform(20, 20, 0.85, 0.85);
}
// Last page: appendix, rotate
if (pdf.PageCount > 10)
{
pdf.SetPageRotation(pdf.PageCount - 1, PdfPageRotation.Clockwise90);
}
pdf.SaveAs("transformed-sections.pdf");
Different sections may need different treatments.
How Do I Fix Scanned Documents?
Common fixes for scanned PDFs:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
public void FixScannedDocument(string inputPath, string outputPath)
{
var pdf = PdfDocument.FromFile(inputPath);
foreach (var page in pdf.Pages)
{
// Correct rotation (common scan issue)
// Check if page is landscape but should be portrait
// This is a simplified example - real detection is more complex
// Add margins for hole-punch
page.ExtendPage(25, 0, 0, 0, MeasurementUnit.Millimeters);
// Scale slightly to ensure content doesn't clip
page.Transform(5, 5, 0.95, 0.95);
}
pdf.SaveAs(outputPath);
}
Scanned documents often need rotation correction and margin adjustment.
How Do I Preserve Quality During Transforms?
Transforms are non-destructive to vector content:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
var pdf = PdfDocument.FromFile("vector-graphics.pdf");
// Vector content (text, lines, shapes) stays crisp
pdf.Pages[0].Transform(0, 0, 2.0, 2.0); // Scale UP to 200%
// Images may become pixelated when scaled up
// Scale down is generally safe
pdf.SaveAs("scaled-up.pdf");
Vector content (text, paths) scales perfectly. Raster images (photos) can degrade.
How Do I Batch Transform Documents?
Process multiple files:
using IronPdf;
// Install via NuGet: Install-Package IronPdf
public void BatchTransform(string inputFolder, string outputFolder)
{
var files = Directory.GetFiles(inputFolder, "*.pdf");
foreach (var file in files)
{
var pdf = PdfDocument.FromFile(file);
// Apply standard transform
foreach (var page in pdf.Pages)
{
page.Transform(25, 25, 0.9, 0.9);
}
var outputPath = Path.Combine(outputFolder, Path.GetFileName(file));
pdf.SaveAs(outputPath);
pdf.Dispose();
Console.WriteLine($"Transformed: {Path.GetFileName(file)}");
}
}
Mass transformation for document standardization.
Quick Reference
| Operation | Code |
|---|---|
| Scale | page.Transform(0, 0, 0.8, 0.8) |
| Move | page.Transform(50, 50, 1.0, 1.0) |
| Scale + Move | page.Transform(50, 50, 0.8, 0.8) |
| Rotate all | pdf.SetAllPageRotations(PdfPageRotation.Clockwise90) |
| Rotate one | pdf.SetPageRotation(0, rotation) |
| Extend page | page.ExtendPage(left, right, top, bottom, unit) |
Unit reminder: 72 points = 1 inch = 25.4 mm
Page transforms give you control over content positioning and sizing after PDF creation. Scale, move, rotate, and extend as needed.
For more transformation options, see the IronPDF page transform documentation.
Written by Jacob Mellor, CTO at Iron Software. Jacob created IronPDF and leads a team of 50+ engineers building .NET document processing libraries.
Top comments (0)