Package javax.print

Examples of javax.print.PrintException


        if (attrs != null) {
            if (attrs.containsKey(Destination.class)) {
                Destination destination =
                    (Destination)attrs.get(Destination.class);
                if (!destination.getURI().getScheme().equals("file")) {
                    throw new PrintException(
                            "Only files supported as destinations.");
                }
                String file = destination.getURI().getPath();
                if (file.startsWith("/")) {
                    file = file.substring(1);
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

        } else {
            PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
            setPrinter("\\\\" + config.getHostname() + "\\" + config.getPrintername());
            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");
        }
        job = printService.createPrintJob();
        flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
        printRequestAttributeSet = new HashPrintRequestAttributeSet();
        printRequestAttributeSet.add(new Copies(1));
View Full Code Here

                    InputStream in = doc.getStreamForBytes();
                    FileOutputStream fos = new FileOutputStream(file);
                    IOHelper.copyAndCloseInput(in, fos);
                    IOHelper.close(fos);
                } catch (Exception e) {
                    throw new PrintException("Error writing Document to the target file " + file.getAbsolutePath());
                }   
            } else {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Issuing Job " + i + " to Printer: " + this.printService.getName());
                }
View Full Code Here

public class PrintExceptionTest extends TestCase {
    /**
     * Test method for {@link javax.print.PrintException#PrintException()}.
     */
    public void testPrintException() {
        PrintException pe = new PrintException();
        assertNull(pe.getMessage());
        assertNull(pe.getCause());
    }
View Full Code Here

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

    /**
     * Test method for {@link javax.print.PrintException#PrintException(java.lang.Exception)}.
     */
    public void testPrintExceptionException() {
        NullPointerException npe = new NullPointerException("npe");
        PrintException pe = new PrintException(npe);
        assertNotNull(pe.getMessage());
        assertSame(npe, pe.getCause());
       
        pe = new PrintException((Exception)null);
        assertNull(pe.getMessage());
        assertNull(pe.getCause());
    }
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.