HTML 콘텐츠를 효율적으로 추가하는 방법
from ironpdf import *

# Use HtmlStamper to stamp Html onto pdf
htmlStamper = HtmlStamper("<h1>Html stamp</h1>")
htmlStamper.VerticalOffset = Length(-200, MeasurementUnit.Pixel)
htmlStamper.HorizontalOffset = Length(-200, MeasurementUnit.Pixel)

# Use TextStamper to stamp text with custom font onto pdf
textStamper = TextStamper("Hello World! Stamp One Here!")
textStamper.FontFamily = "Bungee Spice"
textStamper.UseGoogleFont = True
textStamper.FontSize = 30

# Use ImageStamper to stamp images onto pdf
file_path = r'C:\Users\logo.png'
imageStamper = ImageStamper(file_path)
imageStamper.VerticalAlignment = VerticalAlignment.Top
imageStamper.MinWidth = Length(20)
imageStamper.MinHeight = Length(20)

# Use BarcodeStamper to stamp QR code/Barcode onto pdf
barcodeStamper = BarcodeStamper("IronPDF", BarcodeEncoding.Code39)
barcodeStamper.MaxHeight = Length(5)
barcodeStamper.VerticalAlignment = VerticalAlignment.Bottom
barcodeStamper.HorizontalAlignment = HorizontalAlignment.Left

stamps_list = List[Stamper]()
stamps_list.Add(htmlStamper)
stamps_list.Add(textStamper)
stamps_list.Add(imageStamper)
stamps_list.Add(barcodeStamper)

pdf = PdfDocument.FromFile("Unstamped.pdf")
pdf.ApplyMultipleStamps(stamps_list)
pdf.SaveAs("Stamped.pdf")
pip install ironpdf
HTML 콘텐츠를 효율적으로 추가하는 방법

HTML 콘텐츠를 효율적으로 추가하는 방법

IronPDF for Python은 ApplyMultipleStamps을 사용하여 단일 작업에서 PDF 문서에 HTML, 텍스트, 이미지, 바코드 등 다양한 스탬프를 추가할 수 있습니다.

시작하기

각 스탬프 유형에 대한 개별 스탬퍼 객체를 만들고, 이를 List[Stamper] 컬렉션에 추가한 후, 모든 스탬프를 한 번에 적용하기 위해 ApplyMultipleStamps을 PdfDocument에서 호출합니다.

코드 이해하기

  • HtmlStamper(html): PDF에 HTML 조각을 스탬프합니다. VerticalOffset 및 HorizontalOffset을 지원하여 픽셀 기준 Length 값을 사용하여 위치를 세밀하게 조정합니다.
  • TextStamper(text): 사용자 정의 글꼴 설정으로 일반 텍스트를 스탬프합니다. UseGoogleFont = True 및 FontFamily을 설정하여 이름으로 Google Font를 사용할 수 있습니다.
  • ImageStamper(path): PDF에 이미지 파일을 스탬프합니다. MinWidth 및 MinHeight을 사용하여 스탬프의 크기를 제어하세요.
  • BarcodeStamper(value, encoding): 바코드 또는 QR 코드를 생성하고 스탬프합니다. BarcodeEncoding.Code39은 표준 Code 39 바코드를 생성합니다.
  • List[Stamper](): 혼합 유형의 스탬퍼 객체를 관리하는 형식화된 컬렉션.
  • ApplyMultipleStamps(stamps_list): 목록의 모든 스탬프를 문서의 모든 페이지에 한 번에 효율적으로 적용합니다.

정렬 및 위치 조정

각 스탬퍼는 페이지에 정확하게 위치할 수 있도록 VerticalAlignment, HorizontalAlignment, VerticalOffset, 그리고 HorizontalOffset을 지원합니다.

IronPDF for Python으로 PDF에 스탬프를 찍는 방법을 배우세요!

시작할 준비 되셨나요?

버전:2026.11방금 출시