Skip to main content

ContentHandler

Trait ContentHandler 

Source
pub trait ContentHandler {
    // Provided methods
    fn on_char(&mut self, _event: CharEvent) { ... }
    fn on_path_painted(&mut self, _event: PathEvent) { ... }
    fn on_image(&mut self, _event: ImageEvent) { ... }
    fn on_warning(&mut self, _warning: ExtractWarning) { ... }
}
Expand description

Callback handler for content stream interpretation.

The content stream interpreter calls these methods as it processes PDF page content. Implementors collect the events to build extraction results (characters, paths, images).

All methods have default no-op implementations, allowing handlers to subscribe only to the event types they care about.

§Text Operations

on_char is called for each rendered character glyph with full positioning and font context.

§Path Operations

on_path_painted is called when a path is stroked, filled, or both.

§Image Operations

on_image is called when an image XObject is placed on the page.

Provided Methods§

Source

fn on_char(&mut self, _event: CharEvent)

Called when a character glyph is rendered.

Source

fn on_path_painted(&mut self, _event: PathEvent)

Called when a path is painted (stroked, filled, or both).

Source

fn on_image(&mut self, _event: ImageEvent)

Called when an image XObject is placed on the page.

Source

fn on_warning(&mut self, _warning: ExtractWarning)

Called when a non-fatal warning is encountered during interpretation.

Warnings indicate best-effort degradation (e.g., missing font metrics, unresolvable references). They do not affect extraction correctness — the interpreter continues with sensible defaults.

Implementors§