title: Java printing of 90x20mm image with Epson TM-C3500 not working
body: <p>So as I am developing an application using java I want the functionality to print an 950x250 png image with an Epson TM-C3500. The labels I use are from the 90x20 mm size. </p>
  
  <p>Printing using another windows application fits perfectly on the label but if I do it with my application I will get very weird results with prints on multiple labels and so on. </p>
  
  <p>I tried a lot of things I found on this site but didn't manage to find a solution. Does anyone have some experience with this or knows how to do this? I think I could probably scale my png but I have no clue how. </p>
  
  <p>my current code:</p>
  
  <pre><code>    PrintService[] factories = PrinterJob.lookupPrintServices();
  
  
      AttributeSet aset = new HashAttributeSet();
      aset.add(new PrinterName("EPSON TM-C3500 Ver2", null));
      PrintService[] pservices =
              PrintServiceLookup.lookupPrintServices(null, aset);
  
      PrinterJob printerJob = PrinterJob.getPrinterJob();
      printerJob.setPrintService(pservices[0]);
  
      PrintRequestAttributeSet attributeSet = new HashPrintRequestAttributeSet();
      attributeSet.add(OrientationRequested.LANDSCAPE);
      attributeSet.add(new MediaPrintableArea(0,0,90,20, MediaPrintableArea.MM));
  
      BufferedImage image = ImageIO.read(new File("C:\\Users\\Simon\\Downloads\\Distribib-master\\testprinter\\src\\com\\company\\label (1).png"));
      printerJob.setPrintable(new Printable() {
          @Override
          public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
              if (pageIndex !=0) {
                  return NO_SUCH_PAGE;
              }
  
              graphics.drawImage(image,0,0, image.getWidth(),image.getHeight(),null);
              return PAGE_EXISTS;
          }
      });
      try {
          printerJob.print(attributeSet);
      } catch (PrinterException e1)  {
          e1.printStackTrace();
      }
  </code></pre>
  
  <p>I tried numerous things. Like translating the image to an appropriate size, selecting supported MediaSize by getting it through "getSupportedAttributeValues", trying to change pageFormat, ... </p>
  
  <p>But these things were always just trying out because I found the documentation on printing png's very confusing.  </p>