通过 ID 移动印章
Contents
[
Hide
]
在 PDF 中添加橡胶印章注释后,可能需要调整其位置。‘move_stamp_by_id()’ 方法允许您基于标识符重新定位印章,而无需重新创建。这在需要动态调整印章放置的自动化工作流中非常有用。
- 创建一个 PdfContentEditor 实例。
- 绑定输入的 PDF 文档。
- 添加橡胶印章注释。
- 使用其 ID 移动印章。
- 保存更新后的 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 move_stamp_by_id_example(infile, outfile):
# Create PdfContentEditor object
content_editor = pdf_facades.PdfContentEditor()
# Bind document to PdfContentEditor
content_editor.bind_pdf(infile)
content_editor.create_rubber_stamp(
1,
apd.Rectangle(300, 420, 180, 60),
"Approved",
"Move this stamp by ID",
apd.Color.green,
)
# Move stamp by ID overload
content_editor.move_stamp_by_id(1, 1, 240, 360)
# Save updated document
content_editor.save(outfile)