Java Language Java Print Service Defining print request attributes


Example

Sometimes we need to determine some aspects of the print request. We will call them attribute.

Are examples of print request attributes:

  • amount of copies (1, 2 etc),
  • orientation (portrait or landscape)
  • chromacity (monochrome, color)
  • quality (draft, normal, high)
  • sides (one-sided, two-sided etc)
  • and so on...

Before choosing one of them and which value each one will have, first we need to build a set of attributes:

PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();

Now we can add them. Some examples are:

pras.add(new Copies(5));
pras.add(MediaSize.ISO_A4);
pras.add(OrientationRequested.PORTRAIT);
pras.add(PrintQuality.NORMAL);

The pras object now can be sent to the print job request (see Creating a print job from a print service).