Skip to main content

pdfrum_doc/
lib.rs

1#![doc = include_str!("../README.md")]
2#![forbid(unsafe_code)]
3#![cfg_attr(docsrs, feature(doc_cfg))]
4// Every byte this crate reads came from an untrusted file: index with `get()`.
5#![warn(clippy::indexing_slicing)]
6
7pub mod annot;
8pub mod annot_render;
9pub mod ap;
10pub mod color;
11pub mod error;
12pub mod form;
13pub mod geom;
14pub mod nav;
15pub mod page_label;
16pub mod pdfa;
17pub mod prefs;
18pub mod signature;
19pub mod structure;
20pub mod vt;
21
22pub(crate) mod metadata;
23mod names;
24
25pub use annot::{AnnotFlags, Annotation, Subtype};
26pub use ap::{AnnotOverlay, Focus, FocusBox, GeneratedAp};
27pub use color::Color;
28pub use error::Error;
29pub use metadata::xmp;
30pub use nav::{
31    AActionType, Action, ActionKind, Bookmark, Dest, FileSpec, Link, NameTree, ZoomMode,
32};
33pub use page_label::page_label;
34pub use pdfa::{Clause as PdfaClause, Level as PdfaLevel, Report as PdfaReport};
35pub use prefs::ViewerPrefs;
36pub use structure::{StructElement, StructTree};
37
38use pdfrum_common::Limits;
39
40/// How much of the appearance-generation surface a document walk turns on.
41///
42/// Both switches are off by default because that is what the oracle does: it
43/// builds every annotation list through the form-fill environment, which
44/// disables the `/NeedAppearances` widget path outright. The implementations
45/// exist for callers that want the documented viewer behavior instead.
46///
47/// ```
48/// use pdfrum_doc::DocOptions;
49///
50/// // Both switches are off by default, which is what a viewer building
51/// // its annotation list through the form-fill environment does.
52/// assert!(!DocOptions::default().generate_widget_ap);
53///
54/// // Turn on the documented `/NeedAppearances` behaviour instead:
55/// let options = DocOptions {
56///     generate_widget_ap: true,
57///     generate_widget_shapes: true,
58///     ..DocOptions::default()
59/// };
60/// assert!(options.generate_widget_shapes);
61/// ```
62#[derive(Debug, Clone, Default, PartialEq, Eq)]
63pub struct DocOptions {
64    /// Generate an appearance for a `/NeedAppearances` widget that has none.
65    pub generate_widget_ap: bool,
66    /// Draw the check, cross, star, circle, square and diamond glyphs for
67    /// checkbox and radio widgets.
68    pub generate_widget_shapes: bool,
69    /// Depth and size caps.
70    pub limits: Limits,
71}