Print without a DialogTag(s): IO


JobAttributes  theJobAttribs  = new JobAttributes();
PageAttributes thePageAttribs = new PageAttributes();

theJobAttribs.setDialog(JobAttributes.DialogType.NONE);
theJobAttribs.setPrinter("HP DeskJet 610C"); // the printer to be used
PrintJob myJob = getToolkit().getPrintJob(this, "PrintJob", theJobAttribs, thePageAttribs);

if (myJob != null) {
  Graphics g = myJob.getGraphics();
  if (g != null) {
    String s = myArea.getText(); // what you like to print
    printText(myJob, g, s);
    g.dispose();
  }
}
myJob.end();

blog comments powered by Disqus