Add Popup Annotations
Contents
[
Hide
]
Popup annotations are useful for adding comments, explanations, or interactive notes in PDF files. Using PdfContentEditor, you can create popup annotations programmatically by specifying the location, content, visibility, and page number.
- Create the PdfContentEditor object.
- Bind the input PDF.
- Define the Popup Annotation rectangle.
- Add the Popup Annotation.
- Save the updated Document.
import aspose.pdf as ap
import aspose.pdf.facades as pdf_facades
import aspose.pydrawing as apd
import sys
from os import path
sys.path.append(path.join(path.dirname(__file__), ".."))
from config import set_license, initialize_data_dir
def add_popup_annotation(infile, outfile):
# Create PdfContentEditor object
content_editor = pdf_facades.PdfContentEditor()
# Bind document to PdfContentEditor
content_editor.bind_pdf(infile)
# Add popup annotation to page 1
content_editor.create_popup(
apd.Rectangle(220, 520, 180, 80),
"This is a popup annotation",
True,
1,
)
# Save updated document
content_editor.save(outfile)