ポリライン注釈を追加

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_polyline_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 = [120, 420, 180, 460, 230, 430, 290, 470]
    content_editor.create_poly_line(
        line_info,
        1,
        apd.Rectangle(110, 410, 200, 90),
        "This is polyline annotation",
    )

    # Save output PDF file
    content_editor.save(outfile)