Package javax.print

Examples of javax.print.PrintException


    final PrintService printService;
    final PrintService[] services = PrintServiceLookup.lookupPrintServices(
        DocFlavor.SERVICE_FORMATTED.PAGEABLE, null);
    if (services.length == 0)
    {
      throw new PrintException
          ("Unable to find a matching print service implementation.");
    }
    printService = services[0];
    return printService;
  }
View Full Code Here


  {
    final PrintService[] services = PrintServiceLookup.lookupPrintServices(
        DocFlavor.SERVICE_FORMATTED.PAGEABLE, null);
    if (services.length == 0)
    {
      throw new PrintException
          ("Unable to find a matching print service implementation.");
    }
    PrintRequestAttributeSet attributes =
        Java14PrintUtil.copyConfiguration(null, report);
    attributes = Java14PrintUtil.copyAuxillaryAttributes(attributes, report);
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

                    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 {} to Printer: {}", i, this.printService.getName());
                }
View Full Code Here

    }
    else
    {
      if (printService.isDocFlavorSupported(DocFlavor.SERVICE_FORMATTED.PAGEABLE) == false)
      {
        throw new PrintException
            ("The print service implementation does not support the Pageable Flavor.");
      }
    }

    PrintRequestAttributeSet attributes =
View Full Code Here

    final PrintService printService;
    final PrintService[] services = PrintServiceLookup.lookupPrintServices(
        DocFlavor.SERVICE_FORMATTED.PAGEABLE, null);
    if (services.length == 0)
    {
      throw new PrintException
          ("Unable to find a matching print service implementation.");
    }
    printService = services[0];
    return printService;
  }
View Full Code Here

  {
    final PrintService[] services = PrintServiceLookup.lookupPrintServices(
        DocFlavor.SERVICE_FORMATTED.PAGEABLE, null);
    if (services.length == 0)
    {
      throw new PrintException
          ("Unable to find a matching print service implementation.");
    }
    PrintRequestAttributeSet attributes =
        Java14PrintUtil.copyConfiguration(null, report);
    attributes = Java14PrintUtil.copyAuxillaryAttributes(attributes, report);
View Full Code Here

                        data = ((URL)doc.getPrintData()).openStream();
                    } else {
                        data = doc.getStreamForBytes();
                    }
                } catch (IOException ioe) {
                    throw new PrintException(
                            "Can't read data from document souce");
                }
                int printerID = startDocPrinter(serviceName,
                        convertAttributes(attributes, flavor),
                        getJobName(attributes), getDestination(attributes));
                if (printerID != 0) {
                    byte[] buffer = new byte[10240];
                    try {
                        int bytesRead = data.read(buffer);
                        while (bytesRead >= 0) {
                            if (!writePrinter(buffer, bytesRead, printerID)) {
                                endDocPrinter(printerID);
                                throw new PrintException(
                                        "Can't send data to printer");
                            }
                            bytesRead = data.read(buffer);
                        }
                    } catch (IOException ioe) {
                        throw new PrintException(
                                "Can't read print data from Doc");
                    }
                    if (!endDocPrinter(printerID)) {
                        throw new PrintException("Can't finish job normally");
                    }
                } else {
                    throw new PrintException("Can't start printing");
                }
            } else if (flavor.getMimeType().toLowerCase().equals(
                           "internal/postscript") &&
                       flavor.getRepresentationClassName().equals(
                           "java.io.InputStream")) {
                InputStream data = null;
                try {
                    data = (InputStream)doc.getPrintData();
                } catch (IOException ioe) {
                    throw new PrintException(
                            "Can't read data from document souce");
                }
                PSInterpreter interpreter = new PSInterpreter(data, serviceName,
                        this, attributes);
                interpreter.interpret();
            } else {
                throw new PrintException("DocFlavor is not supported");
            }
        }
    }
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.