Hapus Semua Gambar dari PDF
Contents
[
Hide
]
Dokumen PDF sering berisi gambar untuk ilustrasi, branding, atau dekorasi. Mungkin ada situasi di mana Anda perlu menghapus semua gambar dari PDF, seperti mengurangi ukuran file, melindungi visual sensitif, atau menyiapkan versi hanya teks.
Menggunakan PdfContentEditor, Anda dapat secara programatis menghapus semua gambar dari PDF, memastikan dokumen hanya berisi konten teks. Contoh ini mengikat PDF input, menghapus semua gambar, dan menyimpan file yang dimodifikasi.
- Buat objek PdfContentEditor.
- Gabungkan PDF input.
- Hapus Semua gambar.
- Simpan Document 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 delete_all_image(infile, outfile):
# Create PdfContentEditor object
content_editor = pdf_facades.PdfContentEditor()
# Bind document to PdfContentEditor
content_editor.bind_pdf(infile)
# Delete all images from the document
content_editor.delete_image()
# Save updated document
content_editor.save(outfile)