Добавить действие закладки
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)