List of usage examples for javax.print PrintService getSupportedDocFlavors
public DocFlavor[] getSupportedDocFlavors();
From source file:Main.java
static public void main(String args[]) throws Exception { PrintService pss[] = PrintServiceLookup.lookupPrintServices(null, null); for (int i = 0; i < pss.length; ++i) { System.out.println(pss[i]); PrintService ps = pss[i]; PrintServiceAttributeSet psas = ps.getAttributes(); Attribute attributes[] = psas.toArray(); for (int j = 0; j < attributes.length; ++j) { Attribute attribute = attributes[j]; System.out.println(" attribute: " + attribute.getName()); if (attribute instanceof PrinterName) { System.out.println(" printer name: " + ((PrinterName) attribute).getValue()); }// www. j a v a 2 s.co m } DocFlavor supportedFlavors[] = ps.getSupportedDocFlavors(); for (int j = 0; j < supportedFlavors.length; ++j) { System.out.println(" flavor: " + supportedFlavors[j]); } } }
From source file:org.efaps.tests.Printer.java
/** * @param args// w ww . j a v a 2s .c om */ public static void main(final String[] args) { final AttributeSet aset = new HashAttributeSet(); aset.add(new PrinterName("HP-LaserJet-100-colorMFP-M175nw", null)); final PrintService[] pservices = PrintServiceLookup.lookupPrintServices(null, aset); for (final PrintService serv : pservices) { System.out.println(serv); } try { final PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); // pras.add(new Copies(2)); final PrintService pservice = getPrintService4Name("HP-LaserJet-100-colorMFP-M175nw"); pservice.getSupportedDocFlavors(); final DocPrintJob job = pservice.createPrintJob(); final DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE; final String filename = "/home/janmoxter/Downloads/Notas_de_Pedido_null.DOCX"; final FileInputStream fis = new FileInputStream(filename); final DocAttributeSet das = new HashDocAttributeSet(); final Doc doc = new SimpleDoc(fis, flavor, das); job.print(doc, pras); } catch (final FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (final PrintException e) { // TODO Auto-generated catch block e.printStackTrace(); } }