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
//! Typed, tolerant views over a PDF's COS graph ([ADR 0005] §4), the stable
//! [`LaminaPdfId`]s that ops, undo and sync address (§5), and the graphics values that
//! building and reading share ([`Matrix`], [`FillRule`], [`Dash`]).
//!
//! ```
//! use laminapdf_model::{Document, OpenOptions, Rotation};
//! use laminapdf_cos::{Dict, Object};
//! use laminapdf_save::test_support::Writer;
//!
//! let mut w = Writer::new(1, 7);
//! let pages = w.reserve();
//! let page = w.add(
//! [("Type", Object::name("Page")), ("Parent", pages.into()), ("Rotate", 90.into())]
//! .into_iter()
//! .collect::<Dict>(),
//! );
//! let media_box = Object::Array(vec![0.into(), 0.into(), 612.into(), 792.into()]);
//! w.set(pages, [("Type", Object::name("Pages")), ("Kids", vec![page.into()].into()), ("Count", 1.into()),
//! ("MediaBox", media_box)].into_iter().collect::<Dict>());
//! let root = w.add([("Type", Object::name("Catalog")), ("Pages", pages.into())].into_iter().collect::<Dict>());
//! let bytes = w.finish(&[("Root", root)].into_iter().collect())?;
//!
//! let doc = Document::open(bytes, OpenOptions::default())?;
//! let pages = doc.pages()?;
//! let first = pages.get(0).expect("one page");
//! assert_eq!(first.id().to_string(), "p2.0");
//! assert_eq!(first.media_box()?.map(|r| r.width()), Some(612.0)); // inherited from /Pages
//! assert_eq!(first.rotate()?, Rotation::Clockwise90);
//! assert_eq!(pages.by_id(&"p2.0".parse()?).map(|p| p.index()), Some(0));
//! assert!(doc.outline()?.is_empty());
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! This crate is part of Lamina PDF's pure core: bytes in, bytes out, no file system, network,
//! clocks or threads.
//!
//! * [`Document`]: a [`laminapdf_cos::Document`] (it dereferences to one) plus the
//! document-level [`IdAllocator`].
//! * [`Pages`] / [`Page`]: boxes as normalised [`UserSpaceRect`]s, [`Rotation`], user unit,
//! the [`PageFrame`] (page space, [ADR 0027]),
//! resources, contents and annotation references, page labels.
//! * [`Outline`] / [`OutlineItem`]: titles, nesting, open state, [`Destination`]s resolved
//! to [`PageId`]s, action kinds.
//! * [`Info`]: the information dictionary, with dates as [`PdfDate`].
//! * [`Disclosure`]: what a document holds beyond its visible pages ([`Document::disclosure`]).
//! * [`xmp`]: the XMP metadata packet ([`Document::xmp`]): a tolerant reader, typed access to
//! the properties Info mirrors, the Info ↔ XMP mapping table, and a writer that keeps every
//! property it doesn't change.
//! * [`NameTree`] / [`NumberTree`] and [`PageLabels`].
//! * [`StructTree`] / [`StructElem`]: a minimal read-only view of the logical structure
//! (types, attributes, MCIDs and `OBJR`s per element, the `RoleMap`).
//! * [`LaminaPdfId`], [`PageId`], [`OutlineItemId`], [`AnnotId`], [`FieldId`].
//! * Units and coordinates ([ADR 0027]): [`Pt`], [`PointPt`], [`RectPt`] (page space) and
//! [`UserSpacePoint`], [`UserSpaceRect`] (raw user space).
//!
//! # Tolerance
//!
//! Views read their fields lazily and apply [ADR 0003]'s tolerance per field: a malformed
//! `/MediaBox` is `None` plus [`Warning::InvalidBox`], not a failed page. Warnings are
//! recorded on the document ([`laminapdf_cos::Document::warnings`]); strict mode turns each
//! into [`Error::Strict`]. Tree walks (outline, name and number trees) are iterative, keep a
//! visited set, and skip subtrees deeper than [`Limits::max_tree_depth`] with a warning.
//! Only strict-mode refusals and unavailable input ([`Error::DataPending`],
//! [`Error::Source`]) end a view's call; every other unreadable value counts as absent.
//!
//! [ADR 0005]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0005-document-model.md
//! [ADR 0027]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0027-coordinates-units-and-page-indexing.md
//! [ADR 0003]: https://github.com/laudebugs/laminapdf/blob/main/docs/decisions/0003-reader-tolerance-and-limits.md
pub use ;
pub use ;
pub use ;
pub use Document;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ParentedPage;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use TreeWriter;
// The layers below, in façade order (ADR 0005 §1): what callers of the model need without
// naming `laminapdf-cos`.
pub use ;