Package net.sf.jasperreports.engine

Examples of net.sf.jasperreports.engine.JRException


    {
      return dbf.newDocumentBuilder();
    }
    catch (ParserConfigurationException e)
    {
      throw new JRException("Failed to create a document builder factory", e);
    }
  }
View Full Code Here


        }
      }
     
      if (printService == null)
      {
        throw new JRException("No suitable print service found.");
      }

      try
      {
        printerJob.setPrintService(printService);
      }
      catch (PrinterException e)
      {
        throw new JRException(e);
      }

      PrintRequestAttributeSet printRequestAttributeSet = null;
      if(displayPrintDialogOnlyOnce || displayPageDialogOnlyOnce)
      {
        printRequestAttributeSet = new HashPrintRequestAttributeSet();
        setDefaultPrintRequestAttributeSet(printRequestAttributeSet);
        setOrientation((JasperPrint)jasperPrintList.get(0), printRequestAttributeSet);
        if(displayPageDialogOnlyOnce)
        {
          if(printerJob.pageDialog(printRequestAttributeSet) == null)
          {
            return;
          }
          else
          {
            displayPageDialog = false;
          }
        }
        if(displayPrintDialogOnlyOnce)
        {
          if(!printerJob.printDialog(printRequestAttributeSet))
          {
            printStatus = new Boolean[]{Boolean.FALSE};
            return;
          }
          else
          {
            displayPrintDialog = false;
          }
        }
      }
     
      List status = new ArrayList();
      // fix for bug ID artf1455 from jasperforge.org bug database
      for(reportIndex = 0; reportIndex < jasperPrintList.size(); reportIndex++)
      {
        setJasperPrint((JasperPrint)jasperPrintList.get(reportIndex));

        exporter = new JRGraphics2DExporter();
        exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
        exporter.setParameter(JRExporterParameter.PROGRESS_MONITOR, parameters.get(JRExporterParameter.PROGRESS_MONITOR));
        exporter.setParameter(JRExporterParameter.OFFSET_X, parameters.get(JRExporterParameter.OFFSET_X));
        exporter.setParameter(JRExporterParameter.OFFSET_Y, parameters.get(JRExporterParameter.OFFSET_Y));
        exporter.setParameter(JRGraphics2DExporterParameter.ZOOM_RATIO, parameters.get(JRGraphics2DExporterParameter.ZOOM_RATIO));
        exporter.setParameter(JRExporterParameter.CLASS_LOADER, classLoader);
        exporter.setParameter(JRExporterParameter.URL_HANDLER_FACTORY, urlHandlerFactory);
        exporter.setParameter(JRExporterParameter.FILE_RESOLVER, fileResolver);
        if (parameters.containsKey(JRExporterParameter.FILTER))
        {
          exporter.setParameter(JRExporterParameter.FILTER, filter);
        }
        exporter.setParameter(JRGraphics2DExporterParameter.MINIMIZE_PRINTER_JOB_SIZE, parameters.get(JRGraphics2DExporterParameter.MINIMIZE_PRINTER_JOB_SIZE));
       
        if(displayPrintDialog || displayPageDialog ||
            (!displayPrintDialogOnlyOnce && !displayPageDialogOnlyOnce))
        {
          printRequestAttributeSet = new HashPrintRequestAttributeSet();
          setDefaultPrintRequestAttributeSet(printRequestAttributeSet);
          setOrientation(jasperPrint, printRequestAttributeSet);
        }
   
        try
        {
         
          if (!isModeBatch)
          {
            printRequestAttributeSet.add(new PageRanges(startPageIndex + 1, endPageIndex + 1));
          }

          printerJob.setJobName("JasperReports - " + jasperPrint.getName());

          if (displayPageDialog)
          {
            printerJob.pageDialog(printRequestAttributeSet);
          }
          if (displayPrintDialog)
          {
            if (printerJob.printDialog(printRequestAttributeSet))
            {
              status.add(Boolean.TRUE);
              printerJob.print(printRequestAttributeSet);
            }
            else
            {
              status.add(Boolean.FALSE);
            }
          }
          else
          {
            PageFormat pageFormat = printerJob.defaultPage();
            Paper paper = pageFormat.getPaper();
           
            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()
                  );
              }
            }
           
            // setting the paper object back as getPaper() returns a clone
            pageFormat.setPaper(paper);
           
            printerJob.setPrintable(this, pageFormat);

            printerJob.print(printRequestAttributeSet);
          }
        }
        catch (PrinterException e)
        {
          throw new JRException(e);
        }
      }
     
      printStatus = (Boolean[]) status.toArray(new Boolean[status.size()]);
      printService = printerJob.getPrintService();
