IRONSOFTWAREHOME
高效新增 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 將多個不同的印章——HTML、文字、圖像和條碼——應用於PDF文件。

入門指南

為每種型別的印章建立個別的印章物件,將它們新增到 List[Stamper] 集合中,然後在 PdfDocument 上調用 ApplyMultipleStamps 以一次性應用所有印章。

理解程式碼

  • HtmlStamper(html):將HTML片段印在PDF上。 支援 VerticalOffset 和 HorizontalOffset 來微調位置,使用基於像素的 Length 值。
  • TextStamper(text):用自定義字體設置印文字。 設置 UseGoogleFont = True 和 FontFamily 以使用任何名稱的Google字體。
  • ImageStamper(path):將圖像檔案印在PDF上。 使用 MinWidth 和 MinHeight 控制印章尺寸。
  • BarcodeStamper(value, encoding):生成並印製條碼或QR碼。 BarcodeEncoding.Code39 生成標準的Code 39條碼。
  • List[Stamper]():一個型別化的集合,持有混合型別的印章物件。
  • ApplyMultipleStamps(stamps_list):在一次高效的操作中將清單中的所有印章應用到文件的每一頁。

對齊和定位

每個印章支援 VerticalOffset 和 HorizontalOffset 以便在頁面上精確放置。

學習如何使用 IronPDF for Python 在PDF上印製印章!

準備開始了嗎?

版本:2026.9剛剛發布

Key in blue circle

立即免費取得 30 天試用金鑰。

Your trial license will be sent to your email address

無任何限制。100% 解鎖。無需信用卡。

OR
bullet_checked無需信用卡或建立帳號無任何限制。100% 解鎖。無需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
預約您的免費即時演示
Booking Badge

全球數百萬工程師的信賴

Iron Software的客戶標誌
獲取您的無義務諮詢
填寫以下表格或發送電子郵件至sales@ironsoftware.com
您的詳細資訊將始終保密。
全球數百萬工程師的信賴
Iron Software的客戶標誌
立即獲取您的30天試用金鑰。
無需信用卡或帳戶建立
PDF的Python模塊下載
使用pip安裝

版本: 2026.9

  1. 下載並安裝Python 3.7+。
  2. 如果尚未安裝,請從 pypi.org 安裝 pip。
  3. 在終端執行上述命令。
Python PDF模塊
下載模塊

版本: 2026.9

手動安裝到您的專案中

  1. 下載套件
  2. 從終端運行此命令
    pip install ironpdf-2026.9-py37-none-win_amd64.whi

從$999起的授權