title: Jasper print from Java without Dialog
body: <pre><code>String Report = "C:\\Template\\"+file_name+".jrxml";//my Jasper report file
  JasperPrint print = JasperFillManager.fillReport(Report,null,con);
  PrinterJob job = PrinterJob.getPrinterJob();
  /* Create an array of PrintServices */
  PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
  int selectedService = 0;
  /* Scan found services to see if anyone suits our needs *
  for(int i = 0; i &lt; services.length;i++)
  {
      if(services[i].getName().toUpperCase().contains("Your printer's name"))
      {
          /*If the service is named as what we are querying we select it */
               selectedService = i;
      }
  }
  job.setPrintService(services[selectedService]);
  PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
  MediaSizeName mediaSizeName = MediaSize.findMedia(4,4,MediaPrintableArea.INCH);
  printRequestAttributeSet.add(mediaSizeName);
  printRequestAttributeSet.add(new Copies(1));
  JRPrintServiceExporter exporter;
  exporter = new JRPrintServiceExporter();
  exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
  /* We set the selected service and pass it as a paramenter */
  exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE, services[selectedService]);
  exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, services[selectedService].getAttributes());
  exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, printRequestAttributeSet);
  exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);
  exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE);
  exporter.exportReport();
  </code></pre>
  
  <p>Using the above code to print jasper from java. If I do the above, the print is working fine and it is opening the AWT Dialog where the default values are set, presumably from the system printer (only one default printer). I want to avoid opening the dialog  by changing to <code>exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.FALSE);</code></p>
  
  <p>But when I do this, it ignores the page layout,size,margins and it takes some default (probably A4 size). How to rectify this ?</p>