カスタムアクションリンクを追加
Contents
[
Hide
]
カスタムアクションリンクを使用すると、スクリプトの実行、ページの移動、アプリケーション固有のコマンドの実行など、クリック時に特定のアクションをトリガーできるインタラクティブ領域を PDF に定義できます。を使用する PDF コンテンツエディター、ページ、四角形、色、およびアクションを指定して、カスタムアクションリンクを作成できます。
- PDF コンテンツエディターのインスタンスを作成します。
- 入力 PDF ドキュメントをバインドします。
- クリック可能なリンクの長方形を定義します。
- ページ番号とリンクの色を指定します。
- カスタムアクションを割り当てます (この例では空白)。
- 更新した 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_custom_action_link(infile, outfile):
# Create PdfContentEditor object
content_editor = pdf_facades.PdfContentEditor()
# Bind document to PdfContentEditor
content_editor.bind_pdf(infile)
# Add custom action link. Empty action list keeps the sample runnable
# without requiring additional enum lookups.
content_editor.create_custom_action_link(
apd.Rectangle(200, 500, 260, 20),
1,
apd.Color.dark_red,
[],
)
# Save updated document
content_editor.save(outfile)