List of usage examples for javax.print.attribute.standard Chromaticity MONOCHROME
Chromaticity MONOCHROME
To view the source code for javax.print.attribute.standard Chromaticity MONOCHROME.
Click Source Link
From source file:JuliaSet3.java
public void print() { // Get a list of all printers that can handle Printable objects. DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; PrintService[] services = PrintServiceLookup.lookupPrintServices(flavor, null); // Set some define printing attributes PrintRequestAttributeSet printAttributes = new HashPrintRequestAttributeSet(); printAttributes.add(OrientationRequested.LANDSCAPE); // landscape mode printAttributes.add(Chromaticity.MONOCHROME); // print in mono // Display a dialog that allows the user to select one of the // available printers and to edit the default attributes PrintService service = ServiceUI.printDialog(null, 100, 100, services, null, null, printAttributes); // If the user canceled, don't do anything if (service == null) return;/* www . j av a2s . c o m*/ // Now call a method defined below to finish the printing printToService(service, printAttributes); }
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() + "'."); }//w ww. j a v a 2s .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(); } }