添加自由文本批注

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_free_text_annotation(infile, outfile):
    # Create PdfContentEditor object
    content_editor = pdf_facades.PdfContentEditor()
    # Bind document to PdfContentEditor
    content_editor.bind_pdf(infile)
    # Add free text annotation to page 1
    content_editor.create_free_text(
        apd.Rectangle(200, 480, 150, 25), "This is a free text annotation", 1
    )
    # Save updated document
    content_editor.save(outfile)