Java 类javax.print.PrintException 实例源码

项目:OpenJSharp    文件:PSStreamPrintJob.java   
public void pageableJob(Pageable pageable,
                        PrintRequestAttributeSet attributes)
    throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setPageable(pageable);
        job.print(attributes);
        notifyEvent(PrintJobEvent.JOB_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
    }
}
项目:OpenJSharp    文件:UnixPrintJob.java   
public void pageableJob(Pageable pageable) throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setCopies(copies);
        job.setJobName(jobName);
        job.setPageable(pageable);
        job.print(reqAttrSet);
        notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
        notifyEvent(PrintJobEvent.NO_MORE_EVENTS);
    }
}
项目:OpenJSharp    文件:UnixPrintJob.java   
public Object run() {
    try {
        if (mDestType == UnixPrintJob.DESTFILE) {
            spoolFile = new File(mDestination);
        } else {
            /* Write to a temporary file which will be spooled to
             * the printer then deleted. In the case that the file
             * is not removed for some reason, request that it is
             * removed when the VM exits.
             */
            spoolFile = Files.createTempFile("javaprint", "").toFile();
            spoolFile.deleteOnExit();
        }
        result = new FileOutputStream(spoolFile);
        return result;
    } catch (IOException ex) {
        // If there is an IOError we subvert it to a PrinterException.
        notifyEvent(PrintJobEvent.JOB_FAILED);
        pex = new PrintException(ex);
    }
    return null;
}
项目:jdk8u-jdk    文件:PSStreamPrintJob.java   
public void pageableJob(Pageable pageable,
                        PrintRequestAttributeSet attributes)
    throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setPageable(pageable);
        job.print(attributes);
        notifyEvent(PrintJobEvent.JOB_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
    }
}
项目:jdk8u-jdk    文件:UnixPrintJob.java   
public void pageableJob(Pageable pageable) throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setCopies(copies);
        job.setJobName(jobName);
        job.setPageable(pageable);
        job.print(reqAttrSet);
        notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
        notifyEvent(PrintJobEvent.NO_MORE_EVENTS);
    }
}
项目:jdk8u-jdk    文件:UnixPrintJob.java   
public Object run() {
    try {
        if (mDestType == UnixPrintJob.DESTFILE) {
            spoolFile = new File(mDestination);
        } else {
            /* Write to a temporary file which will be spooled to
             * the printer then deleted. In the case that the file
             * is not removed for some reason, request that it is
             * removed when the VM exits.
             */
            spoolFile = Files.createTempFile("javaprint", "").toFile();
            spoolFile.deleteOnExit();
        }
        result = new FileOutputStream(spoolFile);
        return result;
    } catch (IOException ex) {
        // If there is an IOError we subvert it to a PrinterException.
        notifyEvent(PrintJobEvent.JOB_FAILED);
        pex = new PrintException(ex);
    }
    return null;
}
项目:openjdk-jdk10    文件:PSStreamPrintJob.java   
public void pageableJob(Pageable pageable,
                        PrintRequestAttributeSet attributes)
    throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setPageable(pageable);
        job.print(attributes);
        notifyEvent(PrintJobEvent.JOB_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
    }
}
项目:openjdk-jdk10    文件:UnixPrintJob.java   
public void pageableJob(Pageable pageable) throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setCopies(copies);
        job.setJobName(jobName);
        job.setPageable(pageable);
        job.print(reqAttrSet);
        notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
        notifyEvent(PrintJobEvent.NO_MORE_EVENTS);
    }
}
项目:openjdk-jdk10    文件:UnixPrintJob.java   
public OutputStream run() {
    try {
        if (mDestType == UnixPrintJob.DESTFILE) {
            spoolFile = new File(mDestination);
        } else {
            /* Write to a temporary file which will be spooled to
             * the printer then deleted. In the case that the file
             * is not removed for some reason, request that it is
             * removed when the VM exits.
             */
            spoolFile = Files.createTempFile("javaprint", "").toFile();
            spoolFile.deleteOnExit();
        }
        result = new FileOutputStream(spoolFile);
        return result;
    } catch (IOException ex) {
        // If there is an IOError we subvert it to a PrinterException.
        notifyEvent(PrintJobEvent.JOB_FAILED);
        pex = new PrintException(ex);
    }
    return null;
}
项目:scorekeeperfrontend    文件:EntryPanel.java   
@Override
public void actionPerformed(ActionEvent e)
{
    try {
        if (selectedDriver == null)
            return;

        PrintService ps = (PrintService)printers.getSelectedItem();
        PrintRequestAttributeSet attr = new HashPrintRequestAttributeSet();

        attr.add(new Copies(1));
        attr.add((Media)ps.getDefaultAttributeValue(Media.class)); // set to default paper from printer
        attr.add(OrientationRequested.LANDSCAPE);

        SimpleDoc doc = new SimpleDoc(activeLabel, DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
        ps.createPrintJob().print(doc, attr);
    }  catch (PrintException ex) {
        log.log(Level.SEVERE, "\bBarcode print failed: " + ex.getMessage(), ex);
    }
}
项目:openjdk9    文件:PSStreamPrintJob.java   
public void pageableJob(Pageable pageable,
                        PrintRequestAttributeSet attributes)
    throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setPageable(pageable);
        job.print(attributes);
        notifyEvent(PrintJobEvent.JOB_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
    }
}
项目:openjdk9    文件:UnixPrintJob.java   
public void pageableJob(Pageable pageable) throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setCopies(copies);
        job.setJobName(jobName);
        job.setPageable(pageable);
        job.print(reqAttrSet);
        notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
        notifyEvent(PrintJobEvent.NO_MORE_EVENTS);
    }
}
项目:openjdk9    文件:UnixPrintJob.java   
public OutputStream run() {
    try {
        if (mDestType == UnixPrintJob.DESTFILE) {
            spoolFile = new File(mDestination);
        } else {
            /* Write to a temporary file which will be spooled to
             * the printer then deleted. In the case that the file
             * is not removed for some reason, request that it is
             * removed when the VM exits.
             */
            spoolFile = Files.createTempFile("javaprint", "").toFile();
            spoolFile.deleteOnExit();
        }
        result = new FileOutputStream(spoolFile);
        return result;
    } catch (IOException ex) {
        // If there is an IOError we subvert it to a PrinterException.
        notifyEvent(PrintJobEvent.JOB_FAILED);
        pex = new PrintException(ex);
    }
    return null;
}
项目:kumoreg    文件:ReportPrintService.java   
/**
 * Prints the given string either the appropriate printer name (from
 * the computers table), or the default printer on the server.
 * @param reportText Text of report
 * @param clientIPAddress Client computer's IP address
 * @return String Result message
 */
