How to Print a PDF Document in Java

Learn about PDF printing in Java.

By Lokesh Vardhan Yadav

The PDF printer component in Gnostice PDFOne (for the Java™ platform) was introduced in February 2008 with Version 2.0. Since then, the printer component has seen several improvements. In this article, we will see a code snippet that shows you how to leverage many of those enhancements.

To print a PDF document:

Create a printer object

Set a PdfDocument object of a loaded PDF document to the printer object.

Select a physical printer for use with the printer object.

Set printer properties. (Perform this step after selecting the physical printer. Only then will you be able to override loaded defaults of the physical printer.)

Gnostice StarDocs is a scalable, fault-tolerant document-processing server
solution, designed to be the central go-to place for all kinds of electronic
document-processing work. StarDocs includes a web application (as seen at
stardocs.gnostice.com) that
frees your end-users from the need to have format-specific software to merge,
split, redact, convert, edit, and sign documents - all they need is a network
connection and a HTML5 browser. StarDocs provides a REST-based API that your
developers can use to add document-processing functions to a variety of
software applications. As the REST API is platform agnostic, your developers
can write software on a wide variety of platforms - from desktop to mobile
devices to Web services in any development language. To get them started
quickly, StarDocs is supported by language-specific native SDK. StarDocs
document server has load-balancing built-in and is designed to be scalable
across enterprise Intranets and the Internet. StarDocs is available as
packaged software for on-premise hosting and also as a subscription-based
cloud service.