Hapus Semua Gambar dari PDF

Contents
[ ]

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.

  1. Buat objek PdfContentEditor.
  2. Gabungkan PDF input.
  3. Hapus Semua gambar.
  4. 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)