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文档中。

开始

为每种印章类型创建单独的印章对象,将它们添加到ApplyMultipleStamps以一次性应用所有印章。

理解代码

  • HtmlStamper(html): 将一个HTML片段盖到PDF上。 支持使用基于像素的HorizontalOffset
  • TextStamper(text): 使用自定义字体设置盖上纯文本。 设置FontFamily以使用任何Google字体(按名称)。
  • ImageStamper(path): 将一个图像文件盖到PDF上。 使用MinHeight控制印章的尺寸。
  • BarcodeStamper(value, encoding): 生成并盖上一个条形码或二维码。 BarcodeEncoding.Code39产生标准的Code 39条形码。
  • List[Stamper](): 一个保存混合类型印章对象的类型化集合。
  • ApplyMultipleStamps(stamps_list): 在单次高效的遍历中将列表中的所有印章应用于文档的每一页。

对齐和定位

每个印章都支持HorizontalOffset以便在页面上精确放置。

学习如何使用IronPDF for Python给PDF盖章!

准备开始了吗?

版本:2026.9刚刚发布

Key in blue circle

立即获取免费的 30 天试用版密钥

Your trial license will be sent to your email address

无任何限制。100% 解锁。无需信用卡。

bullet_checked无需信用卡或创建账户无任何限制。100% 解锁。无需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
预约您的免费现场演示
Booking Badge

深受全球数百万工程师信赖

Iron Software 的客户徽标
获取您的无义务咨询
填写下面的表格或通过sales@ironsoftware.com
您的资料将始终保密。
深受全球数百万工程师信赖
Iron Software 的客户徽标
立即获取您的免费30 天试用密钥
无需信用卡或创建账户