Thread View: borland.public.jbuilder.java.language
1 messages
1 total messages
Started by apostolish
Fri, 16 Sep 2005 09:06
Java print service API
Author: apostolish
Date: Fri, 16 Sep 2005 09:06
Date: Fri, 16 Sep 2005 09:06
39 lines
2103 bytes
2103 bytes
Hello, i have a simple example but when i execute it, nothing prints. Can
anyone explain , why;
import java.io.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
...........
DocFlavor flavor = DocFlavor.INPUT_STREAM.TEXT_PLAIN_HOST;
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(MediaSizeName.ISO_A4);
aset.add(new Copies(1));
PrintService[] pservices =
PrintServiceLookup.lookupPrintServices(flavor, aset);
// the pservices.length is 0. why?
// the printers that i have are:
// EPSON STYLUS COLOR 900
// HP LASERJET 6P
// OFFICEJET 6100 SERIES
if (pservices.length > 0) {
System.out.println("selected printer " + pservices[0].getName());
DocPrintJob pj = pservices[0].createPrintJob();
try {
// test.txt is a simple text/plain file
FileInputStream fis = new FileInputStrea("c://tmp//test.txt");
Doc doc = new SimpleDoc(fis, flavor, null);
pj.print(doc, aset);
}
catch (IOException ie) {
System.err.println(ie);
}
catch (PrintException e) {
System.err.println(e);
}
Is it possible none of these printers to support this 'flavor'?
Did i do anything wrong?
Thanks, in advance
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads