This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
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.
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 ]
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.