Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to print to specific printer and using specifc margins?

 
Sarad Mohanan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to print to specific printer and margins(i.e. i dont want to print by showing print dialog to the user). my contents are in a JTextArea so i directly use JTextArea.print(MessageFormat headerFormat, MessageFormat footerFormat, boolean showPrintDialog, PrintService service, PrintRequestAttributeSet attributes, boolean interactive) by passing parameters as ja.print(null, null, false, null, null, false). can any one tell me how to do printing and specify margins in the given method. i find this methods to do this job but dont know how to use it

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);
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic