You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`title`|`str`| — | The visible text label shown in the PDF outline panel. |
39
+
|`page_number`|`None`, `int`, `PageObject`, or `IndirectObject`| — | Destination page for the outline item. May be set to `None`, making the entry non-clickable and usable as a parent/group node. |
40
+
|`parent`|`None`, `TreeObject`, or `IndirectObject`|`None`| Makes the outline item a child of the given parent outline node. If omitted, it becomes a top-level entry. |
41
+
|`before`|`None`, `TreeObject`, or `IndirectObject`|`None`| Inserts the outline item before another existing outline item at the same level. Used to control ordering. |
42
+
|`color`|`tuple[float, float, float]` or `str`, optional |`None`| Sets the outline text color. Tuples must use 0–1 float values (e.g., `(1, 0, 0)` for red). Some named colors may also be accepted. |
43
+
|`bold`|`bool`|`False`| Displays the outline title in bold. |
44
+
|`italic`|`bool`|`False`| Displays the outline title in italic. |
45
+
|`fit`|`Fit`|`PAGE_FIT`| Determines how the destination page is displayed (Fit, FitH, FitV, FitR, XYZ, etc.). |
46
+
|`is_open`|`bool`|`True`| Controls whether the outline node appears expanded in the PDF viewer when opened. |
47
+
46
48
47
49
### Fit Mode Options
48
50
49
-
| Value | Meaning |
50
-
|--------|---------|
51
-
|`"Fit"`| Display the entire page. |
52
-
|`"FitH"`| Fit to width, aligned at the top. |
53
-
|`"FitV"`| Fit to height. |
54
-
|`"FitR"`| Fit a specific rectangle region. |
55
-
|`"XYZ"`| Use a custom zoom level (`zoom=` required). |
The `add_outline_item()` method may raise the following exceptions:
74
76
75
-
| Exception | When it occurs |
76
-
|-----------------|----------------|
77
-
|`ValueError`| Raised when `page_number` is out of range, `fit` is invalid, or `color` is not a valid `(r, g, b)` tuple (each value must be a float between 0–1). |
78
-
| Internal errors | Occur if an invalid `parent` reference is passed, or if the outline tree becomes corrupted internally. |
77
+
| Exception | When it occurs |
78
+
|---------------|----------------|
79
+
|`ValueError`| Raised when `page_number` is out of range, the `fit` argument is invalid, or when the `color` tuple contains values outside the 0–1 float range. |
80
+
|`TypeError`| Raised when arguments such as `parent`, `before`, or `color` are provided using unsupported types. |
81
+
|`IndexError`| May occur if a referenced page index is not available in the document. |
0 commit comments