Mover sello por índice

Contents
[ ]

Cuando existen varios sellos de caucho en una página, puedes mover uno específico usando su índice. El método move_stamp() permite reposicionar anotaciones según su secuencia, lo cual es útil cuando no rastreas los IDs de los sellos pero conoces su orden.

  1. Crear un PdfContentEditor instancia.
  2. Vincula el documento PDF de entrada.
  3. Agregar dos anotaciones de sello de caucho en la misma página.
  4. Demostrar cómo mover un sello usando su índice.
  5. Guarda el documento PDF actualizado.
import aspose.pdf.facades as pdf_facades
import aspose.pydrawing as apd
from io import BytesIO
import sys
from os import path

sys.path.append(path.join(path.dirname(__file__), ".."))

from config import set_license, initialize_data_dir


def move_stamp_by_index(infile, outfile):
    # Create PdfContentEditor object
    content_editor = pdf_facades.PdfContentEditor()
    # Bind document to PdfContentEditor
    content_editor.bind_pdf(infile)

    content_editor.create_rubber_stamp(
        2,
        apd.Rectangle(200, 380, 180, 60),
        "Draft",
        "Draft stamp for ID-based operations",
        apd.Color.orange,
    )

    content_editor.create_rubber_stamp(
        2,
        apd.Rectangle(200, 480, 180, 60),
        "Draft",
        "Draft stamp for ID-based operations",
        apd.Color.orange,
    )
    content_editor.save(outfile)

    # Move first stamp on page 1 by index
    # content_editor.move_stamp(1, 1, 10, 10)
    # Save updated document
    content_editor.save(outfile)