List of usage examples for javax.print StreamPrintServiceFactory lookupStreamPrintServiceFactories
public static StreamPrintServiceFactory[] lookupStreamPrintServiceFactories(DocFlavor flavor, String outputMimeType)
From source file:Main.java
public static void main(String[] argv) throws Exception { StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(null, null);//from www .j a v a2s.co m OutputStream fos = new BufferedOutputStream(new FileOutputStream("outfile.ps")); StreamPrintService service = factories[0].getPrintService(fos); }
From source file:Main.java
public static void main(String[] argv) throws Exception { StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(null, null);/*from ww w . j a va 2 s . c o m*/ factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(DocFlavor.INPUT_STREAM.GIF, DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { OutputStream fos = new BufferedOutputStream(new FileOutputStream("filename.ps")); DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF; StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType()); StreamPrintService service = factories[0].getPrintService(fos); Class[] cats = service.getSupportedAttributeCategories(); for (int j = 0; j < cats.length; j++) { Attribute attr = (Attribute) service.getDefaultAttributeValue(cats[j]); if (attr != null) { String attrName = attr.getName(); String attrValue = attr.toString(); Object o = service.getSupportedAttributeValues(attr.getCategory(), null, null); if (o.getClass().isArray()) { for (int k = 0; k < Array.getLength(o); k++) { Object o2 = Array.get(o, k); System.out.println(o2); }//from ww w .j a va 2 s. co m } } } }
From source file:Main.java
public static void main(String[] argv) throws Exception { OutputStream fos = new BufferedOutputStream(new FileOutputStream("filename.ps")); DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF; StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType()); StreamPrintService service = factories[0].getPrintService(fos); Attribute attr = (Attribute) service.getDefaultAttributeValue(Destination.class); // attr == null if the attribute is not supported if (attr != null) { String attrName = attr.getName(); // Get string representation of default value String attrValue = attr.toString(); }/*from ww w . j ava2 s. c om*/ }
From source file:Main.java
public static void main(String[] argv) throws Exception { OutputStream fos = new BufferedOutputStream(new FileOutputStream("filename.ps")); DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF; StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType()); StreamPrintService service = factories[0].getPrintService(fos); Class category = OrientationRequested.class; Object o = service.getSupportedAttributeValues(category, null, null); if (o == null) { System.out.println("Attribute is not supported"); } else if (o.getClass() == category) { System.out.println("irrelevant"); } else if (o.getClass().isArray()) { System.out.println("array"); for (int i = 0; i < Array.getLength(o); i++) { Object v = Array.get(o, i); System.out.println(v); }// w w w . j a va 2s .co m } }
From source file:Main.java
public static void main(String[] argv) throws Exception { OutputStream fos = new BufferedOutputStream(new FileOutputStream("filename.ps")); DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF; StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType()); StreamPrintService service = factories[0].getPrintService(fos); DocPrintJob job = service.createPrintJob(); job.addPrintJobListener(new MyPrintJobListener()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { OutputStream fos = new BufferedOutputStream(new FileOutputStream("filename.ps")); DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF; StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType()); StreamPrintService service = factories[0].getPrintService(fos); Attribute[] attrs = service.getAttributes().toArray(); for (int j = 0; j < attrs.length; j++) { String attrName = attrs[j].getName(); String attrValue = attrs[j].toString(); System.out.println(attrName); System.out.println(attrValue); }/*from w w w.j a v a 2 s . com*/ }
From source file:StreamOneFour.java
public static void main(String args[]) throws Exception { String infile = "StreamOneFour.java"; DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF; String mimeType = DocFlavor.INPUT_STREAM.POSTSCRIPT.getMimeType(); StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, mimeType);// w ww .j a v a2 s . co m String filename = "out.ps"; FileOutputStream fos = new FileOutputStream(filename); StreamPrintService sps = factories[0].getPrintService(fos); FileInputStream fis = new FileInputStream(infile); DocPrintJob dpj = sps.createPrintJob(); PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); Doc doc = new SimpleDoc(fis, flavor, null); dpj.print(doc, pras); fos.close(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { OutputStream fos = new BufferedOutputStream(new FileOutputStream("filename.ps")); DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF; StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType()); StreamPrintService service = factories[0].getPrintService(fos); DocPrintJob job = service.createPrintJob(); PrintJobAttributeSet set = new HashPrintJobAttributeSet(job.getAttributes()); set.add(new JobMediaSheetsCompleted(0)); job.addPrintJobAttributeListener(new MyPrintJobAttributeListener(), set); }
From source file:Main.java
public static void main(String[] argv) throws Exception { OutputStream fos = new BufferedOutputStream(new FileOutputStream("filename.ps")); DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF; InputStream is = new BufferedInputStream(new FileInputStream("filename.gif")); StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType()); StreamPrintService service = factories[0].getPrintService(fos); DocPrintJob job = service.createPrintJob(); Doc doc = new SimpleDoc(is, flavor, null); PrintJobWatcher pjDone = new PrintJobWatcher(job); job.print(doc, null);//from ww w . j a va2s. co m pjDone.waitForDone(); is.close(); }