USING IRONPRINT

How to Print PDF in VB.NET (Step-by-Step) Tutorial

<div class="alert alert-info iron-variant-1" role="alert">
    <a href="https://ironsoftware.com/csharp/print/">IronPrint</a> is Iron Software's brand new .NET printing library, offering compatibility across a wide range of platforms, including Windows, macOS, Android, and iOS. <a href="https://ironsoftware.com/csharp/print/docs/">Get started with IronPrint</a> now!
</div>
<div class="alert alert-info iron-variant-1" role="alert">
    <a href="https://ironsoftware.com/csharp/print/">IronPrint</a> is Iron Software's brand new .NET printing library, offering compatibility across a wide range of platforms, including Windows, macOS, Android, and iOS. <a href="https://ironsoftware.com/csharp/print/docs/">Get started with IronPrint</a> now!
</div>
HTML

This article describes the process of how to print URL pages with images as PDF pages/documents at runtime system in ASP.NET Web Application using VB.NET. The article will use the IronPDF library for printing PDF documents through URLs in the ASP.NET Web Application with Web/Windows Forms or pages using the default printer.

<div class="hsg-featured-snippet">
    <h2>How to Print PDF File in VB.NET</h2>
    <ol>
        <li><a class="js-modal-open" data-modal-id="trial-license-after-download" href="https://nuget.org/packages/IronPdf/">Install VB library to print PDF files</a></li>
        <li>Create ASP.NET Web Application</li>
        <li>Use <code>RenderUrlAsPdf</code> method in VB to render website into PDF</li>
        <li>Perform print action to the default printer with <code>Print</code> method</li>
        <li>Execute <code>SaveAs</code> method to save the PDF as a new document</li>
    </ol>
</div>
<div class="hsg-featured-snippet">
    <h2>How to Print PDF File in VB.NET</h2>
    <ol>
        <li><a class="js-modal-open" data-modal-id="trial-license-after-download" href="https://nuget.org/packages/IronPdf/">Install VB library to print PDF files</a></li>
        <li>Create ASP.NET Web Application</li>
        <li>Use <code>RenderUrlAsPdf</code> method in VB to render website into PDF</li>
        <li>Perform print action to the default printer with <code>Print</code> method</li>
        <li>Execute <code>SaveAs</code> method to save the PDF as a new document</li>
    </ol>
</div>
HTML

About the IronPDF library

IronPDF is a C# and VB.NET PDF library that allows you to print URLs as PDF files/documents without using Adobe Acrobat Reader and the default printer. This product offers a new system solution for developers who wish to print URL content into a PDF file/pages and then print PDF with print preview notes. IronPDF can be used with ASP.NET Web Applications or Windows Forms to generate PDF documents and print PDF files in a way that HTML pages are built without using the default printer. It allows programmers the ability to create PDF files and documents from scratch in ASP.NET Web Applications without having any prior knowledge of Adobe Acrobat or other third-party application tools. Let's see how we can use it in the ASP.NET Web Application for PDF printing/drawing through URL. You can also use Windows Forms in the .NET application for converting URLs into PDF documents and then printing PDF documents using a printer.

It also allows developers to generate, edit, extract, and print PDF document content within .NET Core and Framework projects as .NET applications. Using the IronPDF library, we can print a URL as a PDF document.

Create an ASP.NET Web Application for Generating PDF Files

Follow the following steps for creating an ASP.NET Web Application.

  • Open Visual Studio and click the "Create New Project" button.
  • From the template list, select ASP.NET Web Application.
  • Give a proper name to your application.
  • Select a .NET Framework and click on the 'Create' button.

Learn how to work with IronPDF using VB.NET by reading this tutorial.

Installing the IronPDF library

There are multiple ways to install the IronPDF library.

  • Using NuGet Command Line
  • Using NuGet GUI
  • Download from NuGet Website

The easiest way to install IronPDF is using the NuGet Command Line. Go to the NuGet Command Line, write the following statement, and press the Enter button.

Install-Package IronPrint

IronPDF installation will start. After installation, you will be able to use the IronPDF file in your project. For confirmation that the IronPDF file has been installed, expand the Dependencies section in Solution Explorer and click on the Packages section. You will see the IronPDF file package there.

Now, this project is ready to use IronPDF. Let's see how to use it in the ASP.NET Web Application with Web Forms.

Using IronPDF in ASP.NET Web Application with Web Forms

Add a button for printing PDF files. For example, write the following code snippet on the Default.aspx page for that purpose which is the default filename and first page or web form of the application. Check the below sample code.

<div>
    <asp:Button ID="Button1" runat="server" Text="Generate PDF" OnClick="Button1_Click" />
</div>
<div>
    <asp:Button ID="Button1" runat="server" Text="Generate PDF" OnClick="Button1_Click" />
</div>
HTML

First, in the above code, a div is added with an asp:Button (server control) in it. The text on the button has been set to read "Generate PDF." There is also an OnClick event defined on the button.

