Example usage for javax.print.attribute DocAttributeSet add

List of usage examples for javax.print.attribute DocAttributeSet add

Introduction

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

Prototype

public boolean add(Attribute attribute);

Source Link

Document

Adds the specified attribute value to this attribute set if it is not already present, first removing any existing value in the same attribute category as the specified attribute value (optional operation).

Usage

From source file:org.springframework.integration.print.outbound.PrintMessageHandler.java

@Override
protected void handleMessageInternal(Message<?> message) throws Exception {

    if (LOG.isDebugEnabled()) {
        LOG.debug("Printing using printer '" + this.printServiceExecutor.getPrintService().getName() + "'.");
    }/*  ww  w .j  a v  a2 s.  c om*/

    DocAttributeSet das = new HashDocAttributeSet();
    das.add(Chromaticity.MONOCHROME);

    Object payload = message.getPayload();

    final Doc doc = new SimpleDoc(message.getPayload(), docFlavor, das);

    final DocPrintJob job = this.printServiceExecutor.getPrintService().createPrintJob();

    PrintJobMonitor printJobMonitor = new PrintJobMonitor(job);

    job.print(doc, this.printRequestAttributeSet);

    printJobMonitor.waitForDone();

    if (payload instanceof InputStream) {
        ((InputStream) payload).close();
    }

}