public String printReport(String reportText, String clientIPAddress) {
    if (enablePrintingFromServer != null && enablePrintingFromServer) {
        Computer client = computerService.findComputerByIP(clientIPAddress);
        ReportPrintFormatter formatter =
                new ReportPrintFormatter(reportText, client.getxOffset(), client.getyOffset());
        try {
            printDocument(formatter.getStream(), client.getPrinterName(), false);
            return "Printed to " + client.getPrinterName();
        } catch (PrintException e) {
            log.error(String.format("Error printing report for %s: %s",
                    clientIPAddress, e.getMessage()), e);
            return("Error printing. No printers found? More information in server logs");
        }
    } else {
        return("Printing from server not enabled.");
    }
}
项目:jdk8u_jdk    文件:PSStreamPrintJob.java   
public void pageableJob(Pageable pageable,
                        PrintRequestAttributeSet attributes)
    throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setPageable(pageable);
        job.print(attributes);
        notifyEvent(PrintJobEvent.JOB_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
    }
}
项目:jdk8u_jdk    文件:UnixPrintJob.java   
public void pageableJob(Pageable pageable) throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setCopies(copies);
        job.setJobName(jobName);
        job.setPageable(pageable);
        job.print(reqAttrSet);
        notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
        notifyEvent(PrintJobEvent.NO_MORE_EVENTS);
    }
}
项目:jdk8u_jdk    文件:UnixPrintJob.java   
public Object run() {
    try {
        if (mDestType == UnixPrintJob.DESTFILE) {
            spoolFile = new File(mDestination);
        } else {
            /* Write to a temporary file which will be spooled to
             * the printer then deleted. In the case that the file
             * is not removed for some reason, request that it is
             * removed when the VM exits.
             */
            spoolFile = Files.createTempFile("javaprint", "").toFile();
            spoolFile.deleteOnExit();
        }
        result = new FileOutputStream(spoolFile);
        return result;
    } catch (IOException ex) {
        // If there is an IOError we subvert it to a PrinterException.
        notifyEvent(PrintJobEvent.JOB_FAILED);
        pex = new PrintException(ex);
    }
    return null;
}
项目:lookaside_java-1.8.0-openjdk    文件:PSStreamPrintJob.java   
public void pageableJob(Pageable pageable,
                        PrintRequestAttributeSet attributes)
    throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setPageable(pageable);
        job.print(attributes);
        notifyEvent(PrintJobEvent.JOB_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:UnixPrintJob.java   
public void pageableJob(Pageable pageable) throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setCopies(copies);
        job.setJobName(jobName);
        job.setPageable(pageable);
        job.print(reqAttrSet);
        notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
        notifyEvent(PrintJobEvent.NO_MORE_EVENTS);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:UnixPrintJob.java   
public Object run() {
    try {
        if (mDestType == UnixPrintJob.DESTFILE) {
            spoolFile = new File(mDestination);
        } else {
            /* Write to a temporary file which will be spooled to
             * the printer then deleted. In the case that the file
             * is not removed for some reason, request that it is
             * removed when the VM exits.
             */
            spoolFile = Files.createTempFile("javaprint", "").toFile();
            spoolFile.deleteOnExit();
        }
        result = new FileOutputStream(spoolFile);
        return result;
    } catch (IOException ex) {
        // If there is an IOError we subvert it to a PrinterException.
        notifyEvent(PrintJobEvent.JOB_FAILED);
        pex = new PrintException(ex);
    }
    return null;
}
项目:javify    文件:JavaPrinterJob.java   
/**
 * Prints the pages.
 */
public void print() throws PrinterException
{
  if( printable == null && pageable == null ) // nothing to print?
    return;

  PostScriptGraphics2D pg = new PostScriptGraphics2D( this );
  SpooledDocument doc = pg.spoolPostScript( printable, pageFormat,
                                            pageable );

  cancelled = false;
  printJob = printer.createPrintJob();
  try
    {
      printJob.print(doc, attributes);
    }
  catch (PrintException pe)
    {
      PrinterException p = new PrinterException();
      p.initCause(pe);
      throw p;
    }
  // no printjob active.
  printJob = null;
}
项目:Camel    文件:PrinterProducer.java   
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());
    printRequestAttributeSet.add(config.getInternalOrientation());

    if (config.getMediaTray() != null) {
        MediaTray mediaTray = resolveMediaTray(config.getMediaTray());

        if (mediaTray == null) {
            throw new PrintException("mediatray not found " + config.getMediaTray());
        }

        printRequestAttributeSet.add(mediaTray);
    }

    return printRequestAttributeSet;
}
项目:kumoreg    文件:ReportPrintService.java   
/**
 * Prints the given string either the appropriate printer name (from
 * the computers table), or the default printer on the server.
 * @param reportText Text of report
 * @param clientIPAddress Client computer's IP address
 * @return String Result message
 */
