IronPDF How-Tos Images (jpg, png, svg, gif, etc) How to Add Images to PDFs Chaknith Bin Updated:June 22, 2025 Embedding an image in a PDF means placing the image directly within the PDF file, ensuring it's self-contained and doesn't rely on external sources. This allows the PDF to display the image seamlessly, even without an internet connection or external files. IronPDF is capable of rendering HTML strings, files, and web URLs to PDF. By using this method, images can be embedded in HTML and then converted into a PDF document. How to Add Images to PDFs Download the IronPDF C# library Prepare the image file to be embedded Use the img tag to embed images in HTML Render the HTML to PDF using the RenderHtmlAsPdf method Embed the image using Base64 encoding Embed Image in PDF Example To embed an image in a PDF, you must first include the image in HTML using the <img> tag. Then, use the RenderHtmlAsPdf method to convert the HTML to PDF. If you have an existing PDF, you can stamp the image onto the PDF document using either an image stamper or HTML stamper tutorial. :path=/static-assets/pdf/content-code-examples/how-to/add-images-to-pdfs-embed-image.cs using IronPdf; ChromePdfRenderer renderer = new ChromePdfRenderer(); string html = @"<img src='https://ironsoftware.com/img/products/ironpdf-logo-text-dotnet.svg'>"; // Render HTML to PDF PdfDocument pdf = renderer.RenderHtmlAsPdf(html); // Export PDF pdf.SaveAs("embedImage.pdf"); Imports IronPdf Private renderer As New ChromePdfRenderer() Private html As String = "<img src='https://ironsoftware.com/img/products/ironpdf-logo-text-dotnet.svg'>" ' Render HTML to PDF Private pdf As PdfDocument = renderer.RenderHtmlAsPdf(html) ' Export PDF pdf.SaveAs("embedImage.pdf") $vbLabelText $csharpLabel Embed with Base64 Example To use base64 for embedding an image in HTML, you must first obtain the binary data of the image either by reading the image file or receiving it through a network request. Use the Convert.ToBase64String method in Microsoft .NET to convert the binary data to base64. Construct the image tag in HTML using "data:image/svg+xml;base64," before the base64 data. You may have noticed that the image type is being specified before the base64 data. Visit the MDN Web Docs on Image Formats for more information on image format types. :path=/static-assets/pdf/content-code-examples/how-to/add-images-to-pdfs-base64-image.cs using IronPdf; using System; using System.IO; ChromePdfRenderer renderer = new ChromePdfRenderer(); // Import image file binary data byte[] binaryData = File.ReadAllBytes("ironpdf-logo-text-dotnet.svg"); // Convert the binary data to base 64 string imgDataUri = Convert.ToBase64String(binaryData); // Embed in HTML string html = $"<img src='data:image/svg+xml;base64,{imgDataUri}'>"; // Convert HTML to PDF PdfDocument pdf = renderer.RenderHtmlAsPdf(html); // Export the PDF pdf.SaveAs("embedImageBase64.pdf"); Imports IronPdf Imports System Imports System.IO Private renderer As New ChromePdfRenderer() ' Import image file binary data Private binaryData() As Byte = File.ReadAllBytes("ironpdf-logo-text-dotnet.svg") ' Convert the binary data to base 64 Private imgDataUri As String = Convert.ToBase64String(binaryData) ' Embed in HTML Private html As String = $"<img src='data:image/svg+xml;base64,{imgDataUri}'>" ' Convert HTML to PDF Private pdf As PdfDocument = renderer.RenderHtmlAsPdf(html) ' Export the PDF pdf.SaveAs("embedImageBase64.pdf") $vbLabelText $csharpLabel Ready to see what else you can do? Check out our tutorial page here: Addtional Features Frequently Asked Questions What is the advantage of embedding images in a PDF? Embedding an image in a PDF ensures that the PDF file is self-contained and does not rely on external sources. This allows the PDF to display the image seamlessly, even without an internet connection or external files. How can images be added to PDFs? IronPDF can render HTML strings, files, and web URLs to PDF. By embedding images in HTML using the tag, and then converting the HTML to a PDF document, images can be added to PDFs using IronPDF. What steps are involved in adding images to PDFs? To add images to PDFs using IronPDF, you need to download the IronPDF C# library, prepare the image file, use the tag to embed images in HTML, render the HTML to PDF using the RenderHtmlAsPdf method, and optionally, embed the image using Base64 encoding. How do you embed an image in a PDF using the tag? To embed an image in a PDF using the tag, include the image in HTML with the tag, then use IronPDF's RenderHtmlAsPdf method to convert the HTML to a PDF. What is the process for embedding an image using Base64 encoding? To embed an image using Base64 encoding, you need to read the binary data of the image, convert it to a Base64 string using the Convert.ToBase64String method, create an HTML image tag with the Base64 data, and then render the HTML to a PDF. Can existing PDFs have images added? Yes, you can stamp images onto existing PDF documents using either an image stamper or an HTML stamper tutorial provided by IronPDF. Is an internet connection required to display embedded images in PDFs? No, once an image is embedded in a PDF, it does not require an internet connection to be displayed since the PDF is self-contained. What coding languages are used in the examples provided? The examples provided use C# programming language to demonstrate how to embed images in PDFs using IronPDF. What is the purpose of using Base64 encoding for images in HTML? Base64 encoding is used to embed image data directly in HTML, allowing images to be displayed without separate image files. This is particularly useful when converting HTML to PDF with embedded images. Where can I find more information on image format types for Base64 embedding? More information on image format types for Base64 embedding can be found on the MDN Web Docs on Image Formats. Chaknith Bin Chat with engineering team now Software Engineer Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience. Reviewed by Jeffrey T. Fritz Principal Program Manager - .NET Community Team Jeff is also a Principal Program Manager for the .NET and Visual Studio teams. He is the executive producer of the .NET Conf virtual conference series and hosts 'Fritz and Friends' a live stream for developers that airs twice weekly where he talks tech and writes code together with viewers. Jeff writes workshops, presentations, and plans content for the largest Microsoft developer events including Microsoft Build, Microsoft Ignite, .NET Conf, and the Microsoft MVP Summit Ready to Get Started? Free NuGet Download Total downloads: 14,817,395 View Licenses