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は、単一の操作でPDFドキュメントにHTML、テキスト、画像、バーコードの複数の異なるスタンプを適用できます。

開始方法

各スタンプタイプに個別のスタンパーオブジェクトを作成しList[Stamper] コレクションに追加し、ApplyMultipleStampsを呼び出して、すべてのスタンプを一度に適用します。

コードの理解

  • HtmlStamper(html): HTMLフラグメントをPDFにスタンプします。 ピクセルベースのVerticalOffset と HorizontalOffset をサポートします。
  • TextStamper(text): カスタムフォント設定を使用してプレーンテキストをスタンプします。 任意のGoogleフォントを名前で使用するためにFontFamilyを設定します。
  • ImageStamper(path): 画像ファイルをPDFにスタンプします。 MinWidth と MinHeightを使用してスタンプの寸法を制御します。
  • BarcodeStamper(value, encoding): バーコードまたはQRコードを生成しスタンプします。 BarcodeEncoding.Code39は標準のコード39バーコードを生成します。
  • List[Stamper](): 異なるタイプのスタンパーオブジェクトを保持する型付きコレクション。
  • ApplyMultipleStamps(stamps_list): ドキュメントのすべてのページにリスト内のスタンプを1度の効率的なパスで適用します。

配置と位置決め

各スタンパーは VerticalOffset、および HorizontalOffset をサポートしてページ上に正確に配置します。

IronPDF for PythonでPDFにスタンプを押す方法を学びましょう!

準備はできましたか?

バージョン:2026.11リリースされたばかり