Add Local Link
Contents
[
Hide
]
Local links in PDFs allow quick navigation between pages within the same document. Using PdfContentEditor, you can define a clickable rectangle that links one page to another, improving document usability and navigation.
- Create a PdfContentEditor instance.
- Bind the input PDF document.
- Define a rectangle for the clickable local link.
- Specifie the 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_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)