Skip to main content

Crate zpdf

Crate zpdf 

Source

Re-exports§

pub use zpdf_display_list as display_list;

Modules§

cpu
pdfa
PDF/A conformance validation (profiles A-1b and A-2b).
pdfua
PDF/UA-1 conformance validation (ISO 14289-1).
time
Wall-clock access that degrades gracefully on wasm32-unknown-unknown.
trust
X.509 certificate-chain verification for PDF signatures, against caller-provided trust anchors.

Structs§

AcroForm
The document’s interactive form.
Annotation
ByteRangeCoverage
How a signature’s /ByteRange covers the file.
ContentInterpreter
Interprets a PDF content stream and produces a DisplayList.
ConversionOptions
Options for convert_pdf.
ConvertedDocument
Structured output from convert_pdf, ready for a TXT, Markdown, or custom serializer.
ConvertedImage
A unique decoded page image and every place it is drawn on that page.
ConvertedPage
Extracted content and metadata for one PDF page.
DecodedImage
Destination
A resolved destination: where in the document to go, and how to view it.
DisplayList
DocInfo
Metadata from the document information dictionary. Every field is optional — producers populate an arbitrary subset.
EmbeddedFile
One embedded or associated file: the file-specification metadata plus the object id of its embedded-file stream (when it carries one). The payload is not decoded here — fetch it with crate::PdfDocument::embedded_file_bytes.
FontCache
Page/display-list font store keyed by FontId.
FormField
A terminal interactive-form field.
FormFiller
A form-filling session. Call FormFiller::set for each field to fill, then FormFiller::finish to flush the /NeedAppearances flag if needed.
GeographicCoordinateSystem
Geographic coordinate system info (Table 262).
IccCache
Per-document cache of ICCBased profile streams → compiled transforms, keyed by the profile stream’s object id AND the rendering intent (the same profile may be requested under different intents on one page). Failures are cached as None so a malformed profile is parsed (and warned about) once.
IccTransform
A compiled ICC-profile → sRGB transform for 1/3/4-component input.
ImageCache
Display-list image store. Entries remain stable because render commands keep only an ImageId; callers bound memory by the store/document lifetime.
ImagePlacement
One occurrence of an extracted image in page user space.
IncrementalWriter
An incremental PDF writer. Accumulates new and modified objects and writes them as an incremental update appended to the original file.
InfoUpdate
A partial update of the /Info dictionary.
Matrix
3x2 affine transformation matrix.
Measure
A measure dictionary describing geospatial coordinate systems and units for an annotation (PDF §13.2, Table 261).
ObjectId
Indirect object identifier: (object number, generation number).
ObjectIdMap
Mapping from source-document object IDs to destination object IDs, built up while copying. Reusable across multiple copy_object_graph calls against the same (source, destination) pair so shared resources (fonts, images) are copied once.
OcConfig
The document’s default optional-content configuration (/OCProperties /D).
OutlineItem
One bookmark: a title, an optional navigation target, and nested children.
OutputIntent
One /OutputIntents entry.
PageLabels
The document’s page labels, parsed from /PageLabels. Built only when the document declares at least one well-formed labeling range.
ParseLimits
Security limits for PDF parsing. PDF is an untrusted input format.
PdfDict
PDF dictionary: ordered map of Name → PdfObject.
PdfDocument
PdfFile
PdfName
PDF Name object (e.g., /Type stored as "Type").
PdfPage
PdfStream
PDF stream object: dictionary + raw byte range (lazy decode).
PdfString
PDF string (literal or hexadecimal).
Point
Rect
PDF rectangle: [x0, y0, x1, y1] (lower-left, upper-right).
ResourceDict
RewriteOptions
Options for rewrite_pdf.
RuleLine
An axis-aligned ruled line captured from page content (a thin stroke or a thin filled rectangle), in PDF user space (y-up). Produced by running the interpreter with ContentInterpreter::with_rule_sink; consumed by detect_tables_with_rules as drawn table-grid evidence.
SearchHit
One search match on a page.
Signature
A digital signature attached to a /Sig form field.
SignatureOptions
Optional signature metadata written into the signature dictionary.
StructElem
One structure element (/Type /StructElem): a node of the logical tree.
StructTree
The document’s logical structure tree (/StructTreeRoot). Present only when the catalog declares one.
Table
A detected table: a grid of cell strings plus the column/row separator positions in PDF user space (y-up).
TextSpan
XmpMetadata
Common document metadata read from the XMP packet. Every field is optional; producers populate an arbitrary subset, and a field may be present in XMP but not in /Info (or vice-versa).

