Java Language Java Print Service Defining print request attributes

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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).



Got any Java Language Question?