How to Add Images to PDF in VB .NET

1. Introduction

Adobe developed the Portable Document Format to make sharing documents with text and pictures simpler. To view a PDF file, however, you require a different application. Today's society relies heavily on PDF documents, which are used by a wide range of businesses to perform tasks like creating invoices and other papers. The PDF format is also used by developers to produce documents that adhere to client specifications. Fortunately, libraries that make the process simpler have made producing PDFs simpler than ever. You should think about features like build, read, and convert capabilities when selecting a library for your project to locate the finest one available.

2. IronPDF Features

IronPDF, a powerful PDF SDK framework for PDF processing, makes it simple for developers to swiftly produce, read, and edit PDF documents. The IronPDF net package converts HTML to PDF by using the Chrome engine. Among the several web components that the library supports are Xamarin, Blazor, Unity, HoloLens apps, Windows Forms, HTML, ASPX, Razor HTML, NET Core, ASP.NET, and WPF. Microsoft.NET and .NET Core programs can be used by both ASP.NET online applications and traditional Windows applications. IronPDF enables the creation of visually appealing PDFs with a title and footer using HTML5, JavaScript, CSS, and pictures. The API library also contains a powerful HTML-to-PDF converter that works well with PDF as well as a standalone PDF conversion engine that is unreliant on any outside sources.

  • The IronPDF library supports a variety of inputs for PDF production, including image files, HTML, HTML5, ASPX, and Razor/MVC View.
  • The library has tools for creating interactive PDF files, finishing and sending interactive forms, dividing PDF files, extracting text and images, text searching, and rasterizing PDF pages to images.
  • In addition to using user agents, proxies, cookies, HTTP headers, and form variables for authentication behind HTML login forms, the library also offers the usage of links as the foundation for PDF documents.
  • IronPDF offers access to password-protected PDF files by requesting user names and passwords.
  • The IronPDF API allows for the reading and editing of existing PDF files.
  • The library can extract images from PDF files as well as add text, graphics, bookmarks, watermarks, headers, and footers to PDF files.
  • Users can split and combine pages in a new or existing PDF document, and IronPDF can create PDF objects from text without requiring Acrobat Reader.
  • Both CSS media files and CSS files can be converted into PDF documents.
  • Users of IronPDF can add brand-new PDF forms and edit pre-existing ones.

3. Create PDF Documents from Images

IronPDF makes it easy for us to create PDFs from images.

Dim pdfdoc = ImageToPdfConverter.ImageToPdf("test.png").SaveAs("Resultimage.pdf")  
Dim pdfdoc = ImageToPdfConverter.ImageToPdf("test.png").SaveAs("Resultimage.pdf")  
VB.NET

By using the ImageToPdfConverter class, we can able to use them 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 saves the generated PDF file in the desired location.

Below image shows the result of the above code.

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

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")  
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

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.

Imports system.Drawing 
Imports IronPdf 
Dim image = Bitmap.FromFile("test.png") 
Dim doc = ImageToPdfConverter.ImageToPdf(image).SaveAs("Resultimage.pdf")  
Imports system.Drawing 
Imports IronPdf 
Dim image = Bitmap.FromFile("test.png") 
Dim doc = ImageToPdfConverter.ImageToPdf(image).SaveAs("Resultimage.pdf")  
VB.NET

In the example above, we create a Bitmap object from the PNG file that we've been using up to this point.

We can also combine a collection (or List) of Bitmap objects into a single PDF:

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")  
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

We can optionally configure the behavior of the above method calls using a ChromePdfRenderOptions object. 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 how to add images to PDFs using IronPDF, along with other information, can be found in the Docs section.

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 $499 up front 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. View IronPDF's complete pricing and licensing details, please click here.