| User Guide > How to Work with... > PDF > How to... > Print a PDF |
Native PDF document printing renders the document content directly to the printer, so it is fast and requires less memory.
The following is a sample method that illustrates how to print a PDF from a Windows Form project using the ImGearPDFDocument.Print() method:
| C# |
Copy Code |
|---|---|
using System.Drawing.Printing; public void PrintPDF(ImGearDocument igDocument) { using (ImGearPDFDocument igPDFDocument = (ImGearPDFDocument)igDocument) { ImGearPDFPrintOptions printOptions = new ImGearPDFPrintOptions(); PrintDocument printDocument = new PrintDocument(); // Use default Windows printer. printOptions.DeviceName = printDocument.PrinterSettings.PrinterName; // Print all pages. printOptions.StartPage = 0; printOptions.EndPage = igDocument.Pages.Count; igPDFDocument.Print(printOptions); } return; } | |
| VB.NET |
Copy Code |
|---|---|
Imports System.Drawing.Printing
Public Sub PrintPDF(igDocument As ImGearDocument)
Using igPDFDocument As ImGearPDFDocument = DirectCast(igDocument, ImGearPDFDocument)
Dim printOptions As New ImGearPDFPrintOptions()
Dim printDocument As New PrintDocument()
' Use default Windows printer.
printOptions.DeviceName = printDoc.PrinterSettings.PrinterName
' Print all pages.
printOptions.StartPage = 0
printOptions.EndPage = igDocument.Pages.Count
igPDFDocument.Print(printOptions)
End Using
Return
End Sub | |
![]() |
The .NET reference System.Drawing.dll is required for this snippet. |