title: Getting the PageFormat of the default Media from a printer in Java
body: <p>I'm looking to get the default Media of the default printer to pull out the PageFormat without calling the pageDialog of a PrinterJob. Currently, my code looks like this:</p>
  
  <pre><code>PrintService defaultPrintService = PrintServiceLookup.lookupDefaultPrintService();
  Media res = (Media)defaultPrintService.getDefaultAttributeValue(Media.class);
  PrintRequestAttributeSet attr_set = new HashPrintRequestAttributeSet();
  attr_set.add(res);
  PrinterJob pj = PrinterJob.getPrinterJob();
  PageFormat pageFormat = pj.getPageFormat(attr_set);
  </code></pre>
  
  <p>It does what I need it to do. Unfortunately, it takes a fairly significant amount of time to do the getDefaultAttributeValue function call. I'm guessing it makes a query to the printer itself? Anyways, the main question is if there is a more efficient, less costly way to find the default Media type of a printer.</p>