Zum Fußzeileninhalt springen
IRONPDF NUTZEN

Wie man Bilder in PDF in VB.NET hinzufügt

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 $799 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.

Häufig gestellte Fragen

Wie kann ich Bilder in ein PDF-Dokument mit VB.NET einfügen?

Sie können IronPDF verwenden, um Bilder in PDF-Dokumente in VB.NET einzufügen, indem Sie die Klasse ImageToPdfConverter verwenden. Zum Beispiel wird die Methode ImageToPdfConverter.ImageToPdf("image.png").SaveAs("output.pdf") ein PDF aus einer Bilddatei erstellen.

Welche Bildformate werden für die PDF-Konvertierung in VB.NET unterstützt?

IronPDF unterstützt eine Vielzahl von Bildformaten für die Konvertierung in PDFs, einschließlich PNG, JPEG, BMP und GIF. Sie können diese Bilddateien mit dem ImageToPdfConverter in PDFs konvertieren.

Kann ich das Erscheinungsbild des PDFs anpassen, wenn ich Bilder mit VB.NET hinzufüge?

Ja, IronPDF ermöglicht die Anpassung des PDF-Outputs, wie z.B. Bildpositionierung, Kopf- und Fußzeilen und Seitengrößen, mit ChromePdfRenderOptions.

Ist es möglich, mehrere Bilder zu einem einzigen PDF-Dokument zu kombinieren?

Ja, mit IronPDF können Sie mehrere Bilder zu einem einzigen PDF-Dokument kombinieren, indem Sie eine Liste von Bildern an ImageToPdfConverter übergeben und die Ausgabe als eine PDF-Datei speichern.

Wie kann ich Bitmap-Objekte verwenden, um PDFs in VB.NET zu erstellen?

IronPDF unterstützt die direkte Verwendung von Bitmap-Objekten zur Erstellung von PDFs. Sie können Bitmap-Bilder konvertieren, indem Sie sie an ImageToPdfConverter übergeben, um PDF-Dateien zu generieren.

Welche Optionen gibt es für die Lizenzierung von IronPDF?

IronPDF bietet eine kostenlose Entwicklungslizenz und verschiedene Produktionslizenzen, die die dauerhafte Nutzung, Produktsupport und Upgrades umfassen. Lizenzierungsoptionen decken auch SaaS und OEM-Weiterverteilung ab.

Erlaubt IronPDF interaktive Elemente in einem PDF?

Ja, IronPDF kann interaktive Elemente wie Formulare und Anmerkungen zu PDF-Dokumenten hinzufügen, um die Funktionalität Ihrer PDFs zu verbessern.

Wie behandelt IronPDF HTML-zu-PDF-Konvertierungen?

IronPDF verwendet die Chrome-Engine zur HTML-zu-PDF-Konvertierung, um sicherzustellen, dass HTML5, JavaScript und CSS optisch ansprechende PDFs in hoher Genauigkeit wiedergeben werden.

Welche Plattformen sind mit IronPDF kompatibel?

IronPDF ist kompatibel mit verschiedenen Plattformen, einschließlich Xamarin, Blazor, Unity und HoloLens-Apps, was es vielseitig für verschiedene Entwicklungsumgebungen macht.

Ist IronPDF vollständig mit .NET 10 kompatibel, und welche Vorteile ergeben sich daraus beim Hinzufügen von Bildern in VB.NET?

Ja, IronPDF ist vollständig mit .NET 10 kompatibel und unterstützt C# und VB.NET in .NET 10-Projekten. Diese Kompatibilität führt zu Verbesserungen bei Leistung, Speichernutzung und Werkzeugen beim Arbeiten mit Bildern oder großen Bilddateien und integriert sich ohne spezielle Konfiguration in die neuesten .NET-APIs.

Curtis Chau
Technischer Autor

Curtis Chau hat einen Bachelor-Abschluss in Informatik von der Carleton University und ist spezialisiert auf Frontend-Entwicklung mit Expertise in Node.js, TypeScript, JavaScript und React. Leidenschaftlich widmet er sich der Erstellung intuitiver und ästhetisch ansprechender Benutzerschnittstellen und arbeitet gerne mit modernen Frameworks sowie der Erstellung gut strukturierter, optisch ansprechender ...

Weiterlesen