Добавить действие закладки

Contents
[ ]

Закладки обеспечивают быстрый переход внутри PDF‑документов. Используя PdfContentEditor, вы можете программно создавать закладки и назначать действия, такие как переход к странице. Вы также можете настраивать внешний вид закладки, включая цвет и варианты стиля, такие как полужирный или курсив.

  1. Создайте объект PdfContentEditor.
  2. Привяжите входной PDF.
  3. Определите свойства закладки.
  4. Назначьте действие закладки.
  5. Сохраните обновлённый 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)