| Start |
|---|
| Building the Doc that will be printed
Every
Before creating the So now, we have to choose a Now, we can create a new instance of The |
| Discovering the available print services To discovery all the available print services, we can use the This program, when executed on a Windows environment, will print something like this: |
| Defining print request attributes Sometimes we need to determine some aspects of the print request. We will call them attribute. Are examples of print request attributes:
Before choosing one of them and which value each one will have, first we need to build a set of attributes: Now we can add them. Some examples are: The |
| Discovering the default print service To discovery the default print service, we can use the |
| Creating a print job from a print service A print job is a request of printing something in a specific print service. It consists, basically, by:
After picking-up the right print service instance, we can request the creation of a print job: The The And the
The print method may throw a |
| Listening print job request status change For the most printing clients, is extremely useful to know if a print job has finished or failed. The Java Print Service API provide some functionalities to get informed about these scenarios. All we have to do is:
When the print job state changes, we will be notified. We can do anything is needed, for example:
In the example bellow, we will log every print job status change: Finally, we can add our print job listener implementation on the print job before the print request itself, as follows: The PrintJobEvent pje argumentNotice that every method has a Will return a Another way to achieve the same goalAnother option to achieve the same goal is extending the Notice that we override only some specific methods. As the same way in the example implementing the interface |
Read Article
https://develop.horje.com/learn/1434/reference