ローカルリンクを追加

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_local_link(infile, outfile):
    # Create PdfContentEditor object
    content_editor = pdf_facades.PdfContentEditor()
    # Bind document to PdfContentEditor
    content_editor.bind_pdf(infile)
    # Add a local link on page 1 to destination page 1
    content_editor.create_local_link(
        apd.Rectangle(120, 620, 220, 20),
        1,
        1,
        apd.Color.red,
    )
    # Save updated document
    content_editor.save(outfile)