View Source Pdf.Reader.Outlines (ExPDF v1.0.1)

Walker for catalog /Outlines (PDF document outline / bookmarks tree).

Traverses the linked-list /First//Next chain at each nesting level and recurses into /First for child outlines. A MapSet of {obj_num, gen_num} xref keys is threaded through the walk to prevent infinite loops when a corrupt PDF has cyclic /Next or /First references. A depth cap of @max_outline_depth 32 ensures that arbitrarily deep trees do not overflow the call stack.

Spec references

Summary

Functions

Reads the document outline tree from the PDF catalog's /Outlines entry.

Functions

@spec read(Pdf.Reader.Document.t()) ::
  {:ok, [Pdf.Reader.Outline.t()], Pdf.Reader.Document.t()} | {:error, term()}

Reads the document outline tree from the PDF catalog's /Outlines entry.

Returns {:ok, outlines, doc} where outlines is a (possibly empty) list of %Pdf.Reader.Outline{} structs arranged as a recursive tree.

When the catalog has no /Outlines key, returns {:ok, [], doc} — never an error. The returned doc may have a warmer cache than the input (the :page_ref_index and :named_dest_index cache keys may be populated).