Print gif using java on a 4x6" paper
- by Wienczny
What is the best way in Java to print a gif given as byte[] or ByteArrayInputStream on a paper with a size of 4x6 inches?
This:
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);
does not work because the MediaSize is not a PrintRequestAttribute. This should be almost the same as in Package javax.print Description