| name | pdfium-syntax-page-objects |
| description | Use when reading or inspecting the content objects on a PDF page with pdfium-render: counting them, iterating them, telling text from images from paths, reading an object's bounding box, or reaching objects nested inside an XObject form. Prevents the inspection mistakes: reading bounds() as a PdfRect after the 0.8.28 type change, indexing objects with the wrong integer type, missing objects nested inside XObject form containers, and unwrapping a narrowing call that returned None. Covers PdfPage::objects, the PdfPageObjects collection, the six-variant PdfPageObject enum, the as_text_object family of narrowing methods, the PdfPageObjectCommon trait, and recursing into PdfPageXObjectFormObject. This skill is read and inspect only; creating and editing objects is a separate skill. Keywords: pdfium-render, page objects, PdfPageObject, PdfPageObjects, objects, iter, as_text_object, as_image_object, as_path_object, bounds, PdfQuadPoints, XObjectForm, nested objects, object type, PdfPageObjectCommon, has_transparency, "what is on this page", "find images in a PDF", "iterate page objects", "text vs image object", "object bounding box", "missing nested objects", "expected PdfRect found PdfQuadPoints", "how do I inspect PDF content".
|
| license | MIT |
| compatibility | Designed for Claude Code. Requires pdfium-render 0.8,0.9. |
| metadata | {"author":"OpenAEC-Foundation","version":"1.0"} |
pdfium-render Page Objects (Read and Inspect)
A PDF page's visible content is a flat list of page objects: text runs,
vector paths, images, shadings, and XObject form containers. This skill
covers reading and inspecting that list: reaching it, iterating it,
discriminating object types, reading object geometry, and recursing into
nested containers.
This skill is read and inspect only. Creating, transforming, and deleting
page objects is the scope of pdfium-impl-page-objects-edit.
Quick Reference: Object Access Flow
PdfPage
.objects() -> &PdfPageObjects immutable collection (inspect)
PdfPageObjects (methods from the PdfPageObjectsCommon trait)
.len() -> usize
.is_empty() -> bool
.get(index) -> Result<PdfPageObject, PdfiumError> index is usize
.first() -> Result<PdfPageObject, PdfiumError>
.last() -> Result<PdfPageObject, PdfiumError>
.iter() -> PdfPageObjectsIterator yields PdfPageObject
PdfPageObject (enum, six variants)
match it, or narrow with .as_text_object() etc.
PdfPageObjectCommon (trait on every object)
.bounds() -> Result<PdfQuadPoints, PdfiumError>
.width() .height() -> Result<PdfPoints, PdfiumError>
.has_transparency() -> bool
.is_inside_rect(&r) / .does_overlap_rect(&r) -> bool
ALWAYS reach page objects through PdfPage::objects(). NEVER assume a page
object can be inspected standalone; it borrows from its PdfPage.
1. Reaching the Object Collection
PdfPage::objects() returns &PdfPageObjects<'a>, the immutable collection
of every content object on the page.
pub fn objects(&self) -> &PdfPageObjects<'a>
For mutation (adding, transforming, removing objects) the page exposes
objects_mut(); that path is documented in pdfium-impl-page-objects-edit.
This skill uses only the immutable objects().
PdfPageObjects gets its methods from the PdfPageObjectsCommon trait:
fn len(&self) -> usize
fn is_empty(&)
(&, index: ) <PdfPageObject<>, PdfiumError>
(&) <PdfPageObject<>, PdfiumError>
(&) <PdfPageObject<>, PdfiumError>
(&) PdfPageObjectsIterator<>