Cómo generar archivos PDF en la biblioteca VB .NET | IronPDF

VB.NET PDF Creator (Code Example Tutorial)

This article was translated from English: Does it need improvement?
Translated
View the article in English

This tutorial will guide you step-by-step on how to create and edit PDF files in VB.NET. This technique is equally valid for use in ASP.NET web apps as well as console applications, Windows Services, and desktop programs. We will use VB.NET to create PDF projects targeting .NET Framework 4.6.2 or .NET Core 2. All you need is a Visual Basic .NET development environment, such as Microsoft Visual Studio Community.

To see how to use IronPDF with C# see this guide.

To see how to use IronPDF with F# see this guide.


Overview

How to Generate PDF Files in VB .NET Library

  1. Download the VB.NET PDF Library
  2. Create a PDF document with VB.NET Library
  3. Customize your PDF document styles
  4. Choose which methods to create dynamic content
  5. Edit your PDF files from VB.NET Library

VB .NET Codes for PDF Creating and Editing with IronPDF

Render HTML to PDF with VB.NET, apply styling, utilize dynamic content, and edit your files easily. Creating PDFs is straightforward and compatible with .NET Framework 4.6.2, .NET Core 3.1, .NET 8, 7, 6 & 5. And no need for proprietary file formats or dealing with different APIs.

This tutorial provides the documentation to walk you through each task step-by-step, all using the free-for-development IronPDF software favored by developers. VB.NET code examples are specific to your use cases so you can see the steps easily in a familiar environment. This VB .NET PDF library has comprehensive creation and settings capabilities for every project, whether in ASP.NET applications, console, or desktop.

Included with IronPDF:

  • Ticket support direct from our .NET PDF Library development team
  • Works with HTML, ASPX forms, MVC views, images, and all the document formats you already use
  • Microsoft Visual Studio installation gets you up and running fast
  • Unlimited free development, and licenses to go live starting at $799

Step 1

1. Download the VB .NET PDF Library FREE from IronPDF

Comience a usar IronPDF en su proyecto hoy con una prueba gratuita.

Primer Paso:
green arrow pointer

Install via NuGet

In Visual Studio, right-click on your project in the Solution Explorer and select "Manage NuGet Packages...". From there simply search for IronPDF and install the latest version... click OK to any dialog boxes that come up.

This will work in any C# .NET Framework project from Framework 4.6.2 and above, or .NET Core 2 and above. It will also work just as well in VB.NET projects.

Install-Package IronPdf

Download IronPDF from NuGet

Install via DLL

Alternatively, the IronPDF DLL can be downloaded and manually installed to the project or GAC from IronPDF Downloads

Remember to add this statement to the top of any VB class file using IronPDF:

Imports IronPdf

How to Tutorials

2. Create a PDF with VB.NET

Using Visual Basic ASP.NET to create a PDF file for the first time is surprisingly easy using IronPDF, as compared to libraries with proprietary design APIs such as iTextSharp.

We can use HTML (with a pixel-perfect rendering engine based on Google Chromium) to define the content of our PDF and simply render it to a file.

Here is the basic code to create a PDF in VB.NET:

:path=/static-assets/pdf/content-code-examples/how-to/vb-net-pdf-1.cs

This will produce a .NET-generated PDF file containing your exact text, albeit lacking some design at this point.

To improve upon this code, we can add the following line to open the PDF in the operating system's default PDF viewer:

:path=/static-assets/pdf/content-code-examples/how-to/vb-net-pdf-2.cs

An alternative method would be to render any existing web page from a URL to a PDF by using the elegant RenderUrlAsPdf method from IronPDF.

:path=/static-assets/pdf/content-code-examples/how-to/vb-net-pdf-3.cs
PDF.SaveAs("webpage.pdf")

3. Apply Styling to VB.NET PDF

To style our PDF content in VB.NET, we can make full use of CSS, JavaScript, and images. We may link to local assets, or even to remote or CDN-based assets such as Google Fonts. We can even use DataURIs to embed images and assets as a string into your HTML.

For advanced design, we can use a 2-stage process:

  1. First, we develop and design our HTML perfectly. This task may involve in-house design staff, splitting the workload.
  2. Render that file as a PDF using VB.NET and our PDF library.

The VB.NET Code to render the HTML file as a PDF:

This method renders an HTML document as if it were opened as a file (file:// protocol).

Dim Renderer As New IronPdf.ChromePdfRenderer()
Renderer.RenderingOptions.PaperOrientation = IronPdf.Rendering.PdfPaperOrientation.Landscape 
Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print 
Dim PDF As IronPdf.PdfDocument = Renderer.RenderUrlAsPdf("file://path-to-your-html-file.html")
PDF.SaveAs("styled-sample.pdf")

4. Create PDF w/ Dynamic Content: 2 Methods

Historically, PDF 'templating' has been an overwhelming task for Software Engineers. Stamping content into PDF templates rarely works because each case or report will contain content of varying types and lengths. Fortunately, HTML is exceptionally good at handling Dynamic Data.

4.1. Method 1 - ASP.NET - ASPX to PDF using VB.NET Web Forms

Any flavor of .NET Web Form (including Razor) can be rendered into a PDF document using this VB.NET code in the Page_Load subroutine in the VB.NET code behind.

:path=/static-assets/pdf/content-code-examples/how-to/vb-net-pdf-8.cs

4.2. Method 2 - HTML to PDF with String Templating

To create dynamic PDF documents that include instance-specific data, we simply create an HTML string to match the data we wish to render as a PDF.

:path=/static-assets/pdf/content-code-examples/how-to/vb-net-pdf-9.cs

5. Edit PDF Files with VB.NET

IronPDF for VB.NET also allows PDF documents to be edited, encrypted, watermarked, or even turned back into plain text:

5.1. Merging Multiple PDF Files into One Document in VB

:path=/static-assets/pdf/content-code-examples/how-to/vb-net-pdf-10.cs

5.2. Add a Cover Page to the PDF

:path=/static-assets/pdf/content-code-examples/how-to/vb-net-pdf-11.cs

5.3. Remove the last page from the PDF

:path=/static-assets/pdf/content-code-examples/how-to/vb-net-pdf-12.cs

5.4. Encrypt a PDF using 128 Bit Encryption

:path=/static-assets/pdf/content-code-examples/how-to/vb-net-pdf-13.cs

5.5. Stamp Additional HTML Content Onto a Page in VB

:path=/static-assets/pdf/content-code-examples/how-to/vb-net-pdf-14.cs

5.6. Add Page Break to PDF Using HTML

The easiest way to do this is with HTML and CSS:

:path=/static-assets/pdf/content-code-examples/how-to/vb-net-pdf-15.cs
<div style='page-break-after: always;'>&nbsp;</div>
HTML

6. More .NET PDF Tutorials

You may also be interested in:


Conclusion

In this tutorial, we discovered 6 ways to achieve VB.NET to PDF results using VB.NET as our programming language of choice.

  • HTML string to PDF
  • Creating a PDF in VB.NET using an HTML string to define its content
  • Rendering existing URLs as PDF files
  • Generating PDF from HTML files
  • HTML templating in VB.NET and conversion to dynamic PDFs
  • Converting ASP.NET pages with live data, such as ASPX to PDF files

For each, we used the popular IronPDF VB.NET library to allow us to turn HTML directly into PDF documents within .NET projects.


Tutorial Quick Access

Brand Visual Studio related to Tutorial Quick Access

Download this Tutorial as Source Code

The full free VB.NET HTML to PDF Source Code for this tutorial is available to download as a zipped Visual Studio project file.

Download

Explore this Tutorial on GitHub

You may also be interested in our extensive library of VB.NET PDF generation and manipulation examples on GitHub. Exploring source code is the fastest way to learn, and Github is the definitive way to do so online. I hope these examples help you get to grips with PDF related functionality in your VB projects.

Creating PDFS in ASP.NET with VB.NET and C# Source A Simple Hello World Project to Render HTML to PDF in VB.NET using IronPDF Exploring HTML To PDF in-depth with VB.NET
Github Icon related to Tutorial Quick Access
Html To Pdf Icon related to Tutorial Quick Access

Download C# PDF Quickstart guide

To make developing PDFs in your .NET applications easier, we have compiled a quick-start guide as a PDF document. This "Cheat-Sheet" provides quick access to common functions and examples for generating and editing PDFs in C# and VB.NET - and will save time getting started using IronPDF in your .NET project.

Download

View the API Reference

Explore the API Reference for IronPDF, outlining the details of all of IronPDF’s features, namespaces, classes, methods fields and enums.

View the API Reference
Documentation related to Tutorial Quick Access

Preguntas Frecuentes

¿Cómo instalo la Biblioteca VB.NET PDF?

Puede instalar la Biblioteca VB.NET PDF desde IronPDF a través de NuGet haciendo clic derecho en su proyecto en el Explorador de Soluciones de Visual Studio, seleccionando 'Gestionar Paquetes NuGet...', buscando IronPDF e instalando la última versión. Alternativamente, puede descargar el DLL de IronPDF e instalarlo manualmente en su proyecto o GAC.

¿Cómo puedo crear un PDF usando VB.NET?

Puede crear un PDF usando VB.NET utilizando la clase ChromePdfRenderer de IronPDF. Por ejemplo, puede renderizar HTML a PDF con el siguiente código: Dim Renderer As New IronPdf.ChromePdfRenderer(), Dim PDF As IronPdf.PdfDocument = Renderer.RenderHtmlAsPdf('

Hello World!

'), PDF.SaveAs('sample.pdf').

¿Qué métodos están disponibles para crear contenido dinámico en un PDF?

Hay dos métodos principales para crear contenido dinámico en PDFs usando VB.NET: El Método 1 involucra el uso de ASP.NET Web Forms para renderizar contenido dinámico en un PDF, y el Método 2 involucra la conversión de HTML a PDF con plantillas de cadena para incluir datos específicos de la instancia.

¿Cómo puedo editar un archivo PDF usando VB.NET?

Usando IronPDF, los archivos PDF pueden editarse de varias maneras, incluyendo la fusión de múltiples PDFs, la adición de una página de cubierta, la eliminación de páginas, el cifrado de PDFs y la inserción de contenido adicional en las páginas. Por ejemplo, para fusionar PDFs, use el método IronPdf.PdfDocument.Merge.

¿Puedo aplicar estilos al contenido PDF en VB.NET?

Sí, puede aplicar estilos al contenido PDF en VB.NET usando CSS, JavaScript e imágenes. Esto puede incluir vincular activos locales o remotos y usar DataURIs para incrustar imágenes directamente en el HTML.

¿Es posible renderizar una página web directamente como un PDF en VB.NET?

Sí, usando el método RenderUrlAsPdf de IronPDF, puede renderizar cualquier página web existente directamente como un PDF. Esto le permite convertir toda la página web, incluidos su contenido y estilo, en un archivo PDF.

¿Cuáles son los requisitos del sistema para usar la biblioteca PDF con VB.NET?

IronPDF es compatible con .NET Framework 4.6.2 en adelante, así como con .NET Core 2 y versiones posteriores. Funciona perfectamente con proyectos VB.NET en estos entornos.

¿Hay soporte disponible para la biblioteca PDF en VB.NET?

Sí, IronPDF ofrece soporte por tickets directamente desde su equipo de desarrollo de la Biblioteca .NET PDF, asegurando que tenga acceso a ayuda cuando sea necesario.

¿Puedo ver la Referencia API para la biblioteca PDF?

Sí, puede ver la Referencia API para IronPDF, que detalla todas sus características, espacios de nombres, clases, métodos, campos y enums, en el sitio web de IronPDF.

¿Dónde puedo encontrar más tutoriales sobre cómo usar la biblioteca PDF de VB.NET?

Puede encontrar más tutoriales en el sitio web de IronPDF, así como en su repositorio de GitHub. Estos recursos proporcionan ejemplos y casos de uso adicionales para crear y manipular PDFs con VB.NET.

¿Cómo puedo convertir HTML a PDF en VB.NET?

Puede usar el método RenderHtmlAsPdf de IronPDF para convertir cadenas HTML en PDFs. Esto es particularmente útil para generar dinámicamente PDFs con contenido estilo.

¿Puedo usar VB.NET para cifrar un archivo PDF?

Sí, puede cifrar un archivo PDF usando IronPDF en VB.NET. La biblioteca proporciona métodos para aplicar configuraciones de seguridad, incluida la protección por contraseña, a sus documentos PDF.

¿Qué opciones están disponibles para fusionar documentos PDF en VB.NET?

Usando IronPDF, puede fusionar múltiples documentos PDF en un solo archivo utilizando el método PdfDocument.Merge. Esto permite la combinación fácil de diferentes archivos PDF.

¿IronPDF es compatible con .NET 10 para proyectos VB.NET?

Sí. IronPDF es totalmente compatible con .NET 10 para VB.NET (así como con C# y F#), incluyendo todas las mejoras de tiempo de ejecución, nuevas API y compatibilidad total desde el primer momento. Los proyectos que utilizan .NET 10 pueden usar IronPDF igual que con versiones anteriores de .NET, sin necesidad de configuración adicional.

Curtis Chau
Escritor Técnico

Curtis Chau tiene una licenciatura en Ciencias de la Computación (Carleton University) y se especializa en el desarrollo front-end con experiencia en Node.js, TypeScript, JavaScript y React. Apasionado por crear interfaces de usuario intuitivas y estéticamente agradables, disfruta trabajando con frameworks modernos y creando manuales bien ...

Leer más
Revisado por
Jeff Fritz
Jeffrey T. Fritz
Gerente Principal de Programas - Equipo de la Comunidad .NET
Jeff también es Gerente Principal de Programas para los equipos de .NET y Visual Studio. Es el productor ejecutivo de la serie de conferencias virtuales .NET Conf y anfitrión de 'Fritz and Friends', una transmisión en vivo para desarrolladores que se emite dos veces a la semana donde habla sobre tecnología y escribe código junto con la audiencia. Jeff escribe talleres, presentaciones, y planifica contenido para los eventos de desarrolladores más importantes de Microsoft, incluyendo Microsoft Build, Microsoft Ignite, .NET Conf y la Cumbre de Microsoft MVP.
¿Listo para empezar?
Nuget Descargas 16,133,208 | Versión: 2025.11 recién lanzado