ライン注釈を追加

Contents
[ ]

ライン注釈は、テキストを強調したり、関係を強調したり、PDF 内の特定の領域に注意を引いたりするのに便利です。と PDF コンテンツエディター、始点と終点、境界矩形、色、境界スタイル、および行末を指定することで、プログラムで線注釈を作成できます。

  1. PDF コンテンツエディターオブジェクトを作成します。
  2. 入力 PDF をバインドします。
  3. ライン注釈プロパティを定義します。
  4. Line アノテーションを追加します。
  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_line_annotation(infile, outfile):
    # Create PdfContentEditor object
    content_editor = pdf_facades.PdfContentEditor()
    # Bind input PDF file
    content_editor.bind_pdf(infile)

    # Create LineAnnotation object
    rect = apd.Rectangle(100, 100, 200, 200)
    contents = "This is line annotation"
    content_editor.create_line(
        rect,
        contents,
        100,
        100,
        200,
        200,
        1,
        1,
        apd.Color.red,
        "Solid",
        [3, 2],
        ["Square"],
    )

    # Save output PDF file
    content_editor.save(outfile)