Add Rubber Stamp

Contents
[ ]

Rubber stamp annotations are commonly used in PDFs to indicate approval, review status, or other notes. Using PdfContentEditor, you can define a rectangle for the stamp, set its text and comments, choose a color, and apply it to multiple pages of a document.

  1. Create a PdfContentEditor instance.
  2. Bind the input PDF document.
  3. Loop through pages 1–4.
  4. Add a rubber stamp annotation with custom text, comments, and color.
  5. Save the updated PDF document.
import aspose.pdf.facades as pdf_facades
import aspose.pydrawing as apd
from io import BytesIO
import sys
from os import path

sys.path.append(path.join(path.dirname(__file__), ".."))

from config import set_license, initialize_data_dir


def add_rubber_stamp(infile, outfile):
    # Create PdfContentEditor object
    content_editor = pdf_facades.PdfContentEditor()
    # Bind document to PdfContentEditor
    content_editor.bind_pdf(infile)

    for i in range(1, 5):
        content_editor.create_rubber_stamp(
            i,
            apd.Rectangle(120, 450, 180, 60),
            "Approved",
            "Approved by reviewer",
            apd.Color.green,
        )
    # Save updated document
    content_editor.save(outfile)