添加书签操作
Contents
[
Hide
]
书签提供了在 PDF 文档内快速导航的功能。使用 PdfContentEditor,您可以以程序方式创建书签并分配诸如导航至页面的操作。您还可以自定义书签的外观,包括颜色以及粗体或斜体等样式选项。
- 创建 PdfContentEditor 对象。
- 绑定输入 PDF。
- 定义书签属性。
- 分配书签操作。
- 保存已更新的 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)