IRONSOFTWAREHOME
Embedding Bitmaps and Images
from ironpdf import *
import base64

# Instantiate Renderer
renderer = ChromePdfRenderer()

# Example 1: From an Image File or Bytes
with open(".\icons\iron.png", "rb") as f:
    pngBinaryData = f.read()
    imgDataUri = "data:image/png;base64," + base64.b64encode(pngBinaryData).decode("utf-8")
    imgHtml = f"<img src='{imgDataUri}'>"

pdf = renderer.RenderHtmlAsPdf(imgHtml)
pdf.SaveAs("embedded_example_1.pdf")
pip install ironpdf
Embedding Bitmaps and Images

Embedding Bitmaps and Images

IronPDF for Python can convert raw image byte content into PDFs.

After reading the byte stream from the data source (such as a database, a network connection, or a file), decode it into a character string and build an HTML string that includes it as a base64-encoded src attribute for an img element:

Afterward, call the RenderHtmlAsPdf method with the HTML string as the argument!

The power of IronPDF lies in its use of HTML as a design language. Get your media into something that represents valid HTML, and let IronPDF take care of the rest for you.

Learn to create PDFs with IronPDF for Python today!
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.

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