添加插入符号注释

Contents
[ ]

插入符号注释通常用于指示文档中的文字插入或编辑性评论。使用 PdfContentEditor,您可以通过指定页码、注释边界、指示区、符号、备注文字和颜色,以编程方式添加插入符号注释。

  1. 创建 PdfContentEditor 对象。
  2. 绑定输入 PDF。
  3. 定义插入符号注释参数:
  • 将添加注释的页码
  • 插入符号矩形(注释位置)
  • 呼出矩形(文本区域)
  • 符号(例如 “P”)
  • 批注文本
  • 批注颜色
  1. 添加插入符号批注。
  2. 保存已更新的 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_caret_annotation(infile, outfile):
    # Create PdfContentEditor object
    content_editor = pdf_facades.PdfContentEditor()
    # Bind document to PdfContentEditor
    content_editor.bind_pdf(infile)
    # Add caret annotation to page 1
    content_editor.create_caret(
        1,
        apd.Rectangle(350, 400, 10, 10),
        apd.Rectangle(300, 380, 115, 15),
        "P",
        "This is a caret annotation",
        apd.Color.red,
    )
    # Save updated document
    content_editor.save(outfile)