Ajouter des annotations de texte libre

Contents
[ ]

Les annotations de texte libre vous permettent de placer du texte visible directement sur une page PDF sans nécessiter de commentaires contextuels. En utilisant PdfContentEditor, vous pouvez spécifier le rectangle de l’annotation, le texte affiché et la page cible.

  1. Créer le PdfContentEditor objet.
  2. Lier le PDF d’entrée.
  3. Définir la position de l’annotation.
  4. Ajoutez l’annotation de texte libre.
  5. Enregistrer le Document mis à jour.
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_free_text_annotation(infile, outfile):
    # Create PdfContentEditor object
    content_editor = pdf_facades.PdfContentEditor()
    # Bind document to PdfContentEditor
    content_editor.bind_pdf(infile)
    # Add free text annotation to page 1
    content_editor.create_free_text(
        apd.Rectangle(200, 480, 150, 25), "This is a free text annotation", 1
    )
    # Save updated document
    content_editor.save(outfile)