title: Fit to page when printing an image
body: <p>I am printing a PNG image on the printer. The image is printed in the center of the page and does not fill the whole page. I tried increasing the size of the image but its always in the center of the page. Any ideas how to make it fit the page?</p>
  
  <pre><code>psStream = new URL(url).openStream();
                  if (psStream == null) {
                      return "Unable to fetch image";
                  }
                  DocFlavor flavor = DocFlavor.INPUT_STREAM.PNG;
                  Doc myDoc = new SimpleDoc(psStream, flavor, null);
                  PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
                  PrintServiceAttributeSet attributes = new HashPrintServiceAttributeSet();
                  attributes.add(new PrinterName(printData.printer, Locale.getDefault()));
                  final PrintService[] printServices = PrintServiceLookup.lookupPrintServices(flavor, attributes);
                  if (printServices.length == 0) {
                      return "Could not find printer " + printData.printer;
                  } else {
                      myPrinter = printServices[0];
                      DocPrintJob job = myPrinter.createPrintJob();
  
                      try {
                          job.print(myDoc, aset);
                          return null;
                      } catch (Exception e) {
                          e.printStackTrace();
                          return "Could not print : " + e.getMessage();
                      }
  
                  }
  </code></pre>