Example usage for javax.print.attribute HashDocAttributeSet HashDocAttributeSet

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

Introduction

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

Prototype

public HashDocAttributeSet() 

Source Link

Document

Construct a new, empty hash doc attribute set.

Usage

From source file:Main.java

public static void main(String args[]) throws Exception {
    String filename = args[0];//from  w  w  w  .j  a v a 2s .c o  m
    DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
    PrintService printService = PrintServiceLookup.lookupDefaultPrintService();
    DocPrintJob job = printService.createPrintJob();
    PrintJobListener listener = new PrintJobAdapter() {
        public void printDataTransferCompleted(PrintJobEvent e) {
            System.out.println("Good-bye");
            System.exit(0);
        }
    };
    job.addPrintJobListener(listener);
    PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
    FileInputStream fis = new FileInputStream(filename);
    DocAttributeSet das = new HashDocAttributeSet();
    Doc doc = new SimpleDoc(fis, flavor, das);
    job.print(doc, pras);
    Thread.sleep(10000);
}

From source file:OneFourDialog.java

public static void main(String args[]) throws Exception {
    String filename = args[0];/*from  w w  w .  j  av  a2  s . com*/
    PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
    DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
    PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor, pras);
    PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
    PrintService service = ServiceUI.printDialog(null, 200, 200, printService, defaultService,
            DocFlavor.INPUT_STREAM.GIF, pras);
    if (service != null) {
        DocPrintJob job = service.createPrintJob();
        PrintJobListener listener = new PrintJobAdapter() {
            public void printDataTransferCompleted(PrintJobEvent e) {
                System.exit(0);
            }
        };
        job.addPrintJobListener(listener);
        FileInputStream fis = new FileInputStream(filename);
        DocAttributeSet das = new HashDocAttributeSet();
        Doc doc = new SimpleDoc(fis, flavor, das);
        job.print(doc, pras);
        Thread.sleep(10000);
    }
}

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

/**
 * @param args//from   ww  w.j a v a2 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();
    }
}

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() + "'.");
    }/*from   w ww .ja  v  a  2s  . c o m*/

    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();
    }

}