IRONSOFTWAREHOME
Stamping HTML Content
from ironpdf import *

# Create an HtmlStamper object to stamp an image onto a PDF
stamper = HtmlStamper("<img src='https://ironpdf.com/img/products/ironpdf-logo-text-dotnet.svg'/>")
stamper.HorizontalAlignment = HorizontalAlignment.Center
stamper.VerticalAlignment = VerticalAlignment.Bottom
stamper.IsStampBehindContent = False
stamper.Opacity = 30

# Load an existing PDF document and apply the stamp to it
pdf = PdfDocument.FromFile("Sample.pdf")
pdf.ApplyStamp(stamper).SaveAs("stampedimage.pdf")
pip install ironpdf
Stamping HTML Content

Stamping HTML Content

IronPDF for Python can overlay HTML content onto existing PDF pages using the HtmlStamper class, allowing you to add logos, images, text, or any other HTML-rendered element on top of or behind page content.

Getting Started

Create an HtmlStamper with your HTML fragment, configure its positioning and appearance properties, load a PdfDocument, and call ApplyStamp to apply the stamp to all pages.

Understanding the Code

  • HtmlStamper(html): Accepts an HTML string - including <img> tags, styled text, or any valid HTML - and creates a stamper object that renders that HTML as an overlay.
  • HorizontalAlignment: Controls the horizontal position of the stamp on the page. Options include Left, Center, and Right.
  • VerticalAlignment: Controls the vertical position. Options include Top, Middle, and Bottom.
  • IsStampBehindContent: When False (default), the stamp appears on top of existing page content. Set to True to render the stamp behind the content, useful for watermarks or background graphics.
  • Opacity: A value from 0 (transparent) to 100 (fully opaque) that controls how visible the stamp is on the page.
  • PdfDocument.FromFile(path): Loads the existing PDF to be stamped.
  • ApplyStamp(stamper): Applies the stamp to all pages of the document and returns the modified PdfDocument.
Learn to edit and stamp PDFs with IronPDF for Python!

Ready to Get Started?

Version:2026.9just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

OR
bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required
Python Module Download for PDF
Install with pip

Version: 2026.9

  1. Download and install Python 3.7+.
  2. Install pip from pypi.org if it isn't installed already.
  3. Execute the above command in the terminal.
Python PDF Module
Download Module

Version: 2026.9

Manually install into your project

  1. Download the package
  2. Run this command from the terminal
    pip install ironpdf-2026.9-py37-none-win_amd64.whi

Licenses from $999