title: Print gif using java on a 4x6" paper
body: <p>What is the best way in Java to print a gif given as <code>byte[]</code> or <code>ByteArrayInputStream</code> on a paper with a size of 4x6 inches?</p>
  
  <p>This:</p>
  
  <pre><code>PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
  aset.add(new MediaSize(4, 6, Size2DSyntax.INCH));
  aset.add(new Copies(1));
  PrintService[] pservices =
  PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.GIF, aset);
  
  DocPrintJob printJob = pservices[0].createPrintJob();
  Doc doc = new SimpleDoc(sap.getGraphicImageBytes(), DocFlavor.INPUT_STREAM.GIF, null);
  printJob.print(doc, aset);
  </code></pre>
  
  <p>does not work because the MediaSize is not a PrintRequestAttribute. This should be almost the same as in <a href="http://java.sun.com/javase/6/docs/api/javax/print/package-summary.html" rel="nofollow noreferrer">Package javax.print Description</a></p>