按索引删除印章
Contents
[
Hide
]
当页面上存在多个橡皮图章时,您可以使用其索引删除特定的图章。delete_stamp() 方法允许按照顺序删除注释,这在您不跟踪印章 ID 但知道其顺序时非常有用。
- 创建一个 PdfContentEditor 实例。
- 绑定输入的 PDF 文档。
- 使用 bind_pdf(infile) 将输入 PDF 文件绑定到 PdfContentEditor 实例。
- 调用 ‘delete_stamp(1, [2, 3])’ 来删除索引为 1 的印章,在第 2 页和第 3 页。
- 使用 save(outfile) 将修改后的 PDF 文档保存到输出文件。
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)