添加应用链接
Contents
[
Hide
]
PDF 可以包含交互式元素,例如启动外部应用程序的链接。使用 PdfContentEditor,您可以在页面上定义一个矩形区域,点击后打开特定的可执行文件。
- 创建一个 PdfContentEditor 实例。
- 绑定输入的 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_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)