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;
}