pdf.add_bookmark
result = pdf.add_bookmark(src, title, page_index, parent=)
Input: src, title, page_index, parent · Output: result
What it is
Adds a new outline entry titled title, pointing at page_index (one-based). parent= (optional Num) nests it under an existing entry, named by the index column of a prior pdf.outlines(src) call on THIS document — the one stable handle to an existing entry this module exposes. Omitted, the new entry is top-level.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = pdf.add_bookmark(src, title, page_index, parent=) | src Numparent= (optional Num) nests it under an existing entry, named by the index column of a prior pdf.outlines(src) call on THIS document — the one stable handle to an existing entry this module exposes.title —Adds a new outline entry titled title, pointing at page_index (one-based).page_index —Adds a new outline entry titled title, pointing at page_index (one-based).parent Numparent= (optional Num) nests it under an existing entry, named by the index column of a prior pdf.outlines(src) call on THIS document — the one stable handle to an existing entry this module exposes. | result Vec | Returns a Vec of bytes, the new PDF. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
import pdf
doc = pdf.merge(["intro.pdf", "results.pdf"])
doc = pdf.add_bookmark(doc, "Introduction", 1)
doc = pdf.add_bookmark(doc, "Results", 3)
rows = pdf.outlines(doc)
print(rows) # index, level, parent_index, title, page_index
doc = pdf.add_annotation(doc, 1, type = "Text", rect = [10, 10, 200, 40], text = "draft")
doc = pdf.add_attachment(doc, "notes.txt", "notes.txt")
pdf.write_pages("with_extras.pdf", doc, 1 to pdf.page_count(doc))
not run by the build — this one needs something the repository cannot supply · from file-io