Skip to footer content

How to Print PDF Files in Java

In this Java tutorial, we explore how to print PDF files using the IronPDF library. We start by setting up a Maven project and adding the necessary dependencies to the pom.xml file, specifically impdf and slf4j. The main Java class, App, contains a main method that initiates the process.

A new PDF document object is created, and the path to the PDF file is specified. The tutorial demonstrates two methods for printing PDFs: using a customizable print dialog box and printing directly without user intervention. The latter is achieved through the printWithoutDialog() method, while the former uses print() to allow users to adjust settings.

The code execution involves opening a print dialog box for customizable print settings, followed by a save dialog box for saving the file. If the laptop is not connected to a printer, Windows defaults to exporting the file as a PDF. The tutorial concludes with an invitation to subscribe for more tutorials and offers support for any queries.

Further Reading: How To Print PDF Files Using Java

Darrius Serrant
Full Stack Software Engineer (WebOps)

Darrius Serrant holds a Bachelor’s degree in Computer Science from the University of Miami and works as a Full Stack WebOps Marketing Engineer at Iron Software. Drawn to coding from a young age, he saw computing as both mysterious and accessible, making it the perfect medium for creativity and problem-solving.

At Iron Software, Darrius enjoys creating new things and simplifying complex concepts to make them more understandable. As one of our resident developers, he has also volunteered to teach students, sharing his expertise with the next generation.

For Darrius, his work is fulfilling because it is valued and has a real impact.

Install with Maven

Version: 2025.6.5

<dependency>
  <groupId>com.ironsoftware</groupId>
  <artifactId>ironpdf</artifactId>
  <version>2025.6.5</version>
</dependency>

Report an Issue