public String printReport(String reportText, String clientIPAddress) {
    if (enablePrintingFromServer != null && enablePrintingFromServer) {
        Computer client = computerService.findComputerByIP(clientIPAddress);
        ReportPrintFormatter formatter =
                new ReportPrintFormatter(reportText, client.getxOffset(), client.getyOffset());
        try {
            printDocument(formatter.getStream(), client.getPrinterName(), false);
            return "Printed to " + client.getPrinterName();
        } catch (PrintException e) {
            log.error(String.format("Error printing report for %s: %s",
                    clientIPAddress, e.getMessage()), e);
            return("Error printing. No printers found? More information in server logs");
        }
    } else {
        return("Printing from server not enabled.");
    }
}
项目:jvm-stm    文件:JavaPrinterJob.java   
/**
  * Prints the pages.
  */
 public void print() throws PrinterException
 {
   if( printable == null && pageable == null ) // nothing to print?
     return;

   PostScriptGraphics2D pg = new PostScriptGraphics2D( this );
   SpooledDocument doc = pg.spoolPostScript( printable, pageFormat, 
                      pageable );

   cancelled = false;
   printJob = printer.createPrintJob();
   try
     {
printJob.print(doc, attributes);
     }
   catch (PrintException pe) 
     {
PrinterException p = new PrinterException();
p.initCause(pe);
throw p;
     }
   // no printjob active.
   printJob = null;
 }
