Add Curve Annotation

Contents
[ ]

Curve annotations are used to highlight irregular paths or shapes in a PDF, providing visual emphasis or marking important areas. Using PdfContentEditor, you can draw curves by specifying a sequence of vertices, border style, visibility, annotation rectangle, and descriptive text.

  1. Create the PdfContentEditor object.
  2. Bind the onput PDF.
  3. Configure the Curve properties.
  4. Draw the Curve 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_curve_annotation(infile, outfile):
    # Create PdfContentEditor object
    content_editor = pdf_facades.PdfContentEditor()
    # Bind input PDF file
    content_editor.bind_pdf(infile)

    line_info = pdf_facades.LineInfo()
    line_info.border_style = 1  # 1 - Dashed
    line_info.vertice_coordinate = [120, 520, 160, 560, 220, 540, 280, 580]
    line_info.visibility = True
    content_editor.draw_curve(
        line_info,
        1,
        apd.Rectangle(110, 510, 220, 100),
        "This is curve annotation",
    )

    # Save output PDF file
    content_editor.save(outfile)