Package java.awt.print

Examples of java.awt.print.PrinterJob


    Printable print = new MyPrintable(proj, circuits,
        parmsPanel.getHeader(),
        parmsPanel.getRotateToFit(),
        parmsPanel.getPrinterView());
   
    PrinterJob job = PrinterJob.getPrinterJob();
    job.setPrintable(print, format);
    if (job.printDialog() == false) return;
    try {
      job.print();
    } catch (PrinterException e) {
      JOptionPane.showMessageDialog(proj.getFrame(),
          StringUtil.format(Strings.get("printError"), e.toString()),
          Strings.get("printErrorTitle"),
          JOptionPane.ERROR_MESSAGE);
View Full Code Here


    return new ActionMenu(action);
  }


  private SettingsDialog showPrintDialog(DialogContent content, Scheme[] schemes) {
    PrinterJob printerJob = PrinterJob.getPrinterJob();
    SettingsDialog settingsDialog = new SettingsDialog(getParentFrame(), printerJob, schemes, content);
    UiUtilities.centerAndShow(settingsDialog);

    if (settingsDialog.getResult() == SettingsDialog.OK) {
      PrintJob job = settingsDialog.getPrintJob();
      try {
        printerJob.setPrintable(job.getPrintable(), job.getPageFormat());
        printerJob.print();
        settingsDialog.printingDone();
      } catch (PrinterException e) {
        util.exc.ErrorHandler.handle("Could not print pages: "+e.getLocalizedMessage(), e);
      }
    }
View Full Code Here

  {
    final ModifiableConfiguration reportConfiguration = report.getReportConfiguration();
    final String jobName = reportConfiguration.getConfigProperty
        (PRINTER_JOB_NAME_KEY, report.getTitle());

    final PrinterJob printerJob = PrinterJob.getPrinterJob();
    if (jobName != null)
    {
      printerJob.setJobName(jobName);
    }

    final PrintReportProcessor reportPane = new PrintReportProcessor(report);
    if (progressListener != null)
    {
      reportPane.addReportProgressListener(progressListener);
    }
    printerJob.setPageable(reportPane);
    try
    {
      printerJob.setCopies(getNumberOfCopies(reportConfiguration));
      printerJob.print();
    }
    finally
    {
      reportPane.close();
      if (progressListener != null)
View Full Code Here

      throws PrinterException, ReportProcessingException
  {
    final ModifiableConfiguration reportConfiguration = report.getReportConfiguration();
    final String jobName = reportConfiguration.getConfigProperty(PRINTER_JOB_NAME_KEY, report.getTitle());

    final PrinterJob printerJob = PrinterJob.getPrinterJob();
    if (jobName != null)
    {
      printerJob.setJobName(jobName);
    }

    final PrintReportProcessor reportPane = new PrintReportProcessor(report);
    if (progressListener != null)
    {
      reportPane.addReportProgressListener(progressListener);
    }

    try
    {
      reportPane.fireProcessingStarted();
      printerJob.setPageable(reportPane);
      printerJob.setCopies(getNumberOfCopies(reportConfiguration));
      if (printerJob.printDialog())
      {
        printerJob.print();
        return true;
      }
      return false;
    }
    finally
View Full Code Here

      return true;
    }
    else
    {

      final PrinterJob pj = PrinterJob.getPrinterJob();
      final PageFormat original = report.getPageDefinition().getPageFormat(0);
      final PageFormat pf = pj.validatePage(pj.pageDialog(original));
      if (PageFormatFactory.isEqual(pf, original))
      {
        return false;
      }
View Full Code Here

        if (ps == null) {
            System.err.println(messageWriter.print0args("noPrinter"));
            return;
        }
        System.out.println(messageWriter.print1args("printingTo", ps.getName()));
        PrinterJob pj = PrinterJob.getPrinterJob();
        try {
            pj.setPrintService(ps);
        } catch (PrinterException pe) {
            System.err.println(messageWriter.print2args("invalidPrinter", ps.getName(), pe.getMessage()));
            return;
        }
        pj.setPageable(this);
        try {
            pj.print();
        } catch (PrinterException pe2) {
            System.err.println(messageWriter.print1args("printFailed", pe2.getMessage()));
            return;
        }
    }
View Full Code Here

            if (!printerDialog.getResult()) {
                return;
            }

            //  Get properties from PrintDialog UI
            PrinterJob printerJob = printerDialog.getPrinterJob();
            PageFormat pageFormat = printerJob.defaultPage();
            printerJob.setJobNamed.toString() );

            d.setSelectionPrintMode( ((Boolean)printerDialog.getPropertyValue(PrintDialog.PRINT_SELECTION)).booleanValue() );
            d.setPrintBackgroundColor( ((Boolean)printerDialog.getPropertyValue(PrintDialog.PRINT_BACKGROUND)).booleanValue());
            d.setScaleSheet(((Boolean)printerDialog.getPropertyValue(PrintDialog.SCALE_SHEET)).booleanValue());
            pageFormat.setOrientation( ((Integer)printerDialog.getPropertyValue(PrintDialog.ORIENTATION)).intValue() );
            pageFormat.setPaperPrintDialog.getPaper( ((Integer)printerDialog.getPropertyValue(PrintDialog.PAPER_SIZE)).intValue() ));
            printerJob.setCopies(((Integer)printerDialog.getPropertyValue(PrintDialog.NB_COPIES)).intValue() );

            printerJob.setPageable(new PagesToPrint(d, pageFormat));

            setStatus(messageWriter.print1args("printingTo", printerJob.getPrintService().getName()));
            try {
                printerJob.print();
            } catch (Exception ex) {
                setStatus(messageWriter.print1args("printFailed", ex.getMessage()));
                ex.printStackTrace();
            }
View Full Code Here

   */
  public void printPrinter(PrintService ps, final DiagramComponent comp) throws PrintException{
    if (ps==null) {
      throw new PrintException("noPrinter", null);
    }
    PrinterJob pj = PrinterJob.getPrinterJob();
    try {
      pj.setPrintService(ps);
    }
    catch (PrinterException pe) {
      throw new PrintException("invalidPrinter", null);
    }
    pj.setPageable(new Pageable(){

      public int getNumberOfPages() {
        return 1;
      }

      public PageFormat getPageFormat(int pageIndex) throws IndexOutOfBoundsException {
        return pageFormat;
      }

      public Printable getPrintable(int pageIndex) throws IndexOutOfBoundsException {
        return comp;
      }
    });
    try {
      pj.print();
    } catch (PrinterException pe2) {
      throw new PrintException("printFailed",pe2);
    }
  }
View Full Code Here

        );
    }

    pageOffset = firstPageIndex;

    PrinterJob printJob = PrinterJob.getPrinterJob();

    // fix for bug ID 6255588 from Sun bug database
    initPrinterJobFields(printJob);
   
    PageFormat pageFormat = printJob.defaultPage();
    Paper paper = pageFormat.getPaper();

    printJob.setJobName("JasperReports - " + jasperPrint.getName());
   
    switch (jasperPrint.getOrientationValue())
    {
      case LANDSCAPE :
      {
        pageFormat.setOrientation(PageFormat.LANDSCAPE);
        paper.setSize(jasperPrint.getPageHeight(), jasperPrint.getPageWidth());
        paper.setImageableArea(
          0,
          0,
          jasperPrint.getPageHeight(),
          jasperPrint.getPageWidth()
          );
        break;
      }
      case
      PORTRAIT :
      default :
      {
        pageFormat.setOrientation(PageFormat.PORTRAIT);
        paper.setSize(jasperPrint.getPageWidth(), jasperPrint.getPageHeight());
        paper.setImageableArea(
          0,
          0,
          jasperPrint.getPageWidth(),
          jasperPrint.getPageHeight()
          );
      }
    }

    pageFormat.setPaper(paper);

    Book book = new Book();
    book.append(this, pageFormat, lastPageIndex - firstPageIndex + 1);
    printJob.setPageable(book);
    try
    {
      if (withPrintDialog)
      {
        if (printJob.printDialog())
        {
          printJob.print();
        }
        else
        {
          isOK = false;
        }
      }
      else
      {
        printJob.print();
      }
    }
    catch (Exception ex)
    {
      throw new JRException("Error printing report.", ex);
View Full Code Here

    }
    public PrintUtilities(Component componentToBePrinted) {
        this.componentToBePrinted = componentToBePrinted;
    }
    public void print() {
        PrinterJob printJob = PrinterJob.getPrinterJob();
        printJob.setPrintable(this);
        if (printJob.printDialog()) {
            try {
                printJob.print();
            } catch (PrinterException pe) {
                s_log.error("Error printing", pe);
            }
        }
    }
View Full Code Here

TOP

Related Classes of java.awt.print.PrinterJob

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.