添付ファイルを削除
Contents
[
Hide
]
PDF には、文書、画像、その他のファイルなどの添付ファイルが含まれている場合があります。セキュリティ、プライバシー、または配布を目的として、PDF からすべての添付ファイルを削除する必要がある場合があります。を使用する PDF コンテンツエディター、ドキュメントに埋め込まれたすべての添付ファイルをプログラムで削除できます。
- PDF コンテンツエディターオブジェクトを作成します。
- 入力 PDF をバインドします。
- 添付ファイルをすべて削除します。
- 更新したドキュメントを保存します。
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)