Hapus Lampiran

Contents
[ ]

PDF dapat berisi lampiran seperti dokumen, gambar, atau file lainnya. Ada skenario di mana Anda perlu membersihkan PDF dari semua lampiran untuk tujuan keamanan, privasi, atau distribusi. Menggunakan PdfContentEditor, Anda dapat secara programatis menghapus semua lampiran yang tersemat dalam dokumen.

  1. Buat objek PdfContentEditor.
  2. Gabungkan PDF input.
  3. Hapus Semua Lampiran.
  4. Simpan Document yang diperbarui.
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 remove_attachments(infile, outfile):
    # Create PdfContentEditor object
    content_editor = pdf_facades.PdfContentEditor()
    # Bind document to PdfContentEditor
    content_editor.bind_pdf(infile)
    # Remove all attachments from document
    content_editor.delete_attachments()
    # Save updated document
    content_editor.save(outfile)