• 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
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

When printing, want to capture fact that printer off line

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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;
}
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic