添加线注释
Contents
[
Hide
]
线注释对于强调文本、突出关系或吸引对 PDF 中特定区域的注意很有用。使用 PdfContentEditor,您可以通过指定起点和终点、边界矩形、颜色、边框样式和线端点,以编程方式创建线注释。
- 创建 PdfContentEditor 对象。
- 绑定输入 PDF。
- 定义线注释属性。
- 添加线注释。
- 保存已更新的 Document。
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_line_annotation(infile, outfile):
# Create PdfContentEditor object
content_editor = pdf_facades.PdfContentEditor()
# Bind input PDF file
content_editor.bind_pdf(infile)
# Create LineAnnotation object
rect = apd.Rectangle(100, 100, 200, 200)
contents = "This is line annotation"
content_editor.create_line(
rect,
contents,
100,
100,
200,
200,
1,
1,
apd.Color.red,
"Solid",
[3, 2],
["Square"],
)
# Save output PDF file
content_editor.save(outfile)