Building the Doc that will be printed

suggest change

Doc is an interface and the Java Print Service API provide a simple implementation called SimpleDoc.

Every Doc instance is basically made of two aspects:

Before creating the Doc object, we need to load our document from somewhere. In the example, we will load an specific file from the disk:

FileInputStream pdfFileInputStream = new FileInputStream("something.pdf");

So now, we have to choose a DocFlavor that matches our content. The DocFlavor class has a bunch of constants to represent the most usual types of data. Let’s pick the INPUT_STREAM.PDF one:

DocFlavor pdfDocFlavor = DocFlavor.INPUT_STREAM.PDF;

Now, we can create a new instance of SimpleDoc:

Doc doc = new SimpleDoc(pdfFileInputStream, pdfDocFlavor , null);

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

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Java Print Service:
* Building the Doc that will be printed

Table Of Contents
8 Arrays
10 Maps
11 Strings
25 JAXB
29 Enums
32 Audio
41 Scanner
63 Logging
75 Lists
78 Sets
89 JAX-WS
96 XJC
98 Process
106 Modules
114 Applets
122 JNDI
139 JavaBean
141 Literals
144 Packages
150 JMX
153 JShell
159 Sockets
167 Enum Map
170 Java Print Service
175 Hashtable
177 SortedMap