添加弹出注释

Contents
[ ]

弹出注释可用于在 PDF 文件中添加评论、解释或交互式注释。使用 PdfContentEditor, 您可以通过指定位置、内容、可见性和页码以编程方式创建弹出注释。

  1. 创建 PdfContentEditor 对象。
  2. 绑定输入 PDF。
  3. 定义弹出注释矩形。
  4. 添加弹出注释。
  5. 保存已更新的 Document。
import aspose.pdf as ap
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_popup_annotation(infile, outfile):
    # Create PdfContentEditor object
    content_editor = pdf_facades.PdfContentEditor()
    # Bind document to PdfContentEditor
    content_editor.bind_pdf(infile)
    # Add popup annotation to page 1
    content_editor.create_popup(
        apd.Rectangle(220, 520, 180, 80),
        "This is a popup annotation",
        True,
        1,
    )
    # Save updated document
    content_editor.save(outfile)