Skip to footer content
USING IRONPDF

How to Add Images to PDF in VB .NET

1. Introduction

Adobe's Portable Document Format (PDF) is widely used in various industries for tasks such as creating invoices. Developers also use the PDF format to produce documents that meet client specifications. Libraries have simplified the process of creating PDFs, and when selecting a library for a project, consider features like build, read, and convert capabilities.

2. IronPDF Features

IronPDF is a robust PDF SDK framework that facilitates the creation, reading, and editing of PDF documents. It converts HTML to PDF using the Chrome engine and supports various web components like Xamarin, Blazor, Unity, HoloLens apps, and more. It works with both online applications and traditional Windows Applications. IronPDF allows for the creation of aesthetically pleasing PDFs using HTML5, JavaScript, CSS, and images, and includes a powerful HTML-to-PDF converter.

3. Create PDF Documents from Images

IronPDF makes it easy to create PDFs from images.

' Create a PDF document from a single image file
Dim pdfdoc = ImageToPdfConverter.ImageToPdf("test.png").SaveAs("Resultimage.pdf")
' Create a PDF document from a single image file
Dim pdfdoc = ImageToPdfConverter.ImageToPdf("test.png").SaveAs("Resultimage.pdf")
VB .NET

By using the ImageToPdfConverter class, it is easy to use without creating any object for the class. The ImageToPdf method accepts the filename and path as a parameter and converts the given PNG file into the desired PDF. Finally, the SaveAs method saves the generated PDF file in the desired location.

The below image shows the result of the above code.

How to Add Images to PDF in VB .NET, Figure 1: The PDF file output The PDF file output

This next example creates a PDF document from a list of images.

' Create a PDF document from a list of image files
Dim lstimages As List(Of String) = New List(Of String)
lstimages.Add("test.png")
lstimages.Add("demo.png")
Dim pdfdoc = ImageToPdfConverter.ImageToPdf(lstimages).SaveAs("Resultimage.pdf")
' Create a PDF document from a list of image files
Dim lstimages As List(Of String) = New List(Of String)
lstimages.Add("test.png")
lstimages.Add("demo.png")
Dim pdfdoc = ImageToPdfConverter.ImageToPdf(lstimages).SaveAs("Resultimage.pdf")
VB .NET

How to Add Images to PDF in VB .NET, Figure 2: The PDF file from two images The PDF file from two images

4. Create PDF Documents from Bitmap image objects

Several bitmap image objects can be converted to PDF files with just a few lines of code.

' Convert a single Bitmap image object to a PDF file
Imports System.Drawing
Imports IronPdf

Dim image As Bitmap = Bitmap.FromFile("test.png")
Dim pdfDoc = ImageToPdfConverter.ImageToPdf(image).SaveAs("Resultimage.pdf")
' Convert a single Bitmap image object to a PDF file
Imports System.Drawing
Imports IronPdf

Dim image As Bitmap = Bitmap.FromFile("test.png")
Dim pdfDoc = ImageToPdfConverter.ImageToPdf(image).SaveAs("Resultimage.pdf")
VB .NET

In the above example, a Bitmap object is created from the PNG file and used as a medium format to convert to a PDF file.

How to Add Images to PDF in VB .NET, Figure 3: Generate a PDF file from a PNG image Generate a PDF file from a PNG image

It is also possible to combine a collection (or List) of Bitmap objects into a single PDF:

' Combine multiple Bitmap objects into a single PDF document
Dim lstImages As List(Of IronSoftware.Drawing.AnyBitmap) = New List(Of IronSoftware.Drawing.AnyBitmap)
lstImages.Add(Bitmap.FromFile("test.png"))
lstImages.Add(Bitmap.FromFile("demo.png"))
Dim pdfDoc = ImageToPdfConverter.ImageToPdf(lstImages).SaveAs("Resultimage.pdf")
' Combine multiple Bitmap objects into a single PDF document
Dim lstImages As List(Of IronSoftware.Drawing.AnyBitmap) = New List(Of IronSoftware.Drawing.AnyBitmap)
lstImages.Add(Bitmap.FromFile("test.png"))
lstImages.Add(Bitmap.FromFile("demo.png"))
Dim pdfDoc = ImageToPdfConverter.ImageToPdf(lstImages).SaveAs("Resultimage.pdf")
VB .NET

