添加方形注释

Contents
[ ]

方形批注通常用于突出显示感兴趣的区域、标记重要章节或在 PDF 文档中提供视觉提示。Using 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_square_annotation(infile, outfile):
    # Create PdfContentEditor object
    content_editor = pdf_facades.PdfContentEditor()
    # Bind input PDF file
    content_editor.bind_pdf(infile)

    # Create SquareAnnotation object
    rect = apd.Rectangle(100, 300, 200, 400)
    contents = "This is square annotation"
    content_editor.create_square_circle(rect, contents, apd.Color.blue, True, 1, 3)

    # Save output PDF file
    content_editor.save(outfile)