Add Bookmark Action
Contents
[
Hide
]
Bookmarks provide quick navigation within PDF documents. Using PdfContentEditor, you can programmatically create bookmarks and assign actions such as navigating to a page. You can also customize the bookmark appearance, including color and style options like bold or italic.
- Create the PdfContentEditor object.
- Bind the input PDF.
- Define Bookmark properties.
- Assign Bookmark action.
- Save the updated Document.
import aspose.pdf.facades as pdf_facades
import aspose.pydrawing as apd
import sys
from os import path
sys.path.append(path.join(path.dirname(__file__), ".."))
from config import set_license, initialize_data_dir
def add_bookmark_action(infile, outfile):
# Create PdfContentEditor object
content_editor = pdf_facades.PdfContentEditor()
# Bind document to PdfContentEditor
content_editor.bind_pdf(infile)
# Add a bookmark action to navigate to page 1
content_editor.create_bookmarks_action(
"PdfContentEditor Bookmark",
apd.Color.blue,
True,
False,
"",
"GoTo",
"1",
)
# Save updated document
content_editor.save(outfile)