File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
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);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to print to specific printer and using specifc margins?