Article View: borland.public.jbuilder.java.language
Article #443Java print service API
From: 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
Technical Details
Message-ID:
<432a8a39@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: f74b3,9f65bb999164dd49,start X-Google-Attributes: gidf74b3,public X-Google-Language: ENGLISH,ASCII-7-bit From: "apostolish" <apostolis@orbis.gr> Newsgroups: borland.public.jbuilder.java.language Subject: Java print service API Date: Fri, 16 Sep 2005 12:06:44 +0300 Lines: 43 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 NNTP-Posting-Host: 193.92.230.163 Message-ID: <432a8a39@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1126861369 193.92.230.163 (16 Sep 2005 02:02:49 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail