Many companies are lessening the use of paper to a large extent. However, there are some scenarios where printing is important. For instance, a system may contain details of online order in PDF format. They need to print PDF while dispatching an online order for delivery. They process items on a large scale so printing each document manually could be quite a task. Aspose.PDF for .NET API, in addition to many other file manipulation and conversion features, supports the efficient printing of PDF files. Let us explore the following use cases related to printing PDF files in .NET applications using C#:
Printing of PDF files can be automated in your .NET applications using C# or VB.net. You can print PDF files by following the simple steps below:
The code snippet below shows how to print PDF file using C#:
If you need to print multiple files because of the nature of your business, then the feature is already supported by Aspose.PDF for .NET API. Printing multiple PDF files, one by one with the above code snippet can be a little slow. Therefore, let us take the PDF printing another step further to make the process easier. Here we will be using List while adding the name of each PDF file to that list. Following steps explain how we will be printing multiple PDF files:
The code snippet shows how to print multiple PDF files using C#:
The feature of printing specific pages of PDF documents is available in the API. We will be considering an example that includes printing multiple page ranges. You need to specify the from and to page numbers as explained in the steps below:
The code snippet below shows how to print specific pages of the document using C#:
A PDF file can be secured and protected by a password. However, the password could be of two types i.e User and Owner password. The PDF files secured with the user password need a password to open and view the encrypted PDF file. On the other hand, the owner password is required to modify the contents of the secured and password protected PDF file. Following steps explain printing of secure PDF:
Following code snippet shows how to print a secured PDF file using C#:
You can print a PDF to specific paper tray with Aspose.PDF for .NET API. For instance, you might want to print a PDF with lot of photos to a different paper tray and textual PDF file to a different paper tray. Follow the steps below to set output tray or bin for printing PDF files:
It is noteworthy here that you can change the name of the printer. Here we will be using Microsoft Print to PDF, as an example. Following code snippet follows these steps and shows how to print a document to a specific paper tray or bin of a printer with C#:
There could be scenarios where you might need to print different pages of one PDF document to different paper trays or bin. For instance, a different paper source for the cover page and different for the other pages. You can certainly follow the below steps to print page ranges to different paper sources within the same printing job:
Following code snippet shows how to follow these steps and print different page ranges to different paper sources or trays using C#:
You can print PDF files to different printers. For example, Microsoft Print to PDF, Microsoft XPS Document Writer, or any physical printer. However, the printing can take a long time duration for huge PDF documents or the printing can fail for some reason. Therefore, the API offers a feature that lets you check print job status with the following steps:
Below code snippet shows how to check print job status or print progress of PDF using C#:
Resultantly, this code snippet prints on the .NET application’s console about printing status of the PDF file:
To sum up, we have learned different approaches and use cases of printing password secured and unsecured PDF files with C# or VB NET in your programming applications. Moreover, we have explored the printing of whole PDF documents. Likewise, we have learned printing some page ranges by specific page trays, bins, or paper sources. Furthermore, we have also checked how to monitor the print status or print progress of documents using C#.