List Stamps
Contents
[
Hide
]
When working with annotated PDFs, you may need to inspect existing rubber stamps before modifying or removing them. The ‘get_stamps()’ method allows you to retrieve all stamps placed on a particular page. You can then iterate through the results and process them programmatically.
- Create a PdfContentEditor instance.
- Bind the input PDF document.
- Retrieve all stamps from page 1.
- Iterate through the stamp collection.
- Print each stamp.
- Display a message if no stamps exist.
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 list_stamps(infile):
# Create PdfContentEditor object
content_editor = pdf_facades.PdfContentEditor()
# Bind document to PdfContentEditor
content_editor.bind_pdf(infile)
# List all stamps on page 1
stamps = content_editor.get_stamps(1)
count = 0
for stamp in stamps:
count += 1
print(f"Stamp {count}: {stamp}")
if count == 0:
print("No stamps found")