How to print PDF file in .NET Core

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

The Aspose.PDF library allows us to convert PDF files to XPS. This function can be useful for organizing the printing of documents. Let’s take a look at an example for using the default printer.

In this example, we convert PDF document into XPS and add it as a job to the queue of the local printer:

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.

The next code snippet is intended to ensure that the PrintScaling property is correctly applied and saved in the PDF.

The PrintScaling property has been added to the Document class with values ​​Aspose.Pdf.PrintScaling.AppDefault or Aspose.Pdf.PrintScaling.None.

The page scaling option that shall be selected when a print dialog is displayed for this document. Valid values are None, which indicates no page scaling, and AppDefault, which indicates the conforming reader’s default print scaling. If this entry has an unrecognized value, AppDefault should be used. Default value: AppDefault.