title: How to print without showing printdialog in java
body: <p>I am creating a java application where application will print a picture and some text beside it. I have two printers while printing I will select accordingly. I will not show the print dialog for the user to select printer and other stuffs. My code is as follow </p>
  
  <pre><code>PrinterJob job = PrinterJob.getPrinterJob();
  boolean ok = job.printDialog();
  </code></pre>
  
  <p>If I don't skip the line <code>boolean ok = job.printDialog();</code> the text is being printed at the mentioned position in my case (20,20) but if i skip the line my printing is done at a point further away on the printer maybe (120, 120) this mean i need a margin setup. and also give me a code to set printer.</p>