Outlines Reference¶
See also
- class pdfnaut.objects.outlines.OutlineItem[source]¶
Bases:
PdfDictionaryAn outline item within the outline tree.
See ISO 32000-2:2020 “Table 151 - Entries in an outline item dictionary” for details.
- __init__(text: str, flags: OutlineItemFlags = OutlineItemFlags.NULL, destination: PdfName | PdfHexString | bytes | Destination | None = None, action: Action | None = None, color: list[float] | None = None, *, pdf: PdfParser | None = None, indirect_ref: PdfReference | None = None) None[source]¶
- property children: OutlineList¶
The immediate children of the outline item.
- close() None[source]¶
If the item has children, closes the outline item and hides the immediate children.
- color: list[float]¶
The color that shall be used for the outline item text, as an array of RGB color components in the range 0 to 1.
- property destination: PdfName | PdfHexString | bytes | Destination | None¶
The destination that shall be displayed when the item is activated, either a named destination (a name or byte string) or an explicit destination (a
Destinationobject).
- property first: OutlineItem | None¶
The first child item of the outline if any.
- flags: OutlineItemFlags¶
A set of bit flags describing characteristics of the outline item text.
- property last: OutlineItem | None¶
The last child item of the outline if any.
- property next: OutlineItem | None¶
The next item at the current outline level if any.
- open() None[source]¶
If the item has children, opens the outline item and displays the immediate children (and its descendants if they are also visible).
- property parent: OutlineItem | OutlineTree¶
The parent outline item or tree containing this outline.
- property previous: OutlineItem | None¶
The previous item at the current outline level if any.
- class pdfnaut.objects.outlines.OutlineItemFlags[source]¶
Bases:
IntFlagFlags specifying style characteristics for an outline item. See “Table 152 - Outline item flags” for details.
- BOLD = 2¶
Display the outline item text in bold.
- ITALIC = 1¶
Display the outline item text in italic.
- NULL = 0¶
No flags
- __new__(value)¶
- class pdfnaut.objects.outlines.OutlineList[source]¶
Bases:
MutableSequence[OutlineItem]The outline list representing the children of an outline tree or item.
Warning
This class is not designed to be constructed by a user. Using the outline list should be done via
OutlineTreeandOutlineItem.- __init__(pdf: PdfParser, parent: OutlineItem | OutlineTree) None[source]¶
- append(value: OutlineItem) None[source]¶
Appends an outline item
valueto the immediate children of the list.
- count(value: Any) int[source]¶
Returns the amount of times outline item
valueappears in the page list.
- extend(values: Iterable[OutlineItem]) None[source]¶
Appends a list of outline items
valuesto the end of the outline list.
- index(value: Any, start: int = 0, stop: int = sys.maxsize) int[source]¶
Returns the index at which outline item
valuewas first found in the range ofstartincluded tostopexcluded.
- insert(index: int, value: OutlineItem) None[source]¶
S.insert(index, value) – insert value before index
- pop(index: int = -1) OutlineItem[source]¶
Removes the outline item at
indexfrom the immediate children of this outline list.- Raises:
IndexError – The outline list is empty or the item is not in the list.
- Returns:
The outline item that was popped.
- Return type:
- remove(value: OutlineItem) None[source]¶
Removes the first occurrence of outline item
valuein the immediate children of this tree.- Raises:
IndexError – The outline list is empty or the item is not in the list.
- class pdfnaut.objects.outlines.OutlineTree[source]¶
Bases:
PdfDictionaryThe document outline tree containing a hierarchy of outline items that allow navigating throughout the document.
See ISO 32000-2:2020 § 12.3.3 “Document outline” for details.
Warning
This class is not designed to be constructed by a user. To add an outline tree to a document,
PdfDocument.new_outline()should be used.- __init__(pdf: PdfParser, tree: PdfDictionary, tree_ref: PdfReference) None[source]¶
- property children: OutlineList¶
The immediate children of the outline tree.
- property first: OutlineItem | None¶
The first outline item in the tree.
- property last: OutlineItem | None¶
The last outline item in the tree.
- pdfnaut.objects.outlines.flatten_outlines(item: OutlineItem | OutlineTree) Generator[OutlineItem, None, None][source]¶
Yields the immediate children of the outline
item.
- pdfnaut.objects.outlines.get_count(item: OutlineTree | OutlineItem) int[source]¶
Calculates the count of visible items within an outline
itemor tree.
- pdfnaut.objects.outlines.is_outline_tree(item: PdfDictionary) bool[source]¶
Reports whether a dictionary
itemis an outline tree.
- pdfnaut.objects.outlines.update_ancestor_count(item: OutlineTree | OutlineItem) None[source]¶
Recalculates the visible item count for the outline
item, reflecting this count in the ancestors.