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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
// Copyright (c) 2026 Innovation Trigger B.V.
//
// PDFluent is available under two licences, at your option: the GNU AGPLv3, or
// the PDFluent Commercial Licence. See the LICENSE file in this repository --
// that file travels with the copy you received, which a URL does not.
//! Unified PDF rendering engine.
//!
//! `pdf-engine` is the main public-facing API for reading and rendering PDF
//! documents. It wraps the lower-level `pdf-syntax` / `pdf-interpret` /
//! `pdf-render` stack and exposes a single [`PdfDocument`] handle for all
//! common operations: page rendering, text extraction, thumbnails, metadata,
//! bookmarks, and full-text search.
//!
//! # Quick Start
//!
//! ```no_run
//! use std::sync::Arc;
//! use pdf_engine::{PdfDocument, RenderOptions};
//!
//! // Load from bytes (accepts Arc<Vec<u8>>, Vec<u8>, or any Into<PdfData>).
//! let data = Arc::new(std::fs::read("invoice.pdf").unwrap());
//! let doc = PdfDocument::open(data).unwrap();
//!
//! println!("{} pages — {:?}", doc.page_count(), doc.info().title);
//!
//! // Render page 0 at 150 DPI → raw RGBA pixel data.
//! let opts = RenderOptions { dpi: 150.0, ..Default::default() };
//! let rendered = doc.render_page(0, &opts).unwrap();
//! println!("{}×{} px", rendered.width, rendered.height);
//!
//! // Plain-text extraction.
//! let text = doc.extract_text(0).unwrap();
//! println!("{text}");
//!
//! // Structured text with per-span positions.
//! for block in doc.extract_text_blocks(0).unwrap() {
//! for span in &block.spans {
//! println!(" [{:.0}, {:.0}] {}", span.x, span.y, span.text);
//! }
//! }
//!
//! // Full-text search — returns 0-based page indices.
//! let hits = doc.search_text("total");
//! println!("'total' found on {} page(s)", hits.len());
//! ```
//!
//! # Key Types
//!
//! | Type | Description |
//! |---|---|
//! | [`BatchConfig`] / [`BatchResult`] | Worker-pool processing for many PDFs |
//! | [`PdfDocument`] | Main document handle |
//! | [`RenderConfig`] / [`RenderOptions`] | DPI, color mode, background colour, optional forced width/height |
//! | [`RenderedPage`] | RGBA or CMYK pixel data (row-major, 4 bytes per pixel) |
//! | [`PageGeometry`] | MediaBox, CropBox, TrimBox, BleedBox, rotation |
//! | [`PageBox`] | A rectangle in PDF user-space points |
//! | [`DocumentInfo`] | Title, author, subject, creator, producer |
//! | [`TextBlock`] / [`TextSpan`] | Structured text with position and font size |
//! | [`Block`] / [`BlockKind`] / [`ExtractOptions`] | Paragraphs, headings and list items, and which pages of them come back |
//! | [`Word`] | One word with its box, page, block and line |
//! | [`to_markdown`] / [`to_json`] | Those blocks as markdown for a reader, or as JSON for a chunker |
//! | [`BookmarkItem`] | Outline node — title, target page, nested children |
//! | [`ThumbnailOptions`] | Max-dimension constraint for thumbnail rendering |
/// Public engine error type and stable error-code mapping. See
/// [`api_error::PdfEngineError`].
/// The balanced tier's page assembly: detector boxes plus our own text (#641).
/// Off by default, beside [`layout`].
/// Visual-to-logical reordering of a line of extracted text (UAX #9 L2).
/// Internal: extraction reorders, nothing outside it needs to.
/// Paragraphs and the [`blocks::Block`] model the structured serializers
/// consume (#567).
/// The text of a table cell with its dot leaders struck and its currency
/// sign joined to its figure (#714).
/// A line wrapped under its entry in a two-column index, joined to the
/// entry (#714).
/// A row or a column of a table with no text in it, dropped from the final
/// table (#714).
/// Running headers, footers and page numbers, from what a document repeats on
/// three or more pages (#571). Internal: it runs on the way out of
/// `extract_blocks` and the kind it decides is on the block. The public API
/// over the model is #573.
/// A column head wrapped over two or three lines, folded into one header row
/// of the final table (#714).
/// Heading levels, from the document's own size and weight statistics (#568).
/// Internal: it runs on the way out of `extract_blocks`, and the level it
/// decides is on the block. The public API over the model is #573.
/// The block model as JSON: every block with its kind, page, box, text, spans
/// and reading-order index, for a caller that chunks the document itself
/// (#572).
/// Layout detection on the shared ONNX Runtime layer (#641). Off by default.
/// Typographic ligatures fold to the letters they stand for. Internal: the
/// option that turns it off rides on the extraction device.
/// List items, from bullet glyphs, numbering and the column's indent steps
/// (#569). Internal: it runs inside the paragraph merge, and the level and the
/// number it decides are on the block. The public API over the model is #573.
/// The block model as markdown: headings, lists, tables and a marker where the
/// page changed (#572).
/// Figures in the block model: listing, naming, pixels, and references (#658).
/// The model tiers' shared surface: specs, failures and install paths (#641).
/// Always compiled; only the session half needs the `ort` feature.
/// Scan detection: how much OCR a page needs, before any recognizer runs.
/// OCR before extraction: a searchable copy of the document to read instead.
/// Internal: it runs inside `extract_blocks` when `ExtractOptions::ocr` asks,
/// and the one public method on it is for bindings with their own engine.
/// The reading order of the whole document: the columns of a page, the pages
/// in turn, and the paragraph a page break cut in two (#571). Internal, for
/// the reason the other passes are.
/// A row whose every cell holds the same number of lines, split into that
/// many rows (#714).
/// Many documents as markdown in one process, for the structured benchmark's
/// fair clock (#623).
/// A stub wrapped onto the line of its figures, joined to it (#714).
/// Marker-led rows the table pass left at the edge of an accepted table
/// (#636). Internal: it runs after the learned pass, over its blocks, and
/// only adopts paragraphs the accepted tables' own columns confirm.
/// Which stage produced each table, for the env-gated diagnostic trace
/// (#636). Internal: it measures finished cells and veto verdicts and prints
/// numbers-only lines on stderr. Rule A2 (drawing_dense) lives here too: it
/// withdraws a table whose box holds three or more drawn clusters.
pub
/// Tables: the column grid a run of rows stands in, and the cells that fill it
/// (#570). Internal: it runs inside the paragraph merge, and the row, column
/// and spans it decides are on the block. The public API over the model is
/// #573.
/// Kinds and reading order from a tagged PDF's own structure tree (#636).
/// Internal: it runs last over the finished blocks when
/// `ExtractOptions::use_tags` is set, and only where the tree passes the
/// validity check; anything else returns the geometric answer untouched.
/// A currency sign at the end of a cell, moved onto the figure in the cell
/// to its right (#714).
/// Optional vision layer: raster plus ONNX runner (#636). Off by default.
pub use ;
pub use ;
/// The P3 test seam behind [`TatrOptions`]. Hidden: tests name it, callers
/// never do.
pub use ;
pub use preserve_device_cmyk;
pub use ;
pub use ;
pub use ;
pub use ;
pub use to_json;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use TextSpanInfo;
pub use ThumbnailOptions;
pub use ;
pub use best_available_backend;
pub use ocr_page_default;
pub use AwsTextractBackend;
pub use AzureDocIntelBackend;
pub use GoogleVisionBackend;
pub use MistralOcrBackend;
pub use OcrsBackend;
pub use PaddleOnnxBackend;