Добавить аннотацию полигога
Contents
[
Hide
]
Аннотации полигона используются для выделения неправильных областей или форм в PDF, обеспечивая визуальное акцентирование или маркировку конкретных регионов. Используя PdfContentEditor, вы можете создавать полигоны, указывая координаты вершин, стиль границы, номер страницы и прямоугольник аннотации.
- Создайте объект PdfContentEditor.
- Привяжите входной PDF.
- Настройте свойства Polygon.
- Добавьте аннотацию Polygon.
- Сохраните обновлённый 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_polygon_annotation(infile, outfile):
# Create PdfContentEditor object
content_editor = pdf_facades.PdfContentEditor()
# Bind input PDF file
content_editor.bind_pdf(infile)
line_info = pdf_facades.LineInfo()
line_info.border_style = 0 # 0 - Solid
line_info.vertice_coordinate = [100, 200, 150, 260, 220, 220, 200, 160]
content_editor.create_polygon(
line_info,
1,
apd.Rectangle(90, 150, 150, 120),
"This is polygon annotation",
)
# Save output PDF file
content_editor.save(outfile)