C# PDF Print Library
How to send, print Adobe pdf file to printer without Acrobat Reader installed using C# .net
.NET PDF Document Printer API SDK for Visual C# .NET Class Applications
In this tutorial, you learn how to print PDF programmatically using C#
- Select a specific printer or use default printer
- Print a PDF document or PDF stream object
- Choose printing PDF pages range
- Choose printing resolution
- No need to install Adobe Reader
- Easy to enable printing function in ASP.NET MVC, Windows Forms application using C#
How to print a PDF file programmatically using C#
- A best PDF printer control for Visual Studio .NET and compatible with C# programming language
- Quicken PDF printer library allows C# users to batch print PDF file in .NET framework
- Free library control SDK for automatically printing PDF document online in ASP.NET WebForm application
- Standalone and easy-to-use API allows C# developers to send a source PDF document file to an actual physical printer device
- Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint
- C# source code for printing PDF adobe PDF file in .NET Windows Forms project
- Provide variety of printing options, like like number of copies, PDF document printing orientation, PDF document printing paper size and PDF document printing resolution
- Fully-featured PDF document printing SDK can help to easily create a custom web-based client-server printing application or a custom Windows Forms project
How to print a PDF file to a specific printer using C#
The following steps show how to print a PDF document to a selected printer.
- Create a PDFPrinterOption object with the specified printer name
- Print a PDF file by calling Print method of the class PDFPrinter
String inputFilePath = @"C:\demo_1.pdf";
PDFPrinterOption op = new PDFPrinterOption();
// Set printer name for printing
op.PrinterName = "Selected printer name";
PDFPrinter.Print(inputFilePath, new PDFPrintSetting(), op);
About printing options
You can apply the following options to choose printing pages range and output resolutions in 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 pages range using C#
The following C# source code shows how to choose a range of PDF pages to print
String inputFilePath = Program.RootPath + "\\" + "1.pdf";
// print a range of pages from page index 1 to 2
PDFPrintSetting setting = new PDFPrintSetting();
setting.StartPageIndex = 1;
setting.StopPageIndex = 2;
PDFPrinter.Print(inputFilePath, setting, new PDFPrinterOption());
How to change the resolution of the PDF printing output using C#
The following C# source code shows how to set the printing PDF pages resolution
String inputFilePath = Program.RootPath + "\\" + "1.pdf";
// set print resolution to 600 dpi
PDFPrintSetting setting = new PDFPrintSetting();
setting.StartPageIndex = 1;
setting.StopPageIndex = 1;
setting.PageResolution = 600;
PDFPrinter.Print(inputFilePath, setting, new PDFPrinterOption());
How to print PDF from byte array using C#
The following C# source code shows how to print PDF from byte array object
String inputFilePath = @"C:\demo_1.pdf";
byte[] dataBytes = File.ReadAllBytes(inputFilePath);
PDFPrinterOption op = new PDFPrinterOption();
// Set printer name for printing
op.PrinterName = "Microsoft Print to PDF";
PDFPrinter.Print(dataBytes, new PDFPrintSetting(), op);
How to print PDF from file stream object using C#
The following C# source code shows how to print PDF from a FileStream object in .net application
String inputFilePath = @"C:\demo_1.pdf";
using (FileStream fs = File.Open(inputFilePath, FileMode.Open, FileAccess.Read))
{
PDFPrinterOption op = new PDFPrinterOption();
// Set printer name for printing
op.PrinterName = "Microsoft Print to PDF";
PDFPrinter.Print(fs, new PDFPrintSetting(), op);
}
How to print PDF from PDFDocument object using C#
The following C# source code shows how to print PDF from PDFDocument object in .net application
String inputFilePath = @"C:\demo_1.pdf";
PDFDocument doc = new PDFDocument(inputFilePath);
// Save PDFDocument object to data bytes
byte[] dataBytes = doc.SaveToBytes();
PDFPrinterOption op = new PDFPrinterOption();
// Set printer name for printing
op.PrinterName = "Microsoft Print to PDF";
PDFPrinter.Print(dataBytes, new PDFPrintSetting(), op);