Package net.sf.jasperreports.engine.export

Examples of net.sf.jasperreports.engine.export.JRPdfExporter


    JasperPrint jasperPrint,
    String destFileName
    ) throws JRException
  {
    /*   */
    JRPdfExporter exporter = new JRPdfExporter();
   
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFileName);
   
    exporter.exportReport();
  }
View Full Code Here


  public static void exportReportToPdfStream(
    JasperPrint jasperPrint,
    OutputStream outputStream
    ) throws JRException
  {
    JRPdfExporter exporter = new JRPdfExporter();
   
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream);
   
    exporter.exportReport();
  }
View Full Code Here

   */
  public static byte[] exportReportToPdf(JasperPrint jasperPrint) throws JRException
  {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    JRPdfExporter exporter = new JRPdfExporter();
   
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);
   
    exporter.exportReport();
   
    return baos.toByteArray();
  }
View Full Code Here

*/
public class ChartNoPdfHandler extends BaseChartHandler implements GenericElementPdfHandler
{
  public void exportElement(JRPdfExporterContext exporterContext, JRGenericPrintElement element)
  {
    JRPdfExporter exporter = (JRPdfExporter)exporterContext.getExporter();
   
    JRPrintText text = getTextElementReplacement(exporterContext, element);
   
    try
    {
      exporter.exportText(text);
    }
    catch (Exception e)
    {
      throw new RuntimeException(e);
    }
View Full Code Here

          getBundleString("save"),
          JOptionPane.OK_CANCEL_OPTION
          )
      )
    {
      JRPdfExporter exporter = new JRPdfExporter();
      exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
      exporter.setParameter(JRExporterParameter.OUTPUT_FILE, file);
      exporter.exportReport();
    }
  }
View Full Code Here

    JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

    File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".pdf");

    JRPdfExporter exporter = new JRPdfExporter();

    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString());

    exporter.exportReport();

    System.err.println("PDF creation time : " + (System.currentTimeMillis() - start));
  }
View Full Code Here

   
    Boolean isBuffered = Boolean.valueOf(request.getParameter(BaseHttpServlet.BUFFERED_OUTPUT_REQUEST_PARAMETER));
    if (isBuffered.booleanValue())
    {
      FileBufferedOutputStream fbos = new FileBufferedOutputStream();
      JRPdfExporter exporter = new JRPdfExporter();
      exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, jasperPrintList);
      exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, fbos);
     
      try
      {
        exporter.exportReport();
        fbos.close();

        if (fbos.size() > 0)
        {
          response.setContentType("application/pdf");
          response.setContentLength(fbos.size());
          ServletOutputStream ouputStream = response.getOutputStream();
 
          try
          {
            fbos.writeData(ouputStream);
            fbos.dispose();
            ouputStream.flush();
          }
          finally
          {
            if (ouputStream != null)
            {
              try
              {
                ouputStream.close();
              }
              catch (IOException ex)
              {
              }
            }
          }
        }
      }
      catch (JRException e)
      {
        throw new ServletException(e);
      }
      finally
      {
        fbos.close();
        fbos.dispose();
      }
     
//      else
//      {
//        response.setContentType("text/html");
//        PrintWriter out = response.getWriter();
//        out.println("<html>");
//        out.println("<body bgcolor=\"white\">");
//        out.println("<span class=\"bold\">Empty response.</span>");
//        out.println("</body>");
//        out.println("</html>");
//      }
    }
    else
    {
      response.setContentType("application/pdf");

      JRPdfExporter exporter = new JRPdfExporter();
      exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, jasperPrintList);
     
      OutputStream ouputStream = response.getOutputStream();
      exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);

      try
      {
        exporter.exportReport();
      }
      catch (JRException e)
      {
        throw new ServletException(e);
      }
View Full Code Here

    JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);

    File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".pdf");
   
    JRPdfExporter exporter = new JRPdfExporter();
   
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    exporter.setParameter(JRExporterParameter.OUTPUT_FILE, destFile);
    exporter.setParameter(JRPdfExporterParameter.IS_ENCRYPTED, Boolean.TRUE);
    exporter.setParameter(JRPdfExporterParameter.IS_128_BIT_KEY, Boolean.TRUE);
    exporter.setParameter(JRPdfExporterParameter.USER_PASSWORD, "jasper");
    exporter.setParameter(JRPdfExporterParameter.OWNER_PASSWORD, "reports");
    exporter.setParameter(
      JRPdfExporterParameter.PERMISSIONS,
      new Integer(PdfWriter.ALLOW_COPY | PdfWriter.ALLOW_PRINTING)
      );
   
    exporter.exportReport();

    System.err.println("PDF creation time : " + (System.currentTimeMillis() - start));
  }
View Full Code Here

    List jasperPrintList = new ArrayList();
    jasperPrintList.add(JRLoader.loadObjectFromLocation("build/reports/Report1.jrprint"));
    jasperPrintList.add(JRLoader.loadObjectFromLocation("build/reports/Report2.jrprint"));
    jasperPrintList.add(JRLoader.loadObjectFromLocation("build/reports/Report3.jrprint"));
   
    JRPdfExporter exporter = new JRPdfExporter();
   
    exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, jasperPrintList);
    exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, "build/reports/BatchExportReport.pdf");
    exporter.setParameter(JRPdfExporterParameter.IS_CREATING_BATCH_MODE_BOOKMARKS, Boolean.TRUE);
   
    exporter.exportReport();
   
    System.err.println("PDF creation time : " + (System.currentTimeMillis() - start));
  }
View Full Code Here

            JRExporter exporter;

            if (format.equals(FORMAT_PDF)) {
                response.setContentType("application/pdf");
                exporter = new JRPdfExporter();
            } else if (format.equals(FORMAT_CSV)) {
                response.setContentType("text/csv");
                exporter = new JRCsvExporter();
            } else if (format.equals(FORMAT_HTML)) {
                response.setContentType("text/html");
View Full Code Here

TOP

Related Classes of net.sf.jasperreports.engine.export.JRPdfExporter

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.