Printing PDF in .NET Framework

The following code snippet also work with Aspose.PDF.Drawing library.

This article describes how to Print PDF File to Default Printer using Printer and Page Settings in C#.

The PdfViewer class allows you to print a PDF file to the default printer. You need to create a PdfViewer object and open the PDF using the BindPdf method. To specify different print settings, use the PageSettings and PrinterSettings classes. Finally, call the PrintDocumentWithSettings method to print the PDF to the default printer. The following code snippet shows how to print PDF to the default printer with printer and page settings.

In order to display a print dialog, try using the following code snippet:

Choosing paper source by PDF page size

Since the 24.4 release, choosing paper source by PDF page size in the print dialog is possible. The next code snippet enables picking a printer tray based on the PDF’s page size.

This preference can be switched on and off using the Document.PickTrayByPdfSize property.