Package java.awt.print

Examples of java.awt.print.PrinterException


    private void print(PrinterJob job, boolean silent) throws PrinterException
    {
        if (job == null)
        {
            throw new PrinterException("The given printer job is null.");
        }
        else
        {
            job.setPageable(new PDPageable(this, job));
            if (silent || job.printDialog())
View Full Code Here


        print(printJob, true);
    }

    private void print(PrinterJob job, boolean silent) throws PrinterException {
        if (job == null) {
            throw new PrinterException("The given printer job is null.");
        } else {
            job.setPageable(new PDPageable(this, job));
            if (silent || job.printDialog()) {
                job.print();
            }
View Full Code Here

   */
  public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException
  {
    if (Thread.currentThread().isInterrupted())
    {
      throw new PrinterException("Current thread interrupted.");
    }

    pageIndex += pageOffset;

    if ( pageIndex < 0 || pageIndex >= jasperPrint.getPages().size() )
    {
      return Printable.NO_SUCH_PAGE;
    }

    try
    {
      JRGraphics2DExporter exporter = new JRGraphics2DExporter();
      exporter.setParameter(JRExporterParameter.JASPER_PRINT, this.jasperPrint);
      exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, graphics);
      exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(pageIndex));
      exporter.exportReport();
    }
    catch (JRException e)
    {
      e.printStackTrace();
      throw new PrinterException(e.getMessage());
    }

    return Printable.PAGE_EXISTS;
  }
View Full Code Here

        print(printJob, true);
    }

    private void print(PrinterJob job, boolean silent) throws PrinterException {
        if (job == null) {
            throw new PrinterException("The given printer job is null.");
        } else {
            job.setPageable(new PDPageable(this, job));
            if (silent || job.printDialog()) {
                job.print();
            }
View Full Code Here

        print(printJob, true);
    }

    private void print(PrinterJob job, boolean silent) throws PrinterException {
        if (job == null) {
            throw new PrinterException("The given printer job is null.");
        } else {
            job.setPageable(new PDPageable(this, job));
            if (silent || job.printDialog()) {
                job.print();
            }
View Full Code Here

        print(printJob, true);
    }

    private void print(PrinterJob job, boolean silent) throws PrinterException {
        if (job == null) {
            throw new PrinterException("The given printer job is null.");
        } else {
            job.setPageable(new PDPageable(this, job));
            if (silent || job.printDialog()) {
                job.print();
            }
View Full Code Here

    public int print(Graphics graphics,
                     PageFormat format,
                     int pageIndex) throws PrinterException {
       
        if (false)
            throw new PrinterException("save trees");
           
        if (fPrintable.print(graphics, pageIndex) == MConstTextPrintable.PAGE_EXISTS) {
            return PAGE_EXISTS;
        }
        else {
View Full Code Here

    private void print(PrinterJob job, boolean silent) throws PrinterException
    {
        if (job == null)
        {
            throw new PrinterException("The given printer job is null.");
        }
        else
        {
            job.setPageable(new PDPageable(this, job));
            if (silent || job.printDialog())
View Full Code Here

     
        // for easy access to these values
        final int imgWidth = (int)pageFormat.getImageableWidth();
        final int imgHeight = (int)pageFormat.getImageableHeight();
        if (imgWidth <= 0) {
            throw new PrinterException(Messages.getString("TablePrinter.27")); //$NON-NLS-1$
        }
       
        boolean drawSeparator = ((Boolean)options.get(DRAW_SEPARATOR)).booleanValue();
   
        // if we are not drawing the table column header then reset the header clip height
        if (((Boolean)options.get(DRAW_HEADER)).booleanValue() == false) {
          columnHeader = null;
          columnHeaderClip.height = 0;
        }
       
        // the amount of vertical space available for printing the table
        int availableSpace = imgHeight;

        TextBox t;
        // get the header TextBox dimensions
        if ((t = (TextBox)options.get(HEADER_TEXTBOX)) != null)
          availableSpace -= t.getSpace() + H_F_SPACE;
       
        // get the page footer TextBox dimensions
        if ((t = (TextBox)options.get(PAGEFOOTER_TEXTBOX)) != null)
          availableSpace -= t.getSpace() + H_F_SPACE;
       
        if (drawSeparator)
          availableSpace -= H_F_SPACE * 2;
       
        if (availableSpace <= 0) {
            throw new PrinterException(Messages.getString("TablePrinter.28")); //$NON-NLS-1$
        }
       
        // depending on the print mode, we may need a scale factor to
        // fit the table's entire width on the page     
        double sf = 1.0D;
View Full Code Here

            if (text instanceof String)
              lines = ((String)text).split("\n"); //$NON-NLS-1$
            else if (text instanceof String[])
              lines = (String[])text;
            else
                    throw new PrinterException(Messages.getString("TablePrinter.38")); //$NON-NLS-1$
            
            for(int i = 0; i < lines.length; i++) {
              lines[i] = MessageFormat.format(lines[i],objs);
            }
          }
            TextBox tb = new TextBox(lines,
                getTextRectangle(graphics,lines,font),
                font,
                (Color)options.get(HEADER_COLOUR),
                ((Boolean)options.get(CENTER_HEADER)).booleanValue());
           
            setOption(HEADER_TEXTBOX,tb);
        }
     
      // do the page footer
        // fetch the formatted footer text, if any   
        if ((text = options.get(PAGE_FOOTER))!= null) {
         
          // get any specified font
          Font font = (Font)options.get(PAGEFOOTER_FONT);
                     
            String[] lines = new String[1];
          if (text instanceof MessageFormat) {
            lines[0] = ((MessageFormat)text).format(objs);
          } else {
            if (text instanceof String)
              lines = ((String)text).split("\n"); //$NON-NLS-1$
            else if (text instanceof String[])
              lines = (String[])text;
            else
                    throw new PrinterException(Messages.getString("TablePrinter.40")); //$NON-NLS-1$

            for(int i = 0; i < lines.length; i++) {
              lines[i] = MessageFormat.format(lines[i],objs);
            }
          }
           
            TextBox tb = new TextBox(lines,
                getTextRectangle(graphics,lines,font),
                font,
                (Color)options.get(PAGEFOOTER_COLOUR),
                ((Boolean)options.get(CENTER_PAGEFOOTER)).booleanValue());
           
            setOption(PAGEFOOTER_TEXTBOX,tb);
        }
      // do the table footer

        if ((text = options.get(TABLE_FOOTER)) != null) {
         
          // get any specified font
             Font font = (Font)options.get(TABLEFOOTER_FONT);

          String[] lines = new String[1];           
        if (text instanceof String)
          lines = ((String)text).split("\n"); //$NON-NLS-1$
        else if (text instanceof String[])
          lines = (String[])text;
        else if (text instanceof MessageFormat) {
          lines[0] = ((MessageFormat)text).format(objs);
          }
        else
                throw new PrinterException(Messages.getString("TablePrinter.42")); //$NON-NLS-1$
       
        for(int i = 0; i < lines.length; i++) {
          lines[i] = MessageFormat.format(lines[i],objs);
          }
View Full Code Here

TOP

Related Classes of java.awt.print.PrinterException

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.