Add PDF Document Link
Contents
[
Hide
]
PDF document links allow users to navigate from one PDF to another seamlessly. Using PdfContentEditor, you can define a clickable rectangle that links to a page in a different PDF file, making your documents interactive and connected.
- Create a PdfContentEditor instance.
- Bind the input PDF document.
- Define a rectangle for the clickable link.
- Specifie the linked PDF file, source page, and destination page.
- 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_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)