IronPDF How-Tos Generate a PDF with Images from Azure Blob Storage Rendering PDFs Containing Images Stored in Azure Blob Storage Chaknith Bin Updated:July 28, 2025 Azure Blob Storage is a cloud-based storage service provided by Microsoft Azure. It's designed to store large amounts of unstructured data, such as text or binary data, that can be accessed via HTTP or HTTPS. Some developers would like to use images stored in Azure Blob Storage. This presents an issue because the image data is stored as binary rather than as a file, which could easily be referenced by HTML. The workaround is to convert images to a base64 string and add them to an img tag. Render an Azure Blob image into a PDF in one line! var blobBase64 = Convert.ToBase64String(new BlobContainerClient("conn","cont").GetBlobClient("img.jpg").DownloadContent().Value.Content.ToArray()); new IronPdf.ChromePdfRenderer().RenderHtmlAsPdf($"<img src=\"data:image/jpeg;base64,{blobBase64}\" />").SaveAs("blobImage.pdf"); Install with NuGet PM > Install-Package IronPdf Get started with IronPDF Start using IronPDF in your project today with a free trial. First Step: Start for Free How to Render Images Stored in Azure Blob Storage Download IronPDF for rendering images stored in Azure Blob Handle the process of retrieving the blob Use the ToBase64String method to convert bytes to base64 Include the base64 information in the img tag Render the HTML to PDF Convert Azure Blob to HTML Assuming you have already set up an Azure Storage account and have a container with blobs, you also need to handle authentication and connection to your Azure Storage in the C# project. Afterward, you can use the DownloadToStreamAsync method to download the image as a stream. The stream information can then be converted to Base64 and embedded in the img tag of HTML. Finally, the imageTag variable can be merged into an HTML document. using Azure.Storage.Blobs; using System; using System.IO; using System.Threading.Tasks; public async Task ConvertBlobToHtmlAsync() { // Define your connection string and container name string connectionString = "your_connection_string"; string containerName = "your_container_name"; // Initialize BlobServiceClient with the connection string BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString); // Get the BlobContainerClient for the specified container BlobContainerClient blobContainer = blobServiceClient.GetBlobContainerClient(containerName); // Get the reference to the blob and initialize a stream BlobClient blobClient = blobContainer.GetBlobClient("867.jpg"); using var stream = new MemoryStream(); // Download the blob data to the stream await blobClient.DownloadToAsync(stream); stream.Position = 0; // Reset stream position // Convert the stream to a byte array byte[] array = stream.ToArray(); // Convert bytes to base64 var base64 = Convert.ToBase64String(array); // Create an img tag with the base64-encoded string var imageTag = $"<img src=\"data:image/jpeg;base64,{base64}\"/><br/>"; // Use the imageTag in your HTML document as needed } using Azure.Storage.Blobs; using System; using System.IO; using System.Threading.Tasks; public async Task ConvertBlobToHtmlAsync() { // Define your connection string and container name string connectionString = "your_connection_string"; string containerName = "your_container_name"; // Initialize BlobServiceClient with the connection string BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString); // Get the BlobContainerClient for the specified container BlobContainerClient blobContainer = blobServiceClient.GetBlobContainerClient(containerName); // Get the reference to the blob and initialize a stream BlobClient blobClient = blobContainer.GetBlobClient("867.jpg"); using var stream = new MemoryStream(); // Download the blob data to the stream await blobClient.DownloadToAsync(stream); stream.Position = 0; // Reset stream position // Convert the stream to a byte array byte[] array = stream.ToArray(); // Convert bytes to base64 var base64 = Convert.ToBase64String(array); // Create an img tag with the base64-encoded string var imageTag = $"<img src=\"data:image/jpeg;base64,{base64}\"/><br/>"; // Use the imageTag in your HTML document as needed } Imports Azure.Storage.Blobs Imports System Imports System.IO Imports System.Threading.Tasks Public Async Function ConvertBlobToHtmlAsync() As Task ' Define your connection string and container name Dim connectionString As String = "your_connection_string" Dim containerName As String = "your_container_name" ' Initialize BlobServiceClient with the connection string Dim blobServiceClient As New BlobServiceClient(connectionString) ' Get the BlobContainerClient for the specified container Dim blobContainer As BlobContainerClient = blobServiceClient.GetBlobContainerClient(containerName) ' Get the reference to the blob and initialize a stream Dim blobClient As BlobClient = blobContainer.GetBlobClient("867.jpg") Dim stream = New MemoryStream() ' Download the blob data to the stream Await blobClient.DownloadToAsync(stream) stream.Position = 0 ' Reset stream position ' Convert the stream to a byte array Dim array() As Byte = stream.ToArray() ' Convert bytes to base64 Dim base64 = Convert.ToBase64String(array) ' Create an img tag with the base64-encoded string Dim imageTag = $"<img src=""data:image/jpeg;base64,{base64}""/><br/>" ' Use the imageTag in your HTML document as needed End Function $vbLabelText $csharpLabel Convert HTML to PDF Continuing from the imageTag, it can then be converted to PDF by using the RenderHtmlAsPdf method of ChromePdfRenderer. Below is a simple example of how you might call RenderHtmlAsPdf: :path=/static-assets/pdf/content-code-examples/how-to/images-azure-blob-storage-html-to-pdf.cs using IronPdf; // Instantiate Renderer var renderer = new ChromePdfRenderer(); // Create a PDF from a HTML string using C# var pdf = renderer.RenderHtmlAsPdf(imageTag); // Export to a file pdf.SaveAs("imageToPdf.pdf"); Imports IronPdf ' Instantiate Renderer Private renderer = New ChromePdfRenderer() ' Create a PDF from a HTML string using C# Private pdf = renderer.RenderHtmlAsPdf(imageTag) ' Export to a file pdf.SaveAs("imageToPdf.pdf") $vbLabelText $csharpLabel Make sure to adjust the "htmlContent" variable to include your actual HTML content where the imageTag is used. Frequently Asked Questions What is Azure Blob Storage? Azure Blob Storage is a cloud-based storage service provided by Microsoft Azure, designed to store large amounts of unstructured data that can be accessed via HTTP or HTTPS. How can I render images stored in Azure Blob Storage as part of a PDF? To render images stored in Azure Blob Storage in a PDF, you need to convert the image data to a base64 string, embed it in an HTML img tag, and then render the HTML to PDF using IronPDF. What are the steps to convert an Azure blob to HTML? First, set up an Azure Storage account and container. Then, use the `DownloadToStreamAsync` method to download the blob as a stream, convert it to a base64 string, and embed it in an HTML img tag. How do I convert HTML to PDF? You can convert HTML to PDF using IronPDF by utilizing the `RenderHtmlAsPdf` method of the `ChromePdfRenderer` class, which takes HTML content and renders it as a PDF document. What is the purpose of the base64 conversion when working with Azure Blob Storage? The base64 conversion allows you to embed binary image data directly into an HTML document as a data URL, which can then be rendered correctly in a PDF. Can I handle images directly from Azure Blob Storage? Yes, IronPDF can be used to handle images stored in Azure Blob Storage by converting them to base64 and embedding them in HTML before rendering to PDF. Do I need to set up authentication for accessing Azure Blob Storage? Yes, you need to handle authentication and establish a connection to your Azure Storage account in your C# project to access blobs. What is IronPDF? IronPDF is a .NET library that allows developers to render HTML into PDF documents, including the ability to include images and other media. How do I download IronPDF? You can download IronPDF from the NuGet package manager by searching for 'IronPdf' or visiting the NuGet website. What programming language is used for the examples in the guide? The examples in the guide are written in C#. 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. Ready to Get Started? Free NuGet Download Total downloads: 14,631,247 View Licenses