경로에서 첨부 파일 추가
Contents
[
Hide
]
PDF에는 참조 또는 배포용 문서, 스프레드시트 또는 이미지와 같은 내장 파일이 포함될 수 있습니다.‘add_document_attachment () ‘의 파일 경로 오버로드를 사용하면 파일 경로에서 직접 첨부 파일을 추가할 수 있으므로 파일을 수동으로 열 필요가 없습니다.
- 생성하기 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 add_attachment_from_path(infile, attachment_file, outfile):
# Create PdfContentEditor object
content_editor = pdf_facades.PdfContentEditor()
# Bind document to PdfContentEditor
content_editor.bind_pdf(infile)
# Add attachment using file-path overload
content_editor.add_document_attachment(
attachment_file,
"Attachment added using file path overload.",
)
# Save updated document
content_editor.save(outfile)