• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Java Print service

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am developing on Windows Xp with J2SDK1.4.2. I tried to print a text file using the following code. The code detects the printers, even allows selection of the printer to be used for printing, however when Print button is clicked, it does nothing at all. I do not know what is wrong with the code. My printer is otherwise working fine. Please help me if you can.

No Exceptions or error messages are thrown. But nothing is printed.
Thanks in advance,
shivang.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've never done printing in this fashion and since you didn't give us PrintJobWatcher I can't compile this code, but I'd say that starting out by opening a text file then setting the document type to an image (PNG) is probably a bad idea.

Originally posted by Shivang Vyas:



Have you looked over the Java Print Service API User Guide? There's some examples in there that may prove instructive.
[ December 31, 2003: Message edited by: Joe Ess ]
 
Shivang Vyas
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Joe,
Thanks for your reply. I had added the Print Job Watcher to ensure that the program doesnt end until printing has finished. However, Print job watcher is actually not required. You may do away with the 2 lines that use Print Job watcher and the code should still do printing. The two lines are the instantiation and initialisation of Print Jobwatcher and the call to the method wait till done method.
As regards your opinion about the use of png in the printing format, I have already tried using text_us_plain and so many other formats. But my printers get detected only get detected when I use png, otherwise the code returns null for printers deteced. I am using a Deskjet printer.
I have gone through Java Print Service API thoroughly and only after that I came up with the posting. I am totally clueless as to why my code wont work.
Please see if you could see any reason for it.
Thanks in advance,
Shivang.
 
reply
    Bookmark Topic Watch Topic
  • New Topic