Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to print to specific printer and using specifc margins?  RSS feed

Sarad Mohanan
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.setPrinter("HP DeskJet 610C"); // the printer to be used
PrintJob myJob = getToolkit().getPrintJob(this, "PrintJob", theJobAttribs, thePageAttribs);
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!