Enums§

AnnotationSpec
An annotation to author. Colors are DeviceRGB components in [0, 1].
ConversionMode
Content retained by convert_pdf.
CryptoStatus
Verdict of the public-key signature check over the CMS signed attributes.
DestView
How a destination positions and zooms the target page (ISO 32000-1 Table 151). Coordinates are in the page’s default user space; None for a coordinate means “retain the current value” (a null in the array).
DigestStatus
Verdict of the byte-range digest check.
EmbeddedSource
Where an EmbeddedFile was discovered.
Error
FieldKind
The four AcroForm field types (/FT), plus an Unknown catch-all.
FieldValue
A resolved field value (/V).
MarkupKind
The four text-markup annotation subtypes.
PageLabelStyle
The numbering style of a label’s numeric portion (ISO 32000-1 Table 159).
PdfObject
All PDF object types.
RevocationStatus
Offline certificate-revocation status, derived from CRLs embedded in the signature CMS or the document’s /DSS. OCSP/CRL fetching over the network is out of scope (the project has no network dependency); this checks only the revocation material already embedded in the file.
SigningKey
Signing key material. The certificate must carry the matching public key.
StampImage
Image data for stamping.
StampItem
A single stamped item: text or image.
StructKid
A kid of a structure element: a nested element, a marked-content sequence in a page’s content stream, or a whole referenced object (/OBJR).
StructRole
A standard structure type (ISO 32000-1 §14.8.4), the role of a structure element after resolving its /S through the document’s /RoleMap. A type outside the standard set (and not mapped onto it) is StructRole::Other.

Traits§

RenderBackend
Backend-agnostic render trait.

Functions§

cmyk_to_rgb_naive
Naïve subtractive CMYK → sRGB: r=(1−c)(1−k), g=(1−m)(1−k), b=(1−y)(1−k). The exact inverse of rgb_to_cmyk_naive. Inputs clamped to 0.0..=1.0.
convert_pdf
Extract selected pages from an already-open PDF.
copy_object_graph
Copy source_id and everything reachable from it out of source_file into writer, renumbering references. Returns the destination ID of the root. Objects already present in id_map are not copied again.
detect_tables
Detect tables among a page’s extracted text spans (in PDF user space, y-up). Returns one Table per detected grid, in top-to-bottom page order.
detect_tables_with_rules
detect_tables, additionally informed by drawn ruled lines (captured via ContentInterpreter::with_rule_sink). Vertical rules that span a band act as forced column separators — they establish columns even where the text alone leaves no clean whitespace gutter — and a band whose columns come from drawn rules skips the prose-fill guard (a drawn grid is stronger evidence than cell-width statistics). With no rules this is exactly detect_tables.
extract_pages
Extract the given 0-based pages of source into a fresh, self-contained PDF containing only those pages (and their transitively referenced objects). Pages appear in the order given.
output_intent_cmyk_profile
Compile the DeviceCMYK colour-management transform for a page’s active output intent, or None when none applies.
rewrite_pdf
Rewrite source as a fresh, garbage-collected PDF. See module docs.
rgb_to_cmyk_naive
Naïve sRGB → subtractive CMYK with maximum GCR (k = 1 − max(r,g,b)), the exact inverse of cmyk_to_rgb_naive. Pure black/white map to (0,0,0,1) / (0,0,0,0). Inputs clamped to 0.0..=1.0.
search_spans
Search one page’s spans for query. Returns hits in top-to-bottom, left-to-right order. Matches never cross line boundaries; whitespace in the query matches both real spaces and inter-span word gaps.
spans_to_text
Reconstruct plain text from extracted spans, recovering reading order.
struct_ordered_text
Extract a page’s text in the document’s logical reading order, driven by the Tagged-PDF structure tree (the order the producer intends, rather than the geometric XY-cut of spans_to_text).

Type Aliases§

Result