Skip to main content

Crate pdf_annotation_extractor

Crate pdf_annotation_extractor 

Source
Expand description

Extract highlighted text and comments from an annotated PDF.

Text markup annotations (Highlight/Underline/StrikeOut/Squiggly) carry /QuadPoints but not the text they cover, so that text is recovered by intersecting each quad with the page’s glyph boxes. Text and FreeText annotations have no quads and yield comment-only records.

Three pdf_oxide behaviours are worked around here:

  • /Contents is decoded with from_utf8_lossy, which mangles the UTF-16BE strings most annotators write. We re-decode from raw_dict.
  • The glyph coordinate convention is not reliably documented, so rather than trusting a doc comment we infer it from the glyphs themselves (see GlyphSpace::infer) and show the evidence under –debug-geometry.
  • /ActualText is re-encoded through the font in character mode, which corrupts every declared span. See actual_text.

Re-exports§

pub use markdown::BareStyle;
pub use markdown::Descriptor;
pub use markdown::Escaping;
pub use markdown::Numbering;
pub use markdown::Section;
pub use markdown::Style;
pub use diagnostic::Diagnostic;
pub use diagnostic::Diagnostics;
pub use diagnostic::Severity;
pub use error::Error;

Modules§

diagnostic
What had to be assumed, worked around, or given up on.
error
The four ways a report fails to be produced.
markdown
Markdown rendering.

Structs§

Options
How to read a document.
Record
Report
What one document yielded.

Enums§

GlyphSpace

Functions§

extract
Read every annotation worth reporting out of one PDF.