VB.NET PDF Printing Library
How to print a PDF file to network printer using VB.NET without Adobe Reader
VB.NET PDF Document SDK for PDF Printing in Visual Basic .NET Program
In this vb.net tutorial, you will learn how to print a PDF document using VB.NET code in Windows Forms, WPF applications.
- Print a PDF to a default, or selected network printer
- Support print resulution and PDF page ranges settings
- No need to install Adobe Reader
- Easy to enable printing function in Windows Forms, WPF applications, ASP.NET using VB.NET
How to print PDF file using Visual Basic .NET
- Standalone VB.NET PDF document printer SDK that is programmed in 100% managed VB.NET code
- Robust VB.NET document printing solution that can be used in .NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.8
- Quickly print all target PDF document pages or one specified PDF page by VB.NET code
Print a PDF file using the selected printer using VB.NET
The steps and vb.net source code below show how to print a PDF document using a selected printer.
- Create a PDFPrinterOption object with the target printer name
- Print a PDF file by calling Print method of the class PDFPrinter
Dim inputFilePath As String = "C:\demo_1.pdf"
Dim op As PDFPrinterOption = New PDFPrinterOption()
' Set printer name for printing
op.PrinterName = "Microsoft Print to PDF"
PDFPrinter.Print(inputFilePath, New PDFPrintSetting(), op)
Apply PDF Print Options in VB.NET Code
About PDF printing options
You can apply the following options in vb.net class PDFPrintSetting.
- StartPageIndex: Index of the first page to print. Default: 0
- StopPageIndex: Index of the last page to print.
-1 means to print all remained pages from the first one.
Default: -1
- PageResolution: Conversion resolution for the page (in pixel per inch).
Default: 300 (dpi)
How to choose printing PDF page range using Visual Basic .NET
The following Visual Basic source code shows how to choose PDF page ranges for printing.
Dim inputFilePath As String = "C:\1.pdf"
' print a range of pages from page index 1 to 2
Dim setting As PDFPrintSetting = New PDFPrintSetting()
setting.StartPageIndex = 1
setting.StopPageIndex = 2
PDFPrinter.Print(inputFilePath, setting, New PDFPrinterOption())
How to change the resolution of the PDF printing output in Visual Basic .NET
The vb.net source code below explains how to set the printing PDF pages resolution.
Dim inputFilePath As String = "C:\1.pdf"
' set print resolution to 600 dpi
Dim setting As PDFPrintSetting = New PDFPrintSetting()
setting.StartPageIndex = 1
setting.StopPageIndex = 1
setting.PageResolution = 600
PDFPrinter.Print(inputFilePath, setting, New PDFPrinterOption())