添加文本注释
Contents
[
Hide
]
本文展示了如何使用 PdfContentEditor Aspose.PDF 中的类。
文本批注允许您将评论、注释或额外信息附加到 PDF 页面上的特定位置。这些批注可以以图标形式出现,并在用户查看文档时展开。
在此示例中:
- 将 PDF 文档加载到 PdfContentEditor 中。
- 在页面的特定位置添加文本注释。
- 该注释包括标题、内容、图标类型和可见性设置。
- 修改后的文档保存为新文件。
- 创建一个 PdfContentEditor 对象。
- 绑定输入 PDF 文档。
- 定义注释位置。
- 添加文本注释。
- 保存更新后的 PDF。
import aspose.pdf as ap
import aspose.pdf.facades as pdf_facades
import aspose.pydrawing as apd
import sys
from os import path
sys.path.append(path.join(path.dirname(__file__), ".."))
from config import set_license, initialize_data_dir
def add_text_annotation(infile, outfile):
# Create PdfContentEditor object
content_editor = pdf_facades.PdfContentEditor()
# Bind document to PdfContentEditor
content_editor.bind_pdf(infile)
# Add text annotation to page 1
content_editor.create_text(
apd.Rectangle(100, 400, 50, 50),
"Text Annotation",
"This is a text annotation",
True,
"Insert",
1,
)
# Save updated document
content_editor.save(outfile)