项目:infobip-open-jdk-8    文件:PSStreamPrintJob.java   
public void pageableJob(Pageable pageable,
                        PrintRequestAttributeSet attributes)
    throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setPageable(pageable);
        job.print(attributes);
        notifyEvent(PrintJobEvent.JOB_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
    }
}
项目:infobip-open-jdk-8    文件:UnixPrintJob.java   
public void pageableJob(Pageable pageable) throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setCopies(copies);
        job.setJobName(jobName);
        job.setPageable(pageable);
        job.print(reqAttrSet);
        notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
        notifyEvent(PrintJobEvent.NO_MORE_EVENTS);
    }
}
项目:infobip-open-jdk-8    文件:UnixPrintJob.java   
public Object run() {
    try {
        if (mDestType == UnixPrintJob.DESTFILE) {
            spoolFile = new File(mDestination);
        } else {
            /* Write to a temporary file which will be spooled to
             * the printer then deleted. In the case that the file
             * is not removed for some reason, request that it is
             * removed when the VM exits.
             */
            spoolFile = Files.createTempFile("javaprint", "").toFile();
            spoolFile.deleteOnExit();
        }
        result = new FileOutputStream(spoolFile);
        return result;
    } catch (IOException ex) {
        // If there is an IOError we subvert it to a PrinterException.
        notifyEvent(PrintJobEvent.JOB_FAILED);
        pex = new PrintException(ex);
    }
    return null;
}
项目:jdk8u-dev-jdk    文件:PSStreamPrintJob.java   
public void pageableJob(Pageable pageable,
                        PrintRequestAttributeSet attributes)
    throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setPageable(pageable);
        job.print(attributes);
        notifyEvent(PrintJobEvent.JOB_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
    }
}
项目:jdk8u-dev-jdk    文件:UnixPrintJob.java   
public void pageableJob(Pageable pageable) throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setCopies(copies);
        job.setJobName(jobName);
        job.setPageable(pageable);
        job.print(reqAttrSet);
        notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
        notifyEvent(PrintJobEvent.NO_MORE_EVENTS);
    }
}
项目:jdk8u-dev-jdk    文件:UnixPrintJob.java   
public Object run() {
    try {
        if (mDestType == UnixPrintJob.DESTFILE) {
            spoolFile = new File(mDestination);
        } else {
            /* Write to a temporary file which will be spooled to
             * the printer then deleted. In the case that the file
             * is not removed for some reason, request that it is
             * removed when the VM exits.
             */
            spoolFile = Files.createTempFile("javaprint", "").toFile();
            spoolFile.deleteOnExit();
        }
        result = new FileOutputStream(spoolFile);
        return result;
    } catch (IOException ex) {
        // If there is an IOError we subvert it to a PrinterException.
        notifyEvent(PrintJobEvent.JOB_FAILED);
        pex = new PrintException(ex);
    }
    return null;
}
项目:jdk7-jdk    文件:PSStreamPrintJob.java   
public void pageableJob(Pageable pageable,
                        PrintRequestAttributeSet attributes)
    throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setPageable(pageable);
        job.print(attributes);
        notifyEvent(PrintJobEvent.JOB_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
    }
}
项目:jdk7-jdk    文件:UnixPrintJob.java   
public void pageableJob(Pageable pageable) throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setCopies(copies);
        job.setJobName(jobName);
        job.setPageable(pageable);
        job.print(reqAttrSet);
        notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
        notifyEvent(PrintJobEvent.NO_MORE_EVENTS);
    }
}
项目:jdk7-jdk    文件:UnixPrintJob.java   
public Object run() {
    try {
        if (mDestType == UnixPrintJob.DESTFILE) {
            spoolFile = new File(mDestination);
        } else {
            /* Write to a temporary file which will be spooled to
             * the printer then deleted. In the case that the file
             * is not removed for some reason, request that it is
             * removed when the VM exits.
             */
            spoolFile = File.createTempFile("javaprint", ".ps", null);
            spoolFile.deleteOnExit();
        }
        result = new FileOutputStream(spoolFile);
        return result;
    } catch (IOException ex) {
        // If there is an IOError we subvert it to a PrinterException.
        notifyEvent(PrintJobEvent.JOB_FAILED);
        pex = new PrintException(ex);
    }
    return null;
}
项目:openjdk-source-code-learn    文件:PSStreamPrintJob.java   
public void pageableJob(Pageable pageable,
                        PrintRequestAttributeSet attributes)
    throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setPageable(pageable);
        job.print(attributes);
        notifyEvent(PrintJobEvent.JOB_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
    }
}
项目:openjdk-source-code-learn    文件:UnixPrintJob.java   
public void pageableJob(Pageable pageable) throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setCopies(copies);
        job.setJobName(jobName);
        job.setPageable(pageable);
        job.print(reqAttrSet);
        notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
        notifyEvent(PrintJobEvent.NO_MORE_EVENTS);
    }
}
项目:openjdk-source-code-learn    文件:UnixPrintJob.java   
public Object run() {
    try {
        if (mDestType == UnixPrintJob.DESTFILE) {
            spoolFile = new File(mDestination);
        } else {
            /* Write to a temporary file which will be spooled to
             * the printer then deleted. In the case that the file
             * is not removed for some reason, request that it is
             * removed when the VM exits.
             */
            spoolFile = File.createTempFile("javaprint", ".ps", null);
            spoolFile.deleteOnExit();
        }
        result = new FileOutputStream(spoolFile);
        return result;
    } catch (IOException ex) {
        // If there is an IOError we subvert it to a PrinterException.
        notifyEvent(PrintJobEvent.JOB_FAILED);
        pex = new PrintException(ex);
    }
    return null;
}
项目:OLD-OpenJDK8    文件:PSStreamPrintJob.java   
public void pageableJob(Pageable pageable,
                        PrintRequestAttributeSet attributes)
    throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setPageable(pageable);
        job.print(attributes);
        notifyEvent(PrintJobEvent.JOB_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
    }
}
项目:OLD-OpenJDK8    文件:UnixPrintJob.java   
public void pageableJob(Pageable pageable) throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setCopies(copies);
        job.setJobName(jobName);
        job.setPageable(pageable);
        job.print(reqAttrSet);
        notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
        notifyEvent(PrintJobEvent.NO_MORE_EVENTS);
    }
}
项目:cn1    文件:WinPrintJob.java   
public void print(final Doc doc, final PrintRequestAttributeSet attributes)
                throws PrintException {
    synchronized (lock) {
        if (printer != null) {
            throw new PrintException("Printer is busy"); //$NON-NLS-1$
        } else {
            final DocFlavor flavor = doc.getDocFlavor();

            if ((flavor == null) || !service.isDocFlavorSupported(flavor)) {
                throw new PrintException("Doc flavor is not supported"); //$NON-NLS-1$
            }

            printer = new Printer(doc, attributes);
            printer.print();
        }
    }
}
项目:cn1    文件:WinPrinterFactory.java   
public static PrinterState getPrinterState(final long handle)
                throws PrintException {
    final long status = getPrinterStatus(handle);

    if ((status & (PRINTER_STATUS_PRINTING | PRINTER_STATUS_PROCESSING)) != 0) {
        return PrinterState.PROCESSING;
    } else if ((status & (PRINTER_STATUS_DOOR_OPEN | PRINTER_STATUS_ERROR
                    | PRINTER_STATUS_NO_TONER
                    | PRINTER_STATUS_NOT_AVAILABLE | PRINTER_STATUS_OFFLINE
                    | PRINTER_STATUS_OUT_OF_MEMORY
                    | PRINTER_STATUS_OUTPUT_BIN_FULL
                    | PRINTER_STATUS_PAPER_JAM | PRINTER_STATUS_PAPER_OUT
                    | PRINTER_STATUS_PAPER_PROBLEM | PRINTER_STATUS_USER_INTERVENTION)) != 0) {
        return PrinterState.STOPPED;
    } else if ((status & PRINTER_STATUS_SERVER_UNKNOWN) != 0) {
        return PrinterState.UNKNOWN;
    } else {
        return PrinterState.IDLE;
    }
}