Add Popup Annotations

Contents
[ ]

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.

  1. Create the PdfContentEditor object.
  2. Bind the input PDF.
  3. Define the Popup Annotation rectangle.
  4. Add the Popup Annotation.
  5. 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)