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
//! The PDF syntax layer: the object model, its exact serialization, the lexer, the object
//! parser and the stream filters (ISO 32000-2 §7.2–7.4).
//!
//! ```
//! use laminapdf_syntax::{Object, parse_object};
//!
//! let obj = parse_object(b"<< /Kids [3 0 R] /Count 1 >>")?;
//! assert_eq!(obj.as_dict().and_then(|d| d.get_int("Count")), Some(1));
//! assert_eq!(obj.to_bytes(), b"<< /Kids [3 0 R] /Count 1 >>");
//! # Ok::<(), laminapdf_syntax::Error>(())
//! ```
//!
//! This crate is part of Lamina PDF's pure core: it takes bytes and returns values, and never
//! touches the file system, network, clocks or threads, so it builds for native, WebAssembly
//! and mobile targets alike. Every parse path returns [`Result`]; no input panics. Recursion
//! only happens in the object parser, which is depth-limited ([`Limits::max_nesting_depth`]).
//!
//! * [`Object`] and friends: the object model and its byte-exact serialization.
//! * [`parse_object`] / [`Parser`]: the tolerant object parser (indirect objects and
//! streams, with an `endstream` scan when `/Length` is wrong).
//! * [`Lexer`] / [`Token`]: the tokenizer the parser and the cross-reference reader share.
//! * [`filters`]: Flate encode/decode within [`Limits`], and PNG predictors.
//! * [`crypt`]: standard security handler decryption (read only): password authentication
//! for R2–R6 and RC4 / AES-128 / AES-256 string and stream decryption.
//! * [`ErrorKind`], [`Position`] and [`Location`]: the shared parts of the error contract
//! (ADR 0026): kinds and tagged positions; [`ErrorCode`] and [`WarningCode`], every code's
//! kind, hint and `docsUrl` (generated from `fixtures/codes.json`); and, with the `json`
//! feature, `Diagnostic`, the §1 object every boundary serialises.
//! * [`Limits`]: the resource limits of ADR 0003, shared by every layer that reads input.
//! * [`Rotation`]: a rotation by a multiple of 90°, read from `/Rotate` values and shared by
//! the page model and the renderers.
//! * [`text`]: text strings (`PDFDocEncoding`, UTF-16BE, UTF-8) and the `PDFDocEncoding` table.
//!
//! The file structure (cross-reference tables, object streams, repair, the page tree) and the
//! writer live one layer up, in `laminapdf-cos`.
/// Generated by `cargo xtask gen codes` from `fixtures/codes.json`; never edited by hand.
// What `fixtures/codes.json` lists, for the kind tests.
use codes as test_codes;
pub use CancelToken;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use Diagnostic;
pub use Rotation;