JFLib

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 View how a destination shows its page (12.3.2.2); None keeps what the viewer has

    • Xyz { left: Option<f64>, top: Option<f64>, zoom: Option<f64> }
    • Fit
    • FitH(Option<f64>)
    • FitV(Option<f64>)
    • FitR([f64; 4]) -- left, bottom, right, top
    • FitB
    • FitBH(Option<f64>)
    • FitBV(Option<f64>)
  • struct Dest a place in the document: a page (counted from 0) and how it is shown

    • page: usize
    • view: View
  • enum Action what an outline item or a link does (12.6.4)

    • GoTo(Dest)
    • Uri(String) -- a web address or other URI
    • GoToFile { file: String, page: Option<usize> } -- a page of another PDF file (GoToR): the file, the page when given as a number
    • Launch(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 Outline an item of the outline, with its children

    • title: String
    • action: Option<Action>
    • open: bool -- its children are shown
    • children: Vec<Outline>
  • struct Annotation an annotation of a page

    • subtype: String -- /Subtype: Link, Text, Highlight, Widget, FileAttachment, ...
    • rect: [f64; 4] -- x0, y0, x1, y1 in page space
    • contents: Option<String> -- /Contents: the text of a note or comment
    • author: Option<String> -- /T: the author of a markup annotation
    • modified: Option<Date>
    • action: Option<Action> -- a link's action (its /A, or its /Dest as GoTo)
    • obj: Option<Ref>
  • enum FieldKind a form field's kind (12.7.4)

    • Text
    • CheckBox
    • Radio
    • PushButton
    • ComboBox
    • ListBox
    • Signature
    • Unknown -- a field without /FT
  • struct Signature a field's signature as the file states it (12.8): the signature is not verified

    • filter: String -- /Filter and /SubFilter: Adobe.PPKLite, adbe.pkcs7.detached, ETSI.CAdES.detached, ...
    • sub_filter: String
    • name: Option<String> -- /Name, /Reason, /Location, /ContactInfo as given
    • reason: Option<String>
    • location: Option<String>
    • time: Option<Date>
    • byte_range: Vec<(u64, u64)> -- the byte ranges of the file the signature covers: (start, length) pairs
    • contents: 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 Field a field of the interactive form

    • name: String -- the full name: the partial names of its parents and its own, with dots
    • kind: FieldKind
    • value: 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 -- /Ff
    • read_only: bool
    • required: bool
    • options: Vec<String> -- the options of a choice field, as shown
    • widgets: Vec<(Option<usize>, [f64; 4])> -- the widgets: the page (when known) and the rectangle
    • signature: Option<Signature> -- for a signature field with a value
  • struct Attachment a 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 page
  • fn fields(&self) -> Vec<Field> the fields of the interactive form (the AcroForm), terminal fields only
  • fn attachments(&self) -> Vec<Attachment> the embedded files: the /EmbeddedFiles name tree, then file attachment annotations
  • fn page_label(&self, page: usize) -> Option<String> a page's label (12.4.2: "iv", "A-3"); None when the document sets no labels

Source: docs/API.md in the JFLib repository.