1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! # rustium-pdf
//!
//! Pure-Rust extraction of PDF page primitives — glyphs with geometry, vector paths, images —
//! plus page rendering. No C library, no FFI, no global state.
//!
//! It is what [rustypaper] reads PDFs with.
//!
//! [rustypaper]: https://github.com/pgarrett-scripps/rustypaper
//!
//! ```no_run
//! # fn main() -> rustium_pdf::Result<()> {
//! let doc = rustium_pdf::Document::open("paper.pdf")?;
//! let page = doc.page(0)?;
//!
//! // Primitives are in user space (y-up); `page_matrix` converts to y-down device space.
//! for glyph in page.glyphs.iter().filter(|g| g.is_visible()) {
//! println!("{:?} at {:?} {}pt bold={}",
//! glyph.text, glyph.origin, glyph.font_size, glyph.flags.is_bold());
//! }
//!
//! let png = page.render(&doc, rustium_pdf::RenderOptions::at_dpi(150.0))?.to_png()?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Threading
//!
//! [`Document`] is `Send + Sync` with no global state, so pages can be extracted and rendered
//! concurrently from one open document, without a lock around it.
//!
//! ## Text semantics
//!
//! A word break the page expresses as a positioning gap rather than a space character is emitted
//! as a glyph flagged [`Glyph::is_generated_space`], so word boundaries survive.
//! [`Page::text`] drops soft hyphens, which mark optional break points rather than content.
//! Primitives are in user space (y-up); [`Page::page_matrix`] converts to y-down page space.
//!
//! ## Fonts without embedded programs
//!
//! A document may name Helvetica or Times and embed nothing. Extraction is unaffected: advances
//! come from built-in metrics for the standard 14. Rendering substitutes a system face, chosen
//! by style and preferring the metrically compatible Liberation family. Set `RUSTIUM_FONT_DIR`
//! to pin the search to fonts you ship. Positions always come from the document, never the
//! substitute, so a missing font shifts nothing.
//!
//! ## Known gaps
//!
//! * Type1 `/FontFile` programs yield metrics and text but no outlines; CFF and TrueType do.
//! * Predefined non-Identity CJK CMaps fall back to the identity mapping.
//! * `JPXDecode`, `CCITTFaxDecode` and `JBIG2Decode` images are passed through undecoded and
//! are skipped when rendering; `DCTDecode` (JPEG) and the byte filters are handled.
//! * Clipping is tracked as a bounding rectangle, not an arbitrary path.
pub use Document;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;