How to Access All PDF DOM Objects in C#
To access PDF DOM objects in C#, use IronPDF's ObjectModel property which provides programmatic access to text, images, and path objects within PDF documents, allowing you to read, modify, translate, scale, and remove elements directly.
Quickstart: Access and Update PDF DOM Elements with IronPDF
Start manipulating PDF documents using IronPDF's DOM access features. This guide shows how to access the PDF DOM, select a page, and modify text objects. Load your PDF, access the desired page, and update content with a few lines of code.
Get started making PDFs with NuGet now:
Install IronPDF with NuGet Package Manager
Copy and run this code snippet.
var objs = IronPdf.ChromePdfRenderer.RenderUrlAsPdf("https://example.com").Pages.First().ObjectModel;Deploy to test on your live environment
Minimal Workflow (5 steps)
- Download the C# library to access PDF DOM Objects
- Import or render the targeted PDF document
- Access the PDF's pages collection and select the desired page
- Use the ObjectModel property to view and interact with the DOM objects
- Save or export the modified PDF document
How Do I Access DOM Objects in PDFs?
The ObjectModel is accessed from the PdfPage object. First, import the target PDF and access its Pages property. From there, select any page to access the ObjectModel property. This enables interaction with PDF content programmatically, similar to working with HTML DOM elements.
When working with PDF DOM objects, you access the underlying structure of the PDF document. This includes text elements, images, vector graphics (paths), and other content that makes up the visual representation of your PDF. IronPDF provides an object-oriented approach to PDF manipulation that integrates with C# applications.
:path=/static-assets/pdf/content-code-examples/how-to/access-pdf-dom-object.csusing IronPdf;
using System.Linq;
// Instantiate Renderer
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Create a PDF from a URL
PdfDocument pdf = renderer.RenderUrlAsPdf("https://ironpdf.com/");
// Access DOM Objects
var objects = pdf.Pages.First().ObjectModel;
The ObjectModel property contains ImageObject, PathObject, and TextObject. Each object contains information about its page index, bounding box, scale, and translation. This information can be modified. For rendering options, you can customize how these objects display. When working with custom margins, understanding object positioning is important.

## How Can I Translate PDF Objects? Adjust PDF layout by repositioning elements like text or images. Move objects by changing their `Translate` property. This functionality is part of IronPDF's [PDF transformation capabilities](https://ironpdf.com/how-to/transform-pdf-pages/). The example below renders HTML using CSS Flexbox to center text. It accesses the first `TextObject` and translates it by assigning a new `PointF` to the `Translate` property. This shifts the text 200 points right and 150 points up. For more examples, visit the [translate PDF objects example page](https://ironpdf.com/examples/translate-pdf-objects/). ### What Code Do I Use to Translate Objects? ```csharp :path=/static-assets/pdf/content-code-examples/how-to/access-pdf-dom-object-translate.cs ``` ### What Does the Translation Result Look Like? The output shows "Centered" shifted 200 points right and 150 points up from its original position.

## How Do I Scale PDF Objects? Resize PDF objects using the `Scale` property. This property acts as a multiplier. Values greater than 1 increase size, while values between 0 and 1 decrease it. Scaling is essential for dynamic layouts and adjusting content to fit page dimensions. See the [scale PDF objects guide](https://ironpdf.com/examples/scale-pdf-objects/) for more examples. The example renders HTML containing an image. It accesses the first `ImageObject` and scales it to 70% by assigning `Scale` a new `PointF` with 0.7 for both axes. ### What's the Code for Scaling PDF Objects? ```csharp :path=/static-assets/pdf/content-code-examples/how-to/access-pdf-dom-object-scale.cs ``` Apply different scaling factors to X and Y axes independently for non-uniform scaling. This is useful for fitting content into specific dimensions. When working with [custom paper sizes](https://ironpdf.com/how-to/custom-paper-size/), scaling helps ensure content fits within page boundaries. ### What Does Scaling Look Like in Practice? The output shows the image scaled to 70% of its original size.

