Print PDF to PDF with Java

This tutorial describes how to print PDF to PDF with Java. It has all the details to set the IDE for using Aspose.PDF for Java to print a PDF file using a virtual PDF printer with Java. It will assist you in configuring the output PDF file by setting various parameters.

Steps to Print to PDF Printer with Java

  1. Set the environment to use Aspose.PDF for Java to print to a PDF
  2. Create the PdfViewer object to load the source PDF file
  3. Set the attributes for auto-resize, auto-rotate, and hiding the print dialog
  4. Create the PdfPrinterSettings object to set the soft printer name
  5. Create the PrintPageSettings object to define the output PDF paper size and margins
  6. Call the printDocumentWithSettings() method to print the loaded PDF to a PDF

Follow these steps for using PDF printer with Java. Create the PdfViewer class object to load the source PDF file, set the flag to auto-resize, auto-rotate, and hide the print page dialog. Create the PdfPrinterSettings and PrintPageSettings objects and set the PDF printer name, paper size, and margins before calling the printDocumentWithSettings() method.

Code to Print to PDF Virtual Printer with Java

This code demonstrates how to use Adobe PDF printer with Java. This code will display the dialog for entering the output PDF file name. Once you set the output PDF name, the loaded PDF will be printed to a PDF and saved on the disk.

This article has taught us how to use Adobe PDF virtual printer with Java. If you want to insert a page break, refer to the article on Insert Page Break in PDF using Java.

 English