Namespace IronPdf.Pages
Classes
LineTextObject
Represents a single line of text within a PDF page, combining multiple text chunks. Provides access to line content, bounding box, and positioning information.
Lines are derived from TextChunks by grouping text objects that appear on the same visual line based on their vertical position.
Example - Extract lines from a page:
var pdf = PdfDocument.FromFile("document.pdf");
var page = pdf.Pages[0] as PdfPage;
foreach (var line in page.Lines)
{
Console.WriteLine($"Line: {line.Contents}");
Console.WriteLine($"Position: ({line.BoundingBox.Left}, {line.BoundingBox.Top})");
}
PdfPage
Represents a single page within a PDF document with access to dimensions, content, and manipulation methods. Provides properties for width, height, rotation, text extraction, and page transformation.
Access pages via Pages collection. Each page provides access to text content, dimensions, and methods for resizing and transforming content.
Example - Work with PDF pages:
var pdf = PdfDocument.FromFile("document.pdf");
// Access page properties:
var page = pdf.Pages[0] as PdfPage;
Console.WriteLine($"Size: {page.Width}mm x {page.Height}mm");
Console.WriteLine($"Rotation: {page.PageRotation}");
Console.WriteLine($"Text: {page.Text}");
// Resize page:
page.Resize(210, 297); // A4 size in mm
// Extend page margins:
page.Extend(10, 10, 20, 20); // Add margins (left, right, top, bottom)
// Transform content:
page.Transform(5, -5, 1.0, 1.0); // Move content 5mm right, 5mm down
PdfPageModel
Represents the document object model (DOM) for a single PDF page. Provides access to text, image, and path objects for content analysis and extraction.
This class exposes the internal structure of a PDF page, allowing programmatic access to individual content elements. Use for content extraction, analysis, or understanding page composition.
Example - Analyze page content:
var pdf = PdfDocument.FromFile("document.pdf");
var pageModel = pdf.Pages[0].GetPageModel();
// Count content elements:
Console.WriteLine($"Images: {pageModel.ImageObjects.Count}");
Console.WriteLine($"Text blocks: {pageModel.TextObjects.Count}");
Console.WriteLine($"Paths/shapes: {pageModel.PathObjects.Count}");
// Get page dimensions:
var bounds = pageModel.BoundingBox;
Console.WriteLine($"Page size: {bounds.Width} x {bounds.Height} points");
// Export to JSON:
string json = pageModel.ToJson();
PdfPagesCollection
Manages the collection of pages within a PDF document. Supports iteration, addition, removal, and direct access to individual pages.
Access this collection via Pages property. The collection provides full control over document structure including page manipulation.
Example - Work with pages:
var pdf = PdfDocument.FromFile("document.pdf");
// Iterate pages:
foreach (var page in pdf.Pages)
Console.WriteLine($"Page {page.PageIndex}: {page.Width}x{page.Height}");
// Access specific page:
var firstPage = pdf.Pages[0];
var lastPage = pdf.Pages[pdf.PageCount - 1];
// Remove page:
pdf.Pages.RemoveAt(2); // Remove page 3
// Get page count:
int totalPages = pdf.Pages.Count;
Interfaces
IPdfPage
PDF document page interface
IPdfPageCollection
Collection of PDF pages