Package javax.print

Examples of javax.print.PrintException


    /**
     * Test method for {@link javax.print.PrintException#PrintException(java.lang.String, java.lang.Exception)}.
     */
    public void testPrintExceptionStringException() {
        NullPointerException npe = new NullPointerException("npe");
        PrintException pe = new PrintException("message", npe);
        assertEquals("message", pe.getMessage());
        assertSame(npe, pe.getCause());
    }
View Full Code Here


    private PrintRequestAttributeSet assignPrintAttributes() throws PrintException {
        PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
        if (config.getCopies() >= 1) {
            printRequestAttributeSet.add(new Copies(config.getCopies()));
        } else {
            throw new PrintException("Number of print copies should be greater than zero");
        }
        printRequestAttributeSet.add(config.getMediaSizeName());
        printRequestAttributeSet.add(config.getInternalSides());
       
        return printRequestAttributeSet;
View Full Code Here

            }
            log.debug("Using printer name: {}", name);
            setPrinter(name);
            int position = findPrinter(services, printer);
            if (position < 0) {
                throw new PrintException("No printer found with name: " + printer + ". Please verify that the host and printer are registered and reachable from this machine.");
            }        
            printService = services[position];
        }
        return printService;
    }
View Full Code Here

    private PrintRequestAttributeSet assignPrintAttributes() throws PrintException {
        PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
        if (config.getCopies() >= 1) {
            printRequestAttributeSet.add(new Copies(config.getCopies()));
        } else {
            throw new PrintException("Number of print copies should be greater than zero");
        }
        printRequestAttributeSet.add(config.getMediaSizeName());
        printRequestAttributeSet.add(config.getInternalSides());
       
        return printRequestAttributeSet;
View Full Code Here

            PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
            setPrinter("\\\\" + config.getHostname() + "\\" + config.getPrintername());
            int position = findPrinter(services, printer);
            if (position < 0) {
                LOG.error("PrintServiceLookup failed. No printer found with the Printer Name: " + printer);
                throw new PrintException("Printer Lookup Failure. Please verify that the host and printer are registered and reachable from this machine");
            }        
            printService = services[position];
        }
        // LOG.info("PrintServiceLookup succeeded. PrintService located at " + printService.getName());
        return printService;
View Full Code Here

    private Doc doc;

    public PrinterOperations() throws PrintException {       
        printService = PrintServiceLookup.lookupDefaultPrintService();
        if (printService == null) {
            throw new PrintException("Printer Lookup Failure. No Default printer set up for this host");
        }
        job = printService.createPrintJob();
        flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
        printRequestAttributeSet = new HashPrintRequestAttributeSet();
        printRequestAttributeSet.add(new Copies(1));
View Full Code Here

                    FileOutputStream fileOutputStream = new FileOutputStream(file);
                    fileOutputStream.write(buffer);
                    fileOutputStream.flush();
                    fileOutputStream.close();
                } catch (Exception e) {
                    throw new PrintException("Error writing Document to the target file " + file.getAbsolutePath());
                }   
            } else {
                LOG.debug("\tIssuing Job " + i + " to Printer: " + this.printService.getName());
                print(doc);
            }
View Full Code Here

    private PrintRequestAttributeSet assignPrintAttributes() throws PrintException {
        PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
        if (config.getCopies() >= 1) {
            printRequestAttributeSet.add(new Copies(config.getCopies()));
        } else {
            throw new PrintException("Number of print copies should be greater than zero");
        }
        printRequestAttributeSet.add(config.getMediaSizeName());
        printRequestAttributeSet.add(config.getInternalSides());
       
        return printRequestAttributeSet;
View Full Code Here

            }
            log.debug("Using printer name: {}", name);
            setPrinter(name);
            int position = findPrinter(services, printer);
            if (position < 0) {
                throw new PrintException("No printer found with name: " + printer + ". Please verify that the host and printer are registered and reachable from this machine.");
            }        
            printService = services[position];
        }
        return printService;
    }
View Full Code Here

    private Doc doc;

    public PrinterOperations() throws PrintException {       
        printService = PrintServiceLookup.lookupDefaultPrintService();
        if (printService == null) {
            throw new PrintException("Printer lookup failure. No default printer set up for this host");
        }
        flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
        printRequestAttributeSet = new HashPrintRequestAttributeSet();
        printRequestAttributeSet.add(new Copies(1));
        printRequestAttributeSet.add(MediaSizeName.NA_LETTER);
View Full Code Here

TOP

Related Classes of javax.print.PrintException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.