Article View: be.comp.programming
Article #5395Re: Problems with printing in Java
From: Jef Melis
Date: Sun, 13 Apr 2003 19:10
Date: Sun, 13 Apr 2003 19:10
84 lines
3510 bytes
3510 bytes
Is there no one that could help me with these problems ??? It is very
important for me !!
Kind regard,
Jef
"Jef Melis" <tmp-05@pandora.be> wrote in message
news:dZRka.38173$t_2.3622@afrodite.telenet-ops.be...
> Hi,
>
> I have the following problems :
>
> 1. Is there a way to retreive the status of a printer in Windows using
Java
> ??? I want to find out if the printer is out_of_paper, toner_low,
> unreachable, ... and those stuff. Anybody an idea ??? (It should only work
> under Windows !!)
>
> 2. This problem concerns the code snippet. The purpose is to print a
> postscript file x times on a Postscript printer. When I set the line
> "aset.add(new Copies(nrOfCopies));" in comment, it works and prints the
> document 1 time. When I uncomment this line it doesn't find the
PrintService
> and therefor doesn't do anything.
> Does anyone have an explanation for this ??? Or even better, does anyone
can
> tell me how I have to do this correctly ???
>
> ./..
> public void print() throws Exception
> {
> String filename = "test.ps";
> int nrOfCopies = 4;
> String printService = "HP LaserJet 2200-PS";
>
> // PrintDoc is an implementation of Doc
> Doc pdoc = new PrintDoc(filename);
>
> // Gets the format of the document
> DocFlavor flavor = pdoc.getDocFlavor();
>
> // Creates a new attribute set
> PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
>
> /*
> * WARNING : When activating the following rule, there is a problem
with
> finding the 'Printservice'
> * WE NEED TO CHECK THIS OUT !!!
> */
> // aset.add(new Copies(nrOfCopies));
>
> // Locates printer to print the specified document format
> // with the specified attribute set
> PrintService service = null;
>
> PrintService services[] =
PrintServiceLookup.lookupPrintServices(flavor,
> aset);
>
> for (int i = 0; i < services.length; i++)
> {
> service = services[i];
>
> if (service.getName().equals(iPrintservice))
> break;
> }
>
> if (service != null)
> {
> DocPrintJob job = service.createPrintJob();
> job.print(pdoc, aset);
> }
> else
> {
> throw new PrintException("PrintService not found : " +
iPrintservice);
> }
> }
> ../.
>
>
>
Technical Details
Message-ID:
<FCima.44852$t_2.4170@afrodite.telenet-ops.be>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!216.166.71.118.MISMATCH!small1.nntp.aus1.giganews.com!border3.nntp.aus1.giganews.com!nntp.giganews.com!newsfeed.cwix.com!ossa.telenet-ops.be!afrodite.telenet-ops.be.POSTED!not-for-mailReferences:
<dZRka.38173$t_2.3622@afrodite.telenet-ops.be>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fcea4,7c215e422a6dafcd X-Google-Attributes: gidfcea4,public X-Google-ArrivalTime: 2003-04-13 12:10:45 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!216.166.71.118.MISMATCH!small1.nntp.aus1.giganews.com!border3.nntp.aus1.giganews.com!nntp.giganews.com!newsfeed.cwix.com!ossa.telenet-ops.be!afrodite.telenet-ops.be.POSTED!not-for-mail From: "Jef Melis" <tmp-05@pandora.be> Newsgroups: be.comp.programming References: <dZRka.38173$t_2.3622@afrodite.telenet-ops.be> Subject: Re: Problems with printing in Java Lines: 86 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: <FCima.44852$t_2.4170@afrodite.telenet-ops.be> Date: Sun, 13 Apr 2003 19:10:29 GMT NNTP-Posting-Host: 213.119.60.105 X-Complaints-To: abuse@telenet.be X-Trace: afrodite.telenet-ops.be 1050261029 213.119.60.105 (Sun, 13 Apr 2003 21:10:29 MET DST) NNTP-Posting-Date: Sun, 13 Apr 2003 21:10:29 MET DST Organization: Telenet Internet