Tambahkan Anotasi Poligon
Contents
[
Hide
]
Anotasi poligon digunakan untuk menyorot area atau bentuk tidak beraturan dalam PDF, memberikan penekanan visual atau menandai wilayah tertentu. Menggunakan PdfContentEditor, Anda dapat membuat poligon dengan menentukan koordinat verteks, gaya batas, nomor halaman, dan persegi panjang anotasi.
- Buat objek PdfContentEditor.
- Gabungkan PDF input.
- Konfigurasikan properti Polygon.
- Tambahkan anotasi Polygon.
- Simpan Document yang diperbarui.
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)