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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//! Safe, self-contained Rust bindings for [PDFium], Google's PDF engine:
//! open documents from memory, inspect pages, render to **owned** pixel
//! buffers, map coordinates between rendered pixels and PDF page space,
//! extract positioned text, and draw form fields — safely usable from
//! concurrent code.
//!
//! [PDFium]: https://pdfium.googlesource.com/pdfium/
//!
//! # Quickstart
//!
//! PDFium is loaded **at runtime** (no build-time linking): fetch a binary
//! once with `cargo xtask fetch-pdfium` (repo checkouts), ship one next to
//! your executable, or point `PDFIUM_LIB_PATH` at one. Then:
//!
//! ```no_run
//! use firecrawl_pdfium::{Pdfium, RenderConfig};
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Discovery chain: $PDFIUM_LIB_PATH → exe dir → ./target/pdfium → system.
//! let pdfium = Pdfium::load()?;
//!
//! let bytes = std::fs::read("document.pdf")?;
//! let doc = pdfium.load_document(bytes, None)?; // None = no password
//! println!("{} pages", doc.page_count());
//!
//! let page = doc.page(0)?;
//! let rendered = page.render(&RenderConfig::new().dpi(144.0))?;
//! println!(
//! "{}x{} pixels, {} bytes/row, {:?}",
//! rendered.width(),
//! rendered.height(),
//! rendered.stride(),
//! rendered.format(),
//! );
//!
//! // Map a pixel back into PDF page space (points, origin bottom-left):
//! let pt = rendered.transform().pixel_to_page((10.0, 10.0).into());
//! println!("pixel (10,10) is at ({:.2}, {:.2})pt", pt.x, pt.y);
//! # Ok(())
//! # }
//! ```
//!
//! # Errors on hostile input
//!
//! Encrypted documents surface as [`Error::PasswordRequired`] /
//! [`Error::IncorrectPassword`] / [`Error::UnsupportedSecurity`]; garbage
//! and truncated files as [`Error::InvalidPdf`]; oversized render requests
//! as [`Error::RenderTooLarge`] (bounded by
//! [`RenderConfig::max_output_bytes`]).
//!
//! # Concurrency model
//!
//! PDFium itself is single-threaded. Every call is serialized through one
//! process-wide mutex, making all handle types `Send + Sync` — safe from
//! any thread, but not parallel. See [`Pdfium`] for details and
//! `docs/DESIGN.md` for the soundness argument. For parallel throughput,
//! shard across processes.
//!
//! # Raw FFI escape hatch
//!
//! The [`sys`] module exposes the loaded function table for calls this
//! crate does not wrap yet; combine with [`Pdfium::ffi_lock`] to stay
//! within the serialization contract.
pub use ;
pub use ;
pub use ;
pub use FormType;
pub use ;
pub use ;
pub use ;
pub use ;