PDF からすべての画像を削除
Contents
[
Hide
]
PDF ドキュメントには、多くの場合、イラスト、ブランディング、または装飾用の画像が含まれています。ファイルサイズを小さくする、センシティブな画像を保護する、テキストのみのバージョンを用意するなど、PDF からすべての画像を削除する必要がある場合があります。
使用する PDF コンテンツエディター、PDF からすべての画像をプログラムで削除して、文書にテキストコンテンツのみを含めることができます。この例では、入力 PDF をバインドし、すべての画像を削除して、変更したファイルを保存します。
- PDF コンテンツエディターオブジェクトを作成します。
- 入力 PDF をバインドします。
- すべての画像を削除します。
- 更新したドキュメントを保存します。
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)