ポリゴン注釈を追加

Contents
[ ]

ポリゴン注釈は、PDF内の不規則な領域や形状を強調表示したり、視覚的に強調したり、特定の領域をマークしたりするために使用されます。を使う PDF コンテンツエディター、頂点座標、境界線のスタイル、ページ番号、および注釈長方形を指定してポリゴンを作成できます。

  1. PDF コンテンツエディターオブジェクトを作成します。
  2. 入力 PDF をバインドします。
  3. ポリゴンのプロパティを設定します。
  4. ポリゴンアノテーションを追加します。
  5. 更新したドキュメントを保存します。
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_polygon_annotation(infile, outfile):
    # Create PdfContentEditor object
    content_editor = pdf_facades.PdfContentEditor()
    # Bind input PDF file
    content_editor.bind_pdf(infile)

    line_info = pdf_facades.LineInfo()
    line_info.border_style = 0  # 0 - Solid
    line_info.vertice_coordinate = [100, 200, 150, 260, 220, 220, 200, 160]
    content_editor.create_polygon(
        line_info,
        1,
        apd.Rectangle(90, 150, 150, 120),
        "This is polygon annotation",
    )

    # Save output PDF file
    content_editor.save(outfile)