アプリケーションリンクを追加

Contents
[ ]

PDF には、外部アプリケーションを起動するリンクなどのインタラクティブな要素を含めることができます。を使用する PDF コンテンツエディターページ上に長方形の領域を定義して、クリックすると特定の実行ファイルを開くことができます。

  1. PDF コンテンツエディターのインスタンスを作成します。
  2. 入力 PDF ドキュメントをバインドします。
  3. クリック可能なリンクの四角形領域を定義します。
  4. 起動するアプリケーションパスを指定します。
  5. リンクの色を設定します。
  6. 更新した PDF ドキュメントを保存します。
import aspose.pdf.facades as pdf_facades
from aspose.pycore import cast, is_assignable
import aspose.pydrawing as apd
import aspose.pdf as ap

import sys
from os import path

sys.path.append(path.join(path.dirname(__file__), ".."))

from config import set_license, initialize_data_dir


def add_application_link(infile, outfile):
    # Create PdfContentEditor object
    content_editor = pdf_facades.PdfContentEditor()
    # Bind document to PdfContentEditor
    content_editor.bind_pdf(infile)
    # Add application launch link
    content_editor.create_application_link(
        apd.Rectangle(180, 530, 260, 20),
        "notepad.exe",
        1,
        apd.Color.purple,
    )
    # Save updated document
    content_editor.save(outfile)