添加文件附件注释
Contents
[
Hide
]
文件附件注释允许您将外部文件嵌入为 PDF 页面上的交互式图标。使用文件路径重载,您可以直接从磁盘附加文件,而无需手动打开流。此方法还允许您自定义注释图标并为用户提供描述。
- 创建 PdfContentEditor 对象。
- 绑定输入 PDF。
- 定义注释矩形。
- 添加文件附件注释。
- 保存已更新的 Document。
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_file_attachment_annotation(infile, attachment_file, outfile):
# Create PdfContentEditor object
content_editor = pdf_facades.PdfContentEditor()
# Bind document to PdfContentEditor
content_editor.bind_pdf(infile)
# Create file attachment annotation on page 1
content_editor.create_file_attachment(
apd.Rectangle(100, 520, 20, 20),
"Attachment annotation contents",
attachment_file,
1,
"PushPin",
)
# Save updated document
content_editor.save(outfile)