IRONSOFTWAREHOME
Add Barcodes in HTML to PDF
from ironpdf import *

# Instantiate Renderer
renderer = ChromePdfRenderer()
renderer.RenderingOptions.WaitFor.RenderDelay(500)

# Load barcode via HTML
barcode_html = '''<link href="https://fonts.googleapis.com/css?family=Libre%20Barcode%20128" rel="stylesheet">
<p style="font-family: 'Libre Barcode 128', serif; font-size:30px;">Hello Google Fonts</p>'''
doc = renderer.RenderHtmlAsPdf(barcode_html)

# or use the BarcodeStamper
barcode_stamp = BarcodeStamper("Hello World", BarcodeEncoding.Code39)
doc.ApplyStamp(barcode_stamp)

# Export to a file or Stream
doc.SaveAs("bc-test.pdf")
pip install ironpdf
Add Barcodes in HTML to PDF

Add Barcodes in HTML to PDF

Python developers can add barcodes to their PDF documents with IronPDF for Python in two ways, as illustrated above:

Method 1: Add Barcodes Using the ChromePdfRenderer

Use this method to create barcodes that contain text-based information:

  1. Create a string variable that holds the following HTML elements:
    • A link element that references a barcode web font like this one.
    • An element containing the text that you want encoded in a barcode.
  2. Create a new ChromePdfRenderer object.
  3. Call the RenderHtmlAsPdf method on the new object with the string variable as the argument.
  4. Save the resulting PdfDocument object to a file.

Method 2: Add Barcodes Using the BarcodeStamper

Use this approach when you want more control over how the barcode appears (e.g., width, height, page positioning, etc.):

  1. Create a PdfDocument object, as shown below.
  2. Create a BarcodeStamper object, specifying the text to encode along with a target Barcode Format in the parameter list (width and height are optional).
  3. Call the apply_stamp method on the PdfDocument object.
  4. Save the changes.

Use the IronBarcode C# Library for even more control over barcode creation. (And then stamp them onto your PDFs using IronPDF for Python's HtmlStamper!)

  • Note: For the Python example above, replace ChromePdfRenderer() and method names with the correct Python library methods and initialize them appropriately based on the imports at the top of the code block.
Learn to Create PDFs with IronPDF for Python
View on GitHub

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 IronPDF
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