Delete All Images from PDF
Contents
[
Hide
]
PDF documents often contain images for illustrations, branding, or decoration. There may be cases where you need to remove all images from a PDF, such as reducing file size, protecting sensitive visuals, or preparing a text-only version.
Using PdfContentEditor, you can programmatically remove all images from a PDF, ensuring the document only contains textual content. This example binds an input PDF, deletes all images, and saves the modified file.
- Create the PdfContentEditor object.
- Bind the input PDF.
- Delete All images.
- Save the updated Document.
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)