添加 PDF 文档链接
Contents
[
Hide
]
PDF 文档链接允许用户无缝地从一个 PDF 导航到另一个 PDF。使用 PdfContentEditor, 您可以定义一个可点击的矩形,链接到另一个 PDF 文件中的页面,使您的文档具有交互性并相互连接。
- 创建一个 PdfContentEditor 实例。
- 绑定输入的 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_pdf_document_link(infile, linked_pdf, outfile):
# Create PdfContentEditor object
content_editor = pdf_facades.PdfContentEditor()
# Bind document to PdfContentEditor
content_editor.bind_pdf(infile)
# Add link to another PDF document
content_editor.create_pdf_document_link(
apd.Rectangle(140, 590, 240, 20),
linked_pdf,
1,
1,
apd.Color.green,
)
# Save updated document
content_editor.save(outfile)