PDF 内の画像の置換
Contents
[
Hide
]
PDF には、ロゴ、図、写真など、更新や置換が必要な画像が含まれていることがよくあります。と PDF コンテンツエディターページ番号、画像インデックス、および新しい画像ファイルパスを指定することで、特定のページの特定の画像を置き換えることができます。
- PDF コンテンツエディターのインスタンスを作成します。
- 入力 PDF ドキュメントをバインドします。
- 特定のページの特定の画像を置き換えます。
- 更新した PDF ドキュメントを保存します。
import aspose.pdf.facades as pdf_facades
import sys
from os import path
sys.path.append(path.join(path.dirname(__file__), ".."))
from config import set_license, initialize_data_dir
def replace_image(infile, image_file, outfile):
# Create PdfContentEditor object
content_editor = pdf_facades.PdfContentEditor()
# Bind document to PdfContentEditor
content_editor.bind_pdf(infile)
# Replace image on page 1
content_editor.replace_image(1, 1, image_file)
# Save updated document
content_editor.save(outfile)