View Full Code Here

        if (log.isErrorEnabled())
        {
          log.error("Fill " + subreportFiller.fillerId + ": exception", e);
        }
       
        throw new JRException("Error encountered while waiting on the subreport filling thread.", e);
      }
     
      if (log.isDebugEnabled())
      {
        log.debug("Fill " + subreportFiller.fillerId + ": wait ended");
View Full Code Here

      if (log.isErrorEnabled())
      {
        log.error("Fill " + subreportFiller.fillerId + ": exception", e);
      }
     
      throw new JRException("Error encountered while waiting on the subreport filling thread.", e);
    }
   
    if (log.isDebugEnabled())
    {
      log.debug("Fill " + subreportFiller.fillerId + ": notified to continue");
View Full Code Here

    boolean isReprintGroupHeaders
    ) throws JRException
  {
    if (isCreatingNewPage)
    {
      throw new JRException("Infinite loop creating new page.");
    }

    if (keepTogetherSavePoint != null)
    {
      keepTogetherSavePoint.saveEndOffsetY(offsetY);
View Full Code Here

   */
  public static Object loadObject(File file) throws JRException
  {
    if (!file.exists() || !file.isFile())
    {
      throw new JRException( new FileNotFoundException(String.valueOf(file)) );
    }

    Object obj = null;

    FileInputStream fis = null;
    ObjectInputStream ois = null;

    try
    {
      fis = new FileInputStream(file);
      BufferedInputStream bufferedIn = new BufferedInputStream(fis);
      ois = new ContextClassLoaderObjectInputStream(bufferedIn);
      obj = ois.readObject();
    }
    catch (IOException e)
    {
      throw new JRException("Error loading object from file : " + file, e);
    }
    catch (ClassNotFoundException e)
    {
      throw new JRException("Class not found when loading object from file : " + file, e);
    }
    finally
    {
      if (ois != null)
      {
View Full Code Here

      ois = new ContextClassLoaderObjectInputStream(is);
      obj = ois.readObject();
    }
    catch (IOException e)
    {
      throw new JRException("Error loading object from URL : " + url, e);
    }
    catch (ClassNotFoundException e)
    {
      throw new JRException("Class not found when loading object from URL : " + url, e);
    }
    finally
    {
      if (ois != null)
      {
View Full Code Here

      ois = new ContextClassLoaderObjectInputStream(is);
      obj = ois.readObject();
    }
    catch (IOException e)
    {
      throw new JRException("Error loading object from InputStream", e);
    }
    catch (ClassNotFoundException e)
    {
      throw new JRException("Class not found when loading object from InputStream", e);
    }

    return obj;
  }
View Full Code Here

    if (url != null)
    {
      return loadObject(url);
    }

    throw new JRException("Could not load object from location : " + location);
  }
View Full Code Here

   */
  public static InputStream getInputStream(File file) throws JRException
  {
    if (!file.exists() || !file.isFile())
    {
      throw new JRException( new FileNotFoundException(String.valueOf(file)) );
    }

    FileInputStream fis = null;

    try
    {
      fis = new FileInputStream(file);
    }
    catch (IOException e)
    {
      throw new JRException("Error opening input stream from file : " + file, e);
    }

    return fis;
  }
View Full Code Here

TOP

Related Classes of net.sf.jasperreports.engine.JRException

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.