wood burning stoves 2.0*
The moose likes Java in General and the fly likes how to print to specific printer and using specifc margins? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "how to print to specific printer and using specifc margins?" Watch "how to print to specific printer and using specifc margins?" New topic
Author

how to print to specific printer and using specifc margins?

Sarad Mohanan
Greenhorn

Joined: May 22, 2012
Posts: 5
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);
 
GeeCON Prague 2014
 
subject: how to print to specific printer and using specifc margins?