pdf/src/read/nav.rs#
Source: lib/pdf/src/read/nav.rs
What a document holds besides its pages' content (ISO 32000-1, 12): the outline
(bookmarks), destinations (explicit and named, through the /Dests dictionary or the name
tree), actions, annotations with links, the fields of an interactive form with their values
and signatures (read, not verified), embedded files and page labels. Trees and lists are
walked with a set of the objects seen and a budget, so a loop or a huge tree ends.
enum Viewhow a destination shows its page (12.3.2.2); None keeps what the viewer hasXyz { left: Option<f64>, top: Option<f64>, zoom: Option<f64> }FitFitH(Option<f64>)FitV(Option<f64>)FitR([f64; 4])-- left, bottom, right, topFitBFitBH(Option<f64>)FitBV(Option<f64>)
struct Desta place in the document: a page (counted from 0) and how it is shownpage: usizeview: View
enum Actionwhat an outline item or a link does (12.6.4)GoTo(Dest)Uri(String)-- a web address or other URIGoToFile { file: String, page: Option<usize> }-- a page of another PDF file (GoToR): the file, the page when given as a numberLaunch(String)-- start another file or program (Launch)Named(String)-- a viewer command (Named: NextPage, PrevPage, FirstPage, LastPage, ...)Other(String)-- any other kind of action (JavaScript, SubmitForm, ...), by its /S
struct Outlinean item of the outline, with its childrentitle: Stringaction: Option<Action>open: bool-- its children are shownchildren: Vec<Outline>
struct Annotationan annotation of a pagesubtype: String-- /Subtype: Link, Text, Highlight, Widget, FileAttachment, ...rect: [f64; 4]-- x0, y0, x1, y1 in page spacecontents: Option<String>-- /Contents: the text of a note or commentauthor: Option<String>-- /T: the author of a markup annotationmodified: Option<Date>action: Option<Action>-- a link's action (its /A, or its /Dest as GoTo)obj: Option<Ref>
enum FieldKinda form field's kind (12.7.4)TextCheckBoxRadioPushButtonComboBoxListBoxSignatureUnknown-- a field without /FT
struct Signaturea field's signature as the file states it (12.8): the signature is not verifiedfilter: String-- /Filter and /SubFilter: Adobe.PPKLite, adbe.pkcs7.detached, ETSI.CAdES.detached, ...sub_filter: Stringname: Option<String>-- /Name, /Reason, /Location, /ContactInfo as givenreason: Option<String>location: Option<String>time: Option<Date>byte_range: Vec<(u64, u64)>-- the byte ranges of the file the signature covers: (start, length) pairscontents: Vec<u8>-- the signature (a PKCS #7 / CMS structure for the usual kinds)covers_file: bool-- the ranges cover the whole file but the signature itself (later changes make it false)
struct Fielda field of the interactive formname: String-- the full name: the partial names of its parents and its own, with dotskind: FieldKindvalue: Vec<String>-- the value: text, the chosen option(s), a button's state ("Off" when not checked; the export value of /Opt when the state is a place in it)flags: u32-- /Ffread_only: boolrequired: booloptions: Vec<String>-- the options of a choice field, as shownwidgets: Vec<(Option<usize>, [f64; 4])>-- the widgets: the page (when known) and the rectanglesignature: Option<Signature>-- for a signature field with a value
struct Attachmenta file embedded in the document (7.11.4)name: String-- the file name (/UF, else /F)description: Option<String>mime: Option<String>-- /Subtype of the file stream: a MIME type ("text/xml")size: Option<u64>modified: Option<Date>relationship: Option<String>-- /AFRelationship (PDF/A-3, ZUGFeRD: Data, Source, Alternative, ...)stream: Option<Stream>-- the data: Document::decode(&stream)
impl Document
fn named_dest(&self, name: &str) -> Option<Dest>a named destination ("chapter1")fn outlines(&self) -> Vec<Outline>the outline (bookmarks)fn annotations(&self, page: usize) -> Result<Vec<Annotation>, Error>the annotations of a pagefn links(&self, page: usize) -> Result<Vec<([f64; 4], Action)>, Error>the links of a page: (rectangle, action)fn fields(&self) -> Vec<Field>the fields of the interactive form (the AcroForm), terminal fields onlyfn attachments(&self) -> Vec<Attachment>the embedded files: the /EmbeddedFiles name tree, then file attachment annotationsfn page_label(&self, page: usize) -> Option<String>a page's label (12.4.2: "iv", "A-3"); None when the document sets no labels