A name trees is a compound data structure in a PDFs, composed from primitive data types, namely PDF dictionaries and arrays. pikepdf provides an interface that significantly simplifies this complex data structure, making it as simple as manipulating any Python dictionary.
In many cases, the PDF 1.7 Reference Manual specifies that some information is stored in a name
tree. To access and manipulate those objects, use
Some objects that are stored in name trees include the objects in
Dests: named destinations
Pages: named pages
IDS: digital identifiers
Attached files (or embedded files) are managed in a name tree, but pikepdf provides an interface specifically for managing them. Use that instead.
In : from pikepdf import Pdf, Page, NameTree In : pdf = Pdf.open('../tests/resources/outlines.pdf') In : nt = NameTree(pdf.Root.Names.Dests) In : print([k for k in nt.keys()]) ['0', '1', '2', '3', '4', '5', '6', '7', '8'] In : nt['2'].objgen, nt['2'], nt['2'] Out: ((3, 0), pikepdf.Name("/XYZ"), Decimal('89.29'))