IRONSOFTWAREHOME
Embedding Bitmaps and Images
using IronPdf;
using IronSoftware.Drawing;
using System;
using System.IO;

ChromePdfRenderer renderer = new ChromePdfRenderer();

// Import image file as byte
byte[] binaryData = File.ReadAllBytes("sample.jpg");

// Convert byte to base64
string imgDataUri = @"data:image/jpg;base64," + Convert.ToBase64String(binaryData);
string imgHtml = $"<img src='{imgDataUri}'>";

PdfDocument pdf = renderer.RenderHtmlAsPdf(imgHtml);
pdf.SaveAs("embedded_example_1.pdf");
Imports IronPdf
Imports IronSoftware.Drawing
Imports System
Imports System.IO

Dim renderer As New ChromePdfRenderer()

' Import image file as byte
Dim binaryData As Byte() = File.ReadAllBytes("sample.jpg")

' Convert byte to base64
Dim imgDataUri As String = "data:image/jpg;base64," & Convert.ToBase64String(binaryData)
Dim imgHtml As String = $"<img src='{imgDataUri}'>"

Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf(imgHtml)
pdf.SaveAs("embedded_example_1.pdf")
NuGet Download
PM > Install-Package IronPdf
Embedding Bitmaps and Images

Embedding Bitmaps and Images

When you want to embed an image in HTML using Base64 encoding, you need to acquire the binary data of the image either by reading the image file or receiving it through a network request. In this example, we have imported the image we want to use and acquired its binary data. Then, using the Convert.ToBase64String method, you successfully converted it to Base64. Through this method, you will be able to add your images to any HTML content that you are using to render PDF documents.

For a more comprehensive guide, including additional examples and sample code, visit this How-to Guide.

Explore Data URI Schemes for Embedding Images in PDFs
View on GitHub

Ready to Get Started?

Nuget Downloads 20,878,335Version: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