This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

When printing, want to capture fact that printer off line

 
Kathy OConnell
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have written an application that prints to a windows printer (LPT1). The code for the print method is below. It is written in java 1.3.
When running on a windows 2000 machine, if the printer is offline (eg not connected, run out of paper etc) then a message is displayed - eg "device is not connected". However, when running on a Windows 98 machine, no message comes back when the printer is offline. The machine just locks up and has to be turned off before anything can happen.
Is there a way I can capture the fact that the printer is not available and handle it in my program?
Any help would be greatly appreciated!
Thanks
public void printDocket(ReceivalDocketEditAnchor anchor) throws ApplicationException {

try {
FileOutputStream fos = new FileOutputStream(ConfigurationManager.getValue("printer.windows.portname"));
PrintStream ps = new PrintStream(fos);
ps.flush();

DocketObject docketData = new DocketObject(anchor);
ps.print(docketData.createDocket());
ps.write((byte)0xC);
ps.flush();
ps.close();
} catch (Exception e)
{
System.out.println("Exception occurred during printing: " + e);
e.printStackTrace();
}
return;
}
 
And will you succeed? Yes you will indeed! (98 and 3/4 % guaranteed) - Seuss. tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!