Example usage for javax.print.attribute HashAttributeSet HashAttributeSet

List of usage examples for javax.print.attribute HashAttributeSet HashAttributeSet

Introduction

In this page you can find the example usage for javax.print.attribute HashAttributeSet HashAttributeSet.

Prototype

public HashAttributeSet() 

Source Link

Document

Construct a new, empty attribute set.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
    PrintService service = PrintServiceLookup.lookupDefaultPrintService();

    services = PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.GIF, null);

    AttributeSet aset = new HashAttributeSet();
    aset.add(new PrinterName("HP LaserJet", null));
    services = PrintServiceLookup.lookupPrintServices(null, aset);

    aset = new HashAttributeSet();
    aset.add(ColorSupported.SUPPORTED);
    services = PrintServiceLookup.lookupPrintServices(null, aset);

}

From source file:org.efaps.tests.Printer.java

/**
 * @param args// w  ww. java2  s .  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();
    }
}