## How Can I Remove PDF Objects? Remove objects by accessing the PDF DOM collection like `ImageObjects` or `TextObjects`. Call `RemoveAt` on the collection, passing the index of the object to delete. This is useful for redacting content or simplifying documents. Learn more at the [remove PDF objects example](https://ironpdf.com/examples/remove-pdf-objects/). The code loads BeforeScale.pdf and removes the first image from the first page. ### What Code Should I Use to Remove Objects? ```csharp :path=/static-assets/pdf/content-code-examples/how-to/access-pdf-dom-object-remove.cs ``` ### What Happens When I Remove Multiple Objects? Indices of remaining objects shift after removal. When removing multiple objects, remove them in reverse order to maintain correct indices. This technique helps when you [redact text](https://ironpdf.com/how-to/redact-text/) from sensitive documents. ## How Do I Combine Multiple DOM Operations? IronPDF's DOM access enables sophisticated document processing workflows. Combine operations for complex transformations: ### When Should I Use Combined Operations? ```csharp // Example of combining multiple DOM operations using IronPdf; using System.Drawing; using System.Linq; PdfDocument pdf = PdfDocument.FromFile("complex-document.pdf"); // Iterate through all pages foreach (var page in pdf.Pages) { var objects = page.ObjectModel; // Process text objects foreach (var textObj in objects.TextObjects) { // Change color of specific text if (textObj.Contents.Contains("Important")) { textObj.Color = Color.Red; } } // Scale down all images by 50% foreach (var imgObj in objects.ImageObjects) { imgObj.Scale = new PointF(0.5f, 0.5f); } } pdf.SaveAs("processed-document.pdf"); ``` ### What Are Common Use Cases for Combined Operations? Combined DOM operations work well for: 1. **Batch Document Processing**: Process documents to standardize formatting or remove sensitive content 2. **Dynamic Report Generation**: Modify template PDFs with real-time data while controlling layout 3. **Content Migration**: Extract and reorganize content from PDFs into new layouts 4. **Accessibility Improvements**: Enhance documents by modifying text size, contrast, or spacing These techniques enable powerful PDF processing applications that handle complex modifications. For managing document properties, see the [metadata management guide](https://ironpdf.com/how-to/metadata/). ## How Does DOM Access Compare to Other PDF Manipulation Methods? Working with PDF DOM provides advantages over traditional approaches: ```csharp // Example: Selective content modification based on criteria using IronPdf; using System.Drawing; using System.Linq; PdfDocument report = PdfDocument.FromFile("quarterly-report.pdf"); foreach (var page in report.Pages) { var textObjects = page.ObjectModel.TextObjects; // Highlight negative values in financial reports foreach (var text in textObjects) { if (text.Contents.StartsWith("-$") || text.Contents.Contains("Loss")) { text.Color = Color.Red; } } } report.SaveAs("highlighted-report.pdf"); ``` This granular control isn't possible with [HTML to PDF conversion](https://ironpdf.com/how-to/html-to-pdf-responsive-css/) alone, making DOM access essential for sophisticated PDF processing. Ready to see what else you can do? Check out the tutorial page here: [Edit PDFs](https://ironpdf.com/tutorials/csharp-edit-pdf-complete-tutorial/)
Frequently Asked Questions
What is the ObjectModel property used for in PDF manipulation?
The ObjectModel property in IronPDF provides programmatic access to text, images, and path objects within PDF documents. It allows developers to read, modify, translate, scale, and remove elements directly from the PDF DOM, similar to working with HTML DOM elements.
How do I access PDF DOM objects in C#?
To access PDF DOM objects using IronPDF, first import your target PDF document, then access its Pages property. From there, select any page and use the ObjectModel property. For example: var objs = IronPdf.ChromePdfRenderer.RenderUrlAsPdf("https://example.com").Pages.First().ObjectModel;
What types of objects can I access through the PDF DOM?
IronPDF's ObjectModel contains three main object types: ImageObject (with properties like Height, Width, and ExportBytesAsJpg), PathObject (with FillColor, StrokeColor, and Points), and TextObject (with Color and Contents properties). Each provides methods tailored to their specific content type.
Can I modify text content within a PDF document programmatically?
Yes, IronPDF allows you to modify text content through the TextObject's Contents property. You can access text objects via the ObjectModel, update their content, and save the modified PDF document with just a few lines of code.
How can I export images from PDF documents?
IronPDF's ImageObject provides the ExportBytesAsJpg method, which allows you to export images as JPG byte arrays. Access the image through the ObjectModel property and use this method to extract image data programmatically.
What information is available about each DOM object's position?
Each object in IronPDF's ObjectModel contains information about its page index, bounding box coordinates, scale, and translation. This positioning data can be both read and modified to reposition or transform elements within the PDF.






