Agregar anotación de línea
Contents
[
Hide
]
Las anotaciones de línea son útiles para enfatizar texto, resaltar relaciones o llamar la atención sobre áreas específicas en un PDF. Con PdfContentEditor, puedes crear programáticamente anotaciones de línea especificando los puntos de inicio y fin, el rectángulo delimitador, el color, el estilo de borde y las terminaciones de línea.
- Crear el objeto PdfContentEditor.
- Vincular el PDF de entrada.
- Definir propiedades de la anotación de línea.
- Agregar la anotación de línea.
- Guarda el Documento actualizado.
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)