Rust API Reference
This page documents every public struct and method in pdf_oxide. For the Python bindings, see the Python API Reference. For type and enum details, see Types & Enums.
PdfDocument
The low-level document handle. Open a PDF file, extract text, images, and metadata.
use pdf_oxide::PdfDocument;
Opening and Authentication
| Method | Signature | Description |
|---|---|---|
open |
fn open(path: impl AsRef<Path>) -> Result<Self> |
Open a PDF file from disk |
open_from_bytes |
fn open_from_bytes(data: Vec<u8>) -> Result<Self> |
Open a PDF from in-memory bytes |
open_with_config |
fn open_with_config(path: impl AsRef<Path>, config: impl Any) -> Result<Self> |
Open with parser configuration |
authenticate |
fn authenticate(&mut self, password: &[u8]) -> Result<bool> |
Authenticate with user or owner password |
Metadata
| Method | Signature | Description |
|---|---|---|
page_count |
fn page_count(&mut self) -> Result<usize> |
Number of pages in the document |
page_count_u32 |
fn page_count_u32(&mut self) -> u32 |
Page count as u32 (0 on error) |
version |
fn version(&self) -> (u8, u8) |
PDF version as (major, minor) |
trailer |
fn trailer(&self) -> &Object |
Raw trailer dictionary |
catalog |
fn catalog(&mut self) -> Result<Object> |
Document catalog dictionary |
Text Extraction
| Method | Signature | Description |
|---|---|---|
extract_text |
fn extract_text(&mut self, page_index: usize) -> Result<String> |
Plain text from a single page |
extract_all_text |
fn extract_all_text(&mut self) -> Result<String> |
Plain text from all pages |
extract_spans |
fn extract_spans(&mut self, page_index: usize) -> Result<Vec<TextSpan>> |
Text runs with font metadata |
extract_spans_with_config |
fn extract_spans_with_config(&mut self, page_index: usize, config: &TextConfig) -> Result<Vec<TextSpan>> |
Spans with custom configuration |
extract_chars |
fn extract_chars(&mut self, page_index: usize) -> Result<Vec<TextChar>> |
Per-character positions and metadata |
extract_text_with_ocr |
fn extract_text_with_ocr(&mut self, page_index: usize) -> Result<String> |
Text with OCR fallback for scanned pages |
extract_spans_with_ocr |
fn extract_spans_with_ocr(&mut self, page_index: usize) -> Result<Vec<TextSpan>> |
Spans with OCR fallback |
apply_intelligent_text_processing |
fn apply_intelligent_text_processing(&self, spans: Vec<TextSpan>) -> Vec<TextSpan> |
Ligature expansion, hyphen reconstruction, OCR cleanup |
extract_hierarchical_content |
fn extract_hierarchical_content(&mut self, page_index: usize) -> Result<Vec<ContentElement>> |
Structured content tree from tagged PDFs |
Conversion
| Method | Signature | Description |
|---|---|---|
to_markdown |
fn to_markdown(&mut self, page_index: usize, options: &ConversionOptions) -> Result<String> |
Convert page to Markdown |
to_html |
fn to_html(&mut self, page_index: usize, options: &ConversionOptions) -> Result<String> |
Convert page to HTML |
to_plain_text |
fn to_plain_text(&mut self, page_index: usize) -> Result<String> |
Convert page to plain text |
to_markdown_all |
fn to_markdown_all(&mut self, options: &ConversionOptions) -> Result<String> |
All pages to Markdown |
to_html_all |
fn to_html_all(&mut self, options: &ConversionOptions) -> Result<String> |
All pages to HTML |
to_plain_text_all |
fn to_plain_text_all(&mut self) -> Result<String> |
All pages to plain text |
to_markdown_with_ocr |
fn to_markdown_with_ocr(&mut self, page_index: usize, options: &ConversionOptions) -> Result<String> |
Markdown with OCR fallback |
Image Extraction
| Method | Signature | Description |
|---|---|---|
extract_images |
fn extract_images(&mut self, page_index: usize) -> Result<Vec<ImageInfo>> |
Image metadata and raw data from a page |
extract_images_to_files |
fn extract_images_to_files(&mut self, page_index: usize, output_dir: &str) -> Result<Vec<PathBuf>> |
Extract and save images to disk |
Path and Graphics Extraction
| Method | Signature | Description |
|---|---|---|
extract_paths |
fn extract_paths(&mut self, page_index: usize) -> Result<Vec<PathContent>> |
Vector graphics from a page |
extract_paths_in_rect |
fn extract_paths_in_rect(&mut self, page_index: usize, rect: Rect) -> Result<Vec<PathContent>> |
Paths within a rectangular region |
Page Information
| Method | Signature | Description |
|---|---|---|
get_page_info |
fn get_page_info(&mut self, page_index: usize) -> Result<PageInfo> |
Page dimensions, rotation, boxes |
get_page_resources |
fn get_page_resources(&mut self, page_index: usize) -> Result<Object> |
Raw resources dictionary |
get_page_content_data |
fn get_page_content_data(&mut self, page_index: usize) -> Result<Vec<u8>> |
Raw content stream bytes |
Structure and Accessibility
| Method | Signature | Description |
|---|---|---|
structure_tree |
fn structure_tree(&mut self) -> Result<Option<StructTreeRoot>> |
Tagged structure tree |
mark_info |
fn mark_info(&mut self) -> Result<MarkInfo> |
MarkInfo dictionary (tagged, suspects) |
Low-Level
| Method | Signature | Description |
|---|---|---|
load_object |
fn load_object(&mut self, obj_ref: ObjectRef) -> Result<Object> |
Load a PDF object by reference |
resolve_object |
fn resolve_object(&mut self, obj: &Object) -> Result<Object> |
Resolve indirect references |
resolve_references |
fn resolve_references(&mut self, obj: &Object, max_depth: usize) -> Result<Object> |
Recursively resolve all references |
check_for_circular_references |
fn check_for_circular_references(&mut self) -> Vec<(ObjectRef, ObjectRef)> |
Detect circular reference chains |
The unified high-level API. One type for extraction, creation, editing, search, and compliance.
use pdf_oxide::api::Pdf;
Constructors
| Method | Signature | Description |
|---|---|---|
new |
fn new() -> Self |
Create an empty Pdf instance |
open |
fn open(path: impl AsRef<Path>) -> Result<Self> |
Open existing PDF for reading |
open_editor |
fn open_editor(path: impl AsRef<Path>) -> Result<DocumentEditor> |
Open for structural editing |
from_markdown |
fn from_markdown(content: &str) -> Result<Self> |
Create PDF from Markdown |
from_html |
fn from_html(content: &str) -> Result<Self> |
Create PDF from HTML |
from_text |
fn from_text(content: &str) -> Result<Self> |
Create PDF from plain text |
from_image |
fn from_image(path: impl AsRef<Path>) -> Result<Self> |
Create PDF from image file |
from_image_bytes |
fn from_image_bytes(data: &[u8]) -> Result<Self> |
Create PDF from image bytes |
from_images |
fn from_images<P: AsRef<Path>>(paths: &[P]) -> Result<Self> |
Multi-page from images |
from_qrcode |
fn from_qrcode(data: &str) -> Result<Self> |
PDF containing a QR code |
from_qrcode_with_options |
fn from_qrcode_with_options(data: &str, size: f32, ecl: &str) -> Result<Self> |
QR code with custom size and error correction |
from_barcode |
fn from_barcode(data: &str, barcode_type: BarcodeType) -> Result<Self> |
PDF containing a barcode |
from_barcode_with_options |
fn from_barcode_with_options(data: &str, barcode_type: BarcodeType, width: f32, height: f32) -> Result<Self> |
Barcode with custom dimensions |
Extraction
| Method | Signature | Description |
|---|---|---|
page_count |
fn page_count(&mut self) -> Result<usize> |
Number of pages |
page |
fn page(&mut self, index: usize) -> Result<PdfPage> |
DOM-like page handle |
to_markdown |
fn to_markdown(&mut self, page: usize) -> Result<String> |
Page to Markdown |
to_html |
fn to_html(&mut self, page: usize) -> Result<String> |
Page to HTML |
to_text |
fn to_text(&mut self, page: usize) -> Result<String> |
Page to plain text |
Search
| Method | Signature | Description |
|---|---|---|
search |
fn search(&mut self, pattern: &str) -> Result<Vec<SearchResult>> |
Search all pages |
search_with_options |
fn search_with_options(&mut self, pattern: &str, opts: &SearchOptions) -> Result<Vec<SearchResult>> |
Search with options |
search_page |
fn search_page(&mut self, page: usize, pattern: &str) -> Result<Vec<SearchResult>> |
Search single page |
highlight_matches |
fn highlight_matches(&mut self, pattern: &str) -> Result<usize> |
Add highlight annotations for matches |
Metadata
| Method | Signature | Description |
|---|---|---|
set_title |
fn set_title(&mut self, title: impl Into<String>) -> Result<()> |
Set document title |
set_author |
fn set_author(&mut self, author: impl Into<String>) -> Result<()> |
Set author |
set_subject |
fn set_subject(&mut self, subject: impl Into<String>) -> Result<()> |
Set subject |
set_keywords |
fn set_keywords(&mut self, keywords: impl Into<String>) -> Result<()> |
Set keywords |
XMP Metadata
| Method | Signature | Description |
|---|---|---|
xmp_metadata |
fn xmp_metadata(&mut self) -> Result<Option<XmpMetadata>> |
Full XMP metadata |
has_xmp_metadata |
fn has_xmp_metadata(&mut self) -> Result<bool> |
Check XMP presence |
xmp_title |
fn xmp_title(&mut self) -> Result<Option<String>> |
XMP dc:title |
xmp_creators |
fn xmp_creators(&mut self) -> Result<Vec<String>> |
XMP dc:creator list |
xmp_description |
fn xmp_description(&mut self) -> Result<Option<String>> |
XMP dc:description |
xmp_creator_tool |
fn xmp_creator_tool(&mut self) -> Result<Option<String>> |
XMP xmp:CreatorTool |
xmp_create_date |
fn xmp_create_date(&mut self) -> Result<Option<String>> |
XMP xmp:CreateDate |
xmp_modify_date |
fn xmp_modify_date(&mut self) -> Result<Option<String>> |
XMP xmp:ModifyDate |
xmp_producer |
fn xmp_producer(&mut self) -> Result<Option<String>> |
XMP pdf:Producer |
Page Labels
| Method | Signature | Description |
|---|---|---|
page_labels |
fn page_labels(&mut self) -> Result<Vec<PageLabelRange>> |
Page label ranges |
page_label |
fn page_label(&mut self, page: usize) -> Result<String> |
Label for a specific page |
all_page_labels |
fn all_page_labels(&mut self) -> Result<Vec<String>> |
Labels for every page |
Page Operations
| Method | Signature | Description |
|---|---|---|
page_rotation |
fn page_rotation(&mut self, page: usize) -> Result<i32> |
Current rotation in degrees |
set_page_rotation |
fn set_page_rotation(&mut self, page: usize, degrees: i32) -> Result<()> |
Set absolute rotation |
rotate_page |
fn rotate_page(&mut self, page: usize, degrees: i32) -> Result<()> |
Add relative rotation |
rotate_all_pages |
fn rotate_all_pages(&mut self, degrees: i32) -> Result<()> |
Rotate all pages |
page_media_box |
fn page_media_box(&mut self, page: usize) -> Result<[f32; 4]> |
MediaBox dimensions |
set_page_media_box |
fn set_page_media_box(&mut self, page: usize, rect: [f32; 4]) -> Result<()> |
Set MediaBox |
page_crop_box |
fn page_crop_box(&mut self, page: usize) -> Result<Option<[f32; 4]>> |
CropBox dimensions |
set_page_crop_box |
fn set_page_crop_box(&mut self, page: usize, rect: [f32; 4]) -> Result<()> |
Set CropBox |
crop_margins |
fn crop_margins(&mut self, left: f32, right: f32, top: f32, bottom: f32) -> Result<()> |
Crop all pages by margins |
Content Editing
| Method | Signature | Description |
|---|---|---|
save_page |
fn save_page(&mut self, page: PdfPage) -> Result<()> |
Save modified page back |
erase_region |
fn erase_region(&mut self, page: usize, rect: [f32; 4]) -> Result<()> |
White-out a rectangular area |
erase_regions |
fn erase_regions(&mut self, page: usize, rects: &[[f32; 4]]) -> Result<()> |
White-out multiple areas |
clear_erase_regions |
fn clear_erase_regions(&mut self, page: usize) |
Clear pending erase operations |
Annotations
| Method | Signature | Description |
|---|---|---|
flatten_page_annotations |
fn flatten_page_annotations(&mut self, page: usize) -> Result<()> |
Flatten annotations on a page |
flatten_all_annotations |
fn flatten_all_annotations(&mut self) -> Result<()> |
Flatten all annotations |
is_page_marked_for_flatten |
fn is_page_marked_for_flatten(&self, page: usize) -> bool |
Check flatten status |
unmark_page_for_flatten |
fn unmark_page_for_flatten(&mut self, page: usize) |
Unmark a page |
Forms
| Method | Signature | Description |
|---|---|---|
flatten_forms_on_page |
fn flatten_forms_on_page(&mut self, page: usize) -> Result<()> |
Flatten forms on a page |
flatten_forms |
fn flatten_forms(&mut self) -> Result<()> |
Flatten all form fields |
is_page_marked_for_form_flatten |
fn is_page_marked_for_form_flatten(&self, page: usize) -> bool |
Check if page forms are marked for flatten |
will_remove_acroform |
fn will_remove_acroform(&self) -> bool |
Check if AcroForm will be removed on save |
export_form_data_fdf |
fn export_form_data_fdf(&mut self, output_path: impl AsRef<Path>) -> Result<()> |
Export form data as FDF |
export_form_data_xfdf |
fn export_form_data_xfdf(&mut self, output_path: impl AsRef<Path>) -> Result<()> |
Export form data as XFDF |
Redactions
| Method | Signature | Description |
|---|---|---|
apply_page_redactions |
fn apply_page_redactions(&mut self, page: usize) -> Result<()> |
Apply redactions on a page |
apply_all_redactions |
fn apply_all_redactions(&mut self) -> Result<()> |
Apply all pending redactions |
is_page_marked_for_redaction |
fn is_page_marked_for_redaction(&self, page: usize) -> bool |
Check if page has pending redactions |
unmark_page_for_redaction |
fn unmark_page_for_redaction(&mut self, page: usize) |
Remove pending redactions for a page |
Images
| Method | Signature | Description |
|---|---|---|
page_images |
fn page_images(&mut self, page: usize) -> Result<Vec<ImageInfo>> |
List images on a page |
reposition_image |
fn reposition_image(&mut self, page: usize, image_index: usize, x: f32, y: f32) -> Result<()> |
Move an image |
resize_image |
fn resize_image(&mut self, page: usize, image_index: usize, width: f32, height: f32) -> Result<()> |
Resize an image |
set_image_bounds |
fn set_image_bounds(&mut self, page: usize, image_index: usize, rect: [f32; 4]) -> Result<()> |
Set image bounding box |
clear_image_modifications |
fn clear_image_modifications(&mut self, page: usize) |
Clear pending image modifications |
has_image_modifications |
fn has_image_modifications(&self, page: usize) -> bool |
Check for pending image modifications |
Embedded Files
| Method | Signature | Description |
|---|---|---|
embed_file |
fn embed_file(&mut self, name: &str, data: Vec<u8>) -> Result<()> |
Attach a file |
embed_file_with_options |
fn embed_file_with_options(&mut self, file: EmbeddedFile) -> Result<()> |
Attach with full config |
pending_embedded_files |
fn pending_embedded_files(&self) -> &[EmbeddedFile] |
List pending file attachments |
clear_embedded_files |
fn clear_embedded_files(&mut self) |
Clear pending file attachments |
Rendering (requires rendering feature)
| Method | Signature | Description |
|---|---|---|
render_page |
fn render_page(&mut self, page: usize) -> Result<RenderedImage> |
Render to image |
render_page_with_options |
fn render_page_with_options(&mut self, page: usize, opts: &RenderOptions) -> Result<RenderedImage> |
Render with options |
render_page_to_file |
fn render_page_to_file(&mut self, page: usize, path: impl AsRef<Path>) -> Result<()> |
Render and save to file |
render_page_to_file_with_dpi |
fn render_page_to_file_with_dpi(&mut self, page: usize, path: impl AsRef<Path>, dpi: f32) -> Result<()> |
Render with custom DPI |
Saving
| Method | Signature | Description |
|---|---|---|
save |
fn save(&mut self, path: impl AsRef<Path>) -> Result<()> |
Save to file |
save_as |
fn save_as(&mut self, path: impl AsRef<Path>) -> Result<()> |
Save to a different file |
save_encrypted |
fn save_encrypted(&mut self, path: impl AsRef<Path>, user_password: &str, owner_password: &str) -> Result<()> |
Save with password protection |
save_with_encryption |
fn save_with_encryption(&mut self, path: impl AsRef<Path>, config: EncryptionConfig) -> Result<()> |
Save with full encryption config |
as_bytes |
fn as_bytes(&self) -> &[u8] |
PDF bytes (creation mode) |
into_bytes |
fn into_bytes(mut self) -> Vec<u8> |
Consume and return PDF bytes |
to_bytes |
fn to_bytes(&mut self) -> Result<Vec<u8>> |
Generate PDF bytes |
to_markdown_file |
fn to_markdown_file(&mut self, path: impl AsRef<Path>) -> Result<()> |
Save all pages as Markdown file |
Accessors
| Method | Signature | Description |
|---|---|---|
source_path |
fn source_path(&self) -> Option<&Path> |
Path of the opened file |
editor |
fn editor(&mut self) -> Option<&mut DocumentEditor> |
Access the underlying editor |
config |
fn config(&self) -> &PdfConfig |
Current configuration |
is_modified |
fn is_modified(&self) -> bool |
Whether document has unsaved changes |
PdfBuilder
Fluent builder for creating PDFs with metadata and layout configuration.
use pdf_oxide::api::PdfBuilder;
use pdf_oxide::writer::PageSize;
| Method | Signature | Description |
|---|---|---|
new |
fn new() -> Self |
Create a new builder |
title |
fn title(self, title: impl Into<String>) -> Self |
Set title |
author |
fn author(self, author: impl Into<String>) -> Self |
Set author |
subject |
fn subject(self, subject: impl Into<String>) -> Self |
Set subject |
keywords |
fn keywords(self, keywords: impl Into<String>) -> Self |
Set keywords |
page_size |
fn page_size(self, size: PageSize) -> Self |
Set page size |
margin |
fn margin(self, margin: f32) -> Self |
Set uniform margins |
margins |
fn margins(self, left: f32, right: f32, top: f32, bottom: f32) -> Self |
Set individual margins |
font_size |
fn font_size(self, size: f32) -> Self |
Set font size |
line_height |
fn line_height(self, height: f32) -> Self |
Set line height |
from_markdown |
fn from_markdown(self, content: &str) -> Result<Pdf> |
Build from Markdown |
from_html |
fn from_html(self, content: &str) -> Result<Pdf> |
Build from HTML |
from_text |
fn from_text(self, content: &str) -> Result<Pdf> |
Build from plain text |
from_image |
fn from_image(self, path: impl AsRef<Path>) -> Result<Pdf> |
Build from image |
from_image_bytes |
fn from_image_bytes(self, data: &[u8]) -> Result<Pdf> |
Build from image bytes |
from_images |
fn from_images<P: AsRef<Path>>(self, paths: &[P]) -> Result<Pdf> |
Build from multiple images |
from_qrcode |
fn from_qrcode(self, data: &str) -> Result<Pdf> |
Build from QR code data |
from_barcode |
fn from_barcode(self, data: &str, barcode_type: BarcodeType) -> Result<Pdf> |
Build from barcode data |
DocumentBuilder
Low-level builder for pixel-precise page layout.
use pdf_oxide::writer::DocumentBuilder;
| Method | Signature | Description |
|---|---|---|
new |
fn new() -> Self |
Create a new builder |
metadata |
fn metadata(self, metadata: DocumentMetadata) -> Self |
Set document metadata |
page |
fn page(&mut self, size: PageSize) -> FluentPageBuilder |
Add a page with named size |
letter_page |
fn letter_page(&mut self) -> FluentPageBuilder |
Add US Letter page |
a4_page |
fn a4_page(&mut self) -> FluentPageBuilder |
Add A4 page |
build |
fn build(self) -> Result<Vec<u8>> |
Generate PDF bytes |
save |
fn save(self, path: impl AsRef<Path>) -> Result<()> |
Save to file |
FluentPageBuilder
Returned by DocumentBuilder::page(). Chain calls to add content to a page:
| Method | Description |
|---|---|
text(text, x, y, size) |
Place text at exact coordinates |
heading(level, text) |
Add a heading (H1-H6) |
paragraph(text) |
Add a paragraph with auto-wrap |
space(points) |
Add vertical space |
horizontal_rule() |
Draw a horizontal line |
link_url(url) |
Add a URL link annotation |
link_page(page) |
Add internal page link |
highlight(color) |
Add highlight annotation |
underline(color) |
Add underline annotation |
strikeout(color) |
Add strikeout annotation |
sticky_note(text) |
Add a sticky note |
stamp(stamp_type) |
Add a stamp annotation |
freetext(rect, text) |
Add free text annotation |
watermark(text) |
Add watermark overlay |
add_annotation(annotation) |
Add any annotation type |
done() |
Finish page, return to builder |
DocumentEditor
Open an existing PDF for structural modifications.
use pdf_oxide::editor::DocumentEditor;
Core
| Method | Signature | Description |
|---|---|---|
open |
fn open(path: impl AsRef<Path>) -> Result<Self> |
Open file for editing |
is_modified |
fn is_modified(&self) -> bool |
Check for unsaved changes |
source_path |
fn source_path(&self) -> &str |
Original file path |
source |
fn source(&self) -> &PdfDocument |
Underlying document (read) |
source_mut |
fn source_mut(&mut self) -> &mut PdfDocument |
Underlying document (write) |
version |
fn version(&self) -> (u8, u8) |
PDF version |
current_page_count |
fn current_page_count(&self) -> usize |
Page count |
Metadata
| Method | Description |
|---|---|
title() / set_title() |
Get/set document title |
author() / set_author() |
Get/set author |
subject() / set_subject() |
Get/set subject |
keywords() / set_keywords() |
Get/set keywords |
Page Operations
| Method | Description |
|---|---|
get_page_rotation() / set_page_rotation() |
Get/set rotation |
rotate_page_by() |
Add relative rotation |
rotate_all_pages() |
Rotate all pages |
get_page_media_box() / set_page_media_box() |
Get/set MediaBox |
get_page_crop_box() / set_page_crop_box() |
Get/set CropBox |
crop_margins() |
Crop all pages by margins |
erase_region() / erase_regions() |
White-out content |
extract_pages() |
Extract pages to separate file |
merge_from() / merge_pages_from() |
Merge pages from another PDF |
DOM-Like Editing
| Method | Signature | Description |
|---|---|---|
get_page |
fn get_page(&mut self, page_index: usize) -> Result<PdfPage> |
Get DOM page handle |
save_page |
fn save_page(&mut self, page: PdfPage) -> Result<()> |
Save modified page |
edit_page |
fn edit_page<F>(&mut self, page_index: usize, f: F) -> Result<()> |
Edit with closure |
page_editor |
fn page_editor(&mut self, page_index: usize) -> Result<PageEditor> |
Get page editor |
get_page_content |
fn get_page_content(&mut self, page_index: usize) -> Result<Option<StructureElement>> |
Get page structure |
set_page_content |
fn set_page_content(&mut self, page_index: usize, content: StructureElement) -> Result<()> |
Set page structure |
modify_structure |
fn modify_structure<F>(&mut self, page_index: usize, f: F) -> Result<()> |
Modify structure with closure |
Form Fields
| Method | Description |
|---|---|
get_form_fields() |
List all form fields |
get_form_field_value(name) |
Get field value by name |
set_form_field_value(name, value: FormFieldValue) |
Set field value by name |
has_form_field(name) |
Check field existence |
add_form_field(widget) |
Add a new form field |
flatten_forms_on_page(page) |
Flatten forms on a page |
flatten_forms() |
Flatten all form fields |
export_form_data_fdf(path) |
Export as FDF |
export_form_data_xfdf(path) |
Export as XFDF |
has_xfa() |
Check for XFA forms |
analyze_xfa() |
Analyze XFA form data |
convert_xfa_to_acroform() |
Convert XFA to AcroForm |
Annotations and Flattening
| Method | Description |
|---|---|
flatten_page_annotations(page) |
Flatten annotations on a page |
flatten_all_annotations() |
Flatten all annotations |
get_page_annotations(page) |
List annotations on a page |
Embedded Files
| Method | Description |
|---|---|
embed_file(name, data) |
Attach a file |
embed_file_with_options(file) |
Attach with full config |
pending_embedded_files() |
List pending attachments |
clear_embedded_files() |
Clear pending attachments |
DOM Types
PdfPage
Represents a single page with queryable and editable elements.
| Method | Description |
|---|---|
elements() |
All elements on the page |
text_elements() |
Only text elements |
image_elements() |
Only image elements |
path_elements() |
Only path/graphics elements |
table_elements() |
Only table elements |
find_text_containing(needle) |
Find text matching substring |
set_text(id, new_text) |
Replace text by element ID |
PdfText
| Method | Return | Description |
|---|---|---|
id() |
ElementId |
Unique element identifier |
text() |
&str |
Text content |
bbox() |
Rect |
Bounding rectangle |
font_name() |
&str |
Font name |
font_size() |
f32 |
Font size in points |
is_bold() |
bool |
Bold weight |
is_italic() |
bool |
Italic style |
color() |
Color |
Text color |
set_text(new) |
Replace text | |
append(text) |
Append text | |
replace(old, new) |
usize |
Replace occurrences |
clear() |
Clear text |
PdfImage
| Method | Return | Description |
|---|---|---|
id() |
ElementId |
Unique identifier |
bbox() |
Rect |
Bounding rectangle |
format() |
ImageFormat |
Image format |
dimensions() |
(u32, u32) |
Width and height in pixels |
aspect_ratio() |
f32 |
Width / height ratio |
is_grayscale() |
bool |
Grayscale check |
alt_text() |
Option<&str> |
Alt text for accessibility |
resolution() |
Option<(f32, f32)> |
DPI as (horizontal, vertical) |
PdfPath
| Method | Return | Description |
|---|---|---|
id() |
ElementId |
Unique identifier |
bbox() |
Rect |
Bounding rectangle |
operations() |
&[PathOperation] |
Path drawing operations |
stroke_color() |
Option<Color> |
Stroke color |
fill_color() |
Option<Color> |
Fill color |
stroke_width() |
f32 |
Line width |
line_cap() |
LineCap |
Line cap style |
line_join() |
LineJoin |
Line join style |
is_closed() |
bool |
Whether path is closed |
to_svg() |
String |
Convert to SVG path data |
to_svg_document() |
String |
Convert to standalone SVG |
PdfTable
| Method | Return | Description |
|---|---|---|
id() |
ElementId |
Unique identifier |
bbox() |
Rect |
Bounding rectangle |
row_count() |
usize |
Number of rows |
column_count() |
usize |
Number of columns |
has_header() |
bool |
Whether first row is a header |
get_cell(row, col) |
Option<&TableCellContent> |
Cell contents |
caption() |
Option<&str> |
Table caption |
TextSearcher
use pdf_oxide::search::{TextSearcher, SearchOptions, SearchResult};
SearchOptions
| Field | Type | Default | Description |
|---|---|---|---|
case_sensitive |
bool |
true |
Case-sensitive matching |
literal |
bool |
false |
Treat pattern as literal (not regex) |
whole_word |
bool |
false |
Match whole words only |
max_results |
Option<usize> |
None |
Limit number of results |
page_range |
Option<(usize, usize)> |
None |
Restrict to page range |
SearchResult
| Field | Type | Description |
|---|---|---|
page |
usize |
Page index |
text |
String |
Matched text |
x |
f64 |
X position in points |
y |
f64 |
Y position in points |
FormField and XmpExtractor
FormField (read)
| Field | Type | Description |
|---|---|---|
name |
String |
Fully qualified field name |
field_type |
FieldType |
Text, Button, Choice, Signature |
value |
Option<String> |
Current value |
rect |
Option<Rect> |
Widget bounds |
flags |
u32 |
Field flags |
XmpExtractor
use pdf_oxide::extractors::xmp::XmpExtractor;
Static methods that operate on a PdfDocument:
| Method | Return | Description |
|---|---|---|
extract(doc) |
Result<Option<XmpMetadata>> |
Extract XMP metadata |
XmpMetadata
| Field | Type | Description |
|---|---|---|
title |
Option<String> |
dc:title |
creators |
Vec<String> |
dc:creator |
description |
Option<String> |
dc:description |
creator_tool |
Option<String> |
xmp:CreatorTool |
create_date |
Option<String> |
xmp:CreateDate |
modify_date |
Option<String> |
xmp:ModifyDate |
producer |
Option<String> |
pdf:Producer |
PageLabelExtractor
use pdf_oxide::extractors::page_labels::PageLabelExtractor;
| Method | Return | Description |
|---|---|---|
extract(doc) |
Result<Vec<PageLabelRange>> |
Extract page label definitions |
label_for_page(doc, page) |
Result<String> |
Compute label for a specific page |
all_labels(doc) |
Result<Vec<String>> |
Compute labels for every page |
Standalone Functions
use pdf_oxide::document::{parse_header, parse_trailer};
| Function | Signature | Description |
|---|---|---|
parse_header |
fn parse_header<R: Read + Seek>(reader: &mut R, lenient: bool) -> Result<(u8, u8, u64)> |
Parse PDF header, returns (major, minor, byte_offset) |
parse_trailer |
fn parse_trailer<R: Read>(reader: &mut R) -> Result<Object> |
Parse the trailer dictionary |
Next Steps
- Python API Reference – Python bindings reference
- Types & Enums – all types, enums, and configuration structs
- Getting Started with Rust – tutorial with examples