Add Application Link
Contents
[
Hide
]
PDF can include interactive elements such as links that launch external applications. Using PdfContentEditor, you can define a rectangular region on a page that, when clicked, opens a specific executable file.
- Create a PdfContentEditor instance.
- Bind the input PDF document.
- Define a rectangle area for the clickable link.
- Specifie the application path to launch.
- Set the link color.
- Save the updated PDF document.
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)