Ganti Gambar dalam PDF
Contents
[
Hide
]
PDF sering berisi gambar yang mungkin perlu diperbarui atau diganti, seperti logo, diagram, atau foto. Dengan PdfContentEditor, Anda dapat mengganti gambar tertentu pada halaman tertentu dengan memberikan nomor halaman, indeks gambar, dan jalur file gambar baru.
- Buat instance PdfContentEditor.
- Hubungkan dokumen PDF masukan.
- Ganti gambar tertentu pada halaman yang diberikan.
- Simpan dokumen PDF yang diperbarui.
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)