색인별 스탬프 이동

Contents
[ ]

PDF 편집에서는 기존 러버 스탬프의 위치를 조정해야 할 수 있습니다.이 코드 스니펫은 다음과 같은 방법을 보여줍니다.

  • 같은 페이지에 여러 스탬프 추가
  • 색인을 사용하여 위치를 변경할 수 있도록 준비하십시오.
  • 페이지, 색인 및 새 좌표를 지정하여 스탬프를 이동할 수도 있습니다.

‘move_stamp (페이지_번호, 스탬프_인덱스, new_x, new_y) ‘메서드는 스탬프를 정확하게 재배치할 수 있습니다.

  1. 만들기 PDF 콘텐츠 편집기 목적.
  2. PDF를 편집기에 바인딩합니다.
  3. 페이지에 여러 개의 러버 스탬프를 추가합니다.
  4. 이동 작업을 수행하기 전에 문서를 저장합니다.
  5. 인덱스별로 특정 스탬프를 이동합니다.
  6. 업데이트된 PDF를 저장합니다.
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)