title: Java Printing to specific page size using label printer
body: <p>I am trying to use a label printer (EPSON TM-T88V to be specific), to spit out PNG images.</p>
  
  <p>I can get it to print fine, except when I am printing an image dimensions (220x175 at 72dpi to be specific again) there is a wad of white space on top of the image printed, which I think is a waste of paper.</p>
  
  <p>Any ideas on how I can minimize the paper waste? I want it to print just the image, minimal whitespace and then cut the paper.</p>
  
  <p>Here is my code</p>
  
  <pre><code>    AttributeSet aset = new HashAttributeSet();
      aset.add(new PrinterName(printerName, null));
      /* locate a print service that can handle the request */
      PrintService[] services = PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.PNG, aset);
  
      if (services.length &gt;= 1) {
          /* create a print job for the chosen service */
          DocPrintJob pj = services[0].createPrintJob();
  
          DocAttributeSet das = new HashDocAttributeSet();
          das.add(PrintQuality.HIGH);
          das.add(MediaSizeName.ISO_A7); // I know the problem is here somewhere. This Media size seems to work best currently
  
          try {
              /* 
              * Create a Doc object to hold the print data.
              */
              Doc doc = new SimpleDoc(imageByteIs, DocFlavor.INPUT_STREAM.PNG, das);
  
              /* print the doc as specified */
              pj.print(doc, null);
  
          } catch (PrintException e) { 
              System.err.println(e);
          }
      }
  </code></pre>