How to Add Images to PDF in VB .NET, Figure 4: Combine multiple Bitmap files to generate a PDF file Combine multiple Bitmap files to generate a PDF file

Configure the behavior of the above method calls using a ChromePdfRenderOptions object to enhance the visual aspect of the output PDF file. Options that can be configured include the position of the image, header and footer formatting, page title, page size, and many others.

More information about adding images to PDFs using IronPDF, along with other information, can be found in the IronPDF Documentation.

5. Conclusion

The IronPDF library provides a free license for development and a variety of licenses are available for purchase for use in a production environment, depending on the developer's needs. The Lite package costs $749 upfront and has no ongoing expenses. The licenses come with a perpetual license, a year of product support, upgrades, and options for SaaS and OEM redistribution. They are one-time investments that can be utilized for production, staging, and development.

IronPDF also provides extra time-limited free licenses. In addition, IronPDF offers free licenses that prevent redistribution. To view IronPDF's complete pricing and licensing details, please visit the IronPDF Licensing Details.

Frequently Asked Questions

What is the purpose of this PDF SDK framework?

IronPDF is a robust PDF SDK framework used for creating, reading, and editing PDF documents. It supports converting HTML to PDF, adding images, and interacting with various web components.

How can I create a PDF from an image file using VB.NET?

You can create a PDF from an image file using the ImageToPdfConverter class in IronPDF. For example, you can call ImageToPdfConverter.ImageToPdf("test.png").SaveAs("Resultimage.pdf") to generate a PDF from a PNG file.

Can this framework handle multiple image files to create a single PDF?

Yes, IronPDF can handle multiple image files. You can create a list of image files and use ImageToPdfConverter.ImageToPdf(listOfImages).SaveAs("Resultimage.pdf") to combine them into a single PDF.

What types of image objects can be converted to PDF using this framework?

IronPDF can convert both image files and Bitmap image objects to PDF files. You can use Bitmap objects directly in the ImageToPdfConverter to generate PDFs.

Does this framework support advanced PDF creation options?

Yes, IronPDF supports advanced PDF creation options such as customizing the position of images, header and footer formatting, page titles, and page sizes using ChromePdfRenderOptions.

Is a license required to use this PDF SDK framework?

IronPDF provides a free license for development purposes. For production use, various licenses are available for purchase, including options for SaaS and OEM redistribution.

Can this framework extract images from an existing PDF?

Yes, IronPDF can extract images from existing PDF files, allowing for further manipulation or conversion as needed.

What input formats does this framework support for PDF conversion?

IronPDF supports a variety of input formats for PDF conversion, including HTML, image files, ASPX pages, Razor/MVC views, and more.

How does this PDF SDK framework ensure compatibility with different applications?

IronPDF is compatible with various applications, including online and traditional Windows applications. It supports components like Xamarin, Blazor, Unity, and HoloLens apps.

What are the benefits of using this framework's HTML-to-PDF conversion?

IronPDF's HTML-to-PDF conversion uses the Chrome engine, allowing for the creation of aesthetically pleasing PDFs using HTML5, JavaScript, CSS, and images with high fidelity.

Chipego
Software Engineer
Chipego has a natural skill for listening that helps him to comprehend customer issues, and offer intelligent solutions. He joined the Iron Software team in 2023, after studying a Bachelor of Science in Information Technology. IronPDF and IronOCR are the two products Chipego has been focusing on, but his knowledge of all products is growing daily, as he finds new ways to support customers. He enjoys how collaborative life is at Iron Software, with team members from across the company bringing their varied experience to contribute to effective, innovative solutions. When Chipego is away from his desk, he can often be found enjoying a good book or playing football.