Example usage for javax.print.attribute HashPrintServiceAttributeSet HashPrintServiceAttributeSet

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

Introduction

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

Prototype

public HashPrintServiceAttributeSet(PrintServiceAttributeSet attributes) 

Source Link

Document

Construct a new attribute set, initially populated with the values from the given set where the members of the attribute set are restricted to the PrintServiceAttribute interface.

Usage

From source file:org.openvpms.web.component.im.till.CashDrawer.java

/**
 * Opens the drawer.//from  w w  w  .  jav a 2  s . c o  m
 *
 * @throws PrintException if the drawer cannot be opened
 */
public void open() throws PrintException {
    AttributeSet attrSet = new HashPrintServiceAttributeSet(new PrinterName(printer, null));
    PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, attrSet);
    if (printServices.length == 0) {
        throw new PrintException(Messages.format("till.drawerCommand.printernotfound", printer));
    }
    DocPrintJob job = printServices[0].createPrintJob();
    DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
    Doc doc = new SimpleDoc(command, flavor, null);
    job.print(doc, null);
}