Print Web Page Content as PDF

Now, it's time to write a post-action to generate a PDF file. After adding an OnClick event in Default.aspx page, it automatically added an event Button1_Click in the Default.aspx.cs file.

Include the following import statements at the top of the Default.aspx.cs source file:

Imports IronPdf
Imports System.Drawing.Printing
Imports IronPdf
Imports System.Drawing.Printing
VB .NET

Enter the following code snippet in the source file for the Button1_Click event:

Public Class _Default
    Inherits Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        ' This method is executed on each page load
    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs)
        ' Creating an instance of ChromePdfRenderer to convert web page content to PDF
        Dim document = New ChromePdfRenderer()

        ' Create new PdfDocument by rendering a specified URL
        Dim PDF As PdfDocument = document.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf")

        ' Save the PDF document to a file named "UrlToPdf.pdf"
        PDF.SaveAs("UrlToPdf.pdf")

        ' Print the PDF document at 300 DPI without showing the print dialog
        PDF.Print(300, False)

        ' For more advanced printing, you can modify PrintDocument settings
        Dim PrintDocYouCanWorkWith As PrintDocument = PDF.GetPrintDocument()
    End Sub
End Class
Public Class _Default
    Inherits Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        ' This method is executed on each page load
    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs)
        ' Creating an instance of ChromePdfRenderer to convert web page content to PDF
        Dim document = New ChromePdfRenderer()

        ' Create new PdfDocument by rendering a specified URL
        Dim PDF As PdfDocument = document.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf")

        ' Save the PDF document to a file named "UrlToPdf.pdf"
        PDF.SaveAs("UrlToPdf.pdf")

        ' Print the PDF document at 300 DPI without showing the print dialog
        PDF.Print(300, False)

        ' For more advanced printing, you can modify PrintDocument settings
        Dim PrintDocYouCanWorkWith As PrintDocument = PDF.GetPrintDocument()
    End Sub
End Class
VB .NET

Firstly, create an instance of the ChromePdfRenderer class. After that, use the RenderUrlAsPdf function to convert a URL to PDF pages. In the method parameter, provide the URL of the web page that is needed to convert. In this case, provide the URL as "https://www.nuget.org/packages/IronPdf". After generating the PDF, save it to the computer using the SaveAs function. Afterward, call the Print method with a specified DPI to print the document. The third False parameter value makes it print without displaying the Print Dialog box.

Run the project. You will see the welcome page with a "Generate PDF" button.

When you click on the "Generate PDF" button, it will print a PDF document via the default selected printer.

You will see the hard copy of content that has been generated by the IronPDF. The content in the hard copy is the same as mentioned in the URL and printed PDF documents.

Conclusion

IronPDF is a great tool for .NET developers to manipulate and print PDFs in their .NET projects without using Adobe Reader. It provides features in multiple languages like C# and VB.NET which are handy for developers to pace up their work. You can format PDF files, delete or add pages, add PNG or graphics in PDF and many more. IronPDF is free for development.

IronPDF offers developers methods to render PDF documents into images and extract text and content from a PDF. IronPDF also can merge and split PDF files, edit PDF forms, and enhance security with passwords.

Frequently Asked Questions

What is IronPDF?

IronPDF is a C# and VB.NET PDF library that allows developers to print URLs as PDF files/documents without using Adobe Acrobat Reader and the default printer.

How can I install IronPDF in my project?

You can install IronPDF using NuGet Command Line, NuGet GUI, or by downloading it from the NuGet Website.

How do I print a PDF from a URL using VB.NET?

To print a PDF from a URL using VB.NET, use the IronPDF library's RenderUrlAsPdf method to render the website into a PDF, then use the Print method to perform the print action.

Can IronPDF be used in ASP.NET Web Applications?

Yes, IronPDF can be used in ASP.NET Web Applications to generate and print PDF documents.

Is prior knowledge of Adobe Acrobat required to use IronPDF?

No, IronPDF allows developers to create PDF files and documents without any prior knowledge of Adobe Acrobat or other third-party application tools.

What platforms is IronPrint compatible with?

IronPrint is compatible across a wide range of platforms, including Windows, macOS, Android, and iOS.

What are the primary features of IronPDF?

IronPDF allows developers to generate, edit, extract, and print PDF document content, merge and split PDFs, edit PDF forms, and enhance security with passwords.

Can I use IronPDF with Windows Forms applications?

Yes, IronPDF can be used with Windows Forms applications to convert URLs into PDF documents and then print them.

What programming languages does IronPDF support?

IronPDF provides features in multiple languages, including C# and VB.NET.

Is IronPDF free for development?

Yes, IronPDF is free for development purposes.

Chaknith Bin
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.
< PREVIOUS
C# Send PDF to Printer (Step-By-Step Tutorial)
NEXT >
C# Print PDF to Specific Printer (Code Example Tutorial)

Ready to get started? Version: 2025.6 just released

View Licenses >