Delete Stamp By Index
Contents
[
Hide
]
When multiple rubber stamps exist on a page, you can delete a specific one using its index. The delete_stamp() method allows removing annotations according to their sequence, which is useful when you don’t track stamp IDs but know their order.
- Create a PdfContentEditor instance.
- Bind the input PDF document.
- Bind the input PDF file to the PdfContentEditor instance using bind_pdf(infile).
- Call ‘delete_stamp(1, [2, 3])’ to remove the stamp with index 1 from pages 2 and 3.
- Save the modified PDF document to the output file using save(outfile).
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 delete_stamp_by_index(infile, outfile):
# Create PdfContentEditor object
content_editor = pdf_facades.PdfContentEditor()
# Bind document to PdfContentEditor
content_editor.bind_pdf(infile)
content_editor.delete_stamp(1, [2, 3])
# Save updated document
content_editor.save(outfile)