Crystal Reports for Eclipse Developer Guide

To export a report to PDF

  1. Use the PrintOutputController object to export the report to a ByteArrayInputStream object.
      ByteArrayInputStream byteIS = (ByteArrayInputStream)rcd.getPrintOutputController().export(ReportExportFormat.PDF);
  2. Create a byte array the same size as the exported ByteArrayInputStream object.
      byte[] buf = new byte[2000 * 1024];
  3. Set the response headers to a PDF MIME type.
      response.reset();
      response.setHeader("content-disposition", "inline;filename=untitled.pdf");
      response.setContentType("application/pdf");
    
  4. Copy the contents of the byte stream into the byte array and send the byte array to the client browser.
      int nRead = 0;
    
      while ((nRead = byteIS.read(buf)) != -1) 
      {
         response.getOutputStream().write(buf, 0, nRead);
      }
    
  5. Flush and close the output stream.
      response.getOutputStream().flush();
      response.getOutputStream().close();
    
Example: 
void ExportToPDF(ReportClientDocument rcd)
{
  ByteArrayInputStream byteIS = (ByteArrayInputStream)rcd.getPrintOutputController().export(ReportExportFormat.PDF);
  byte[] buf = new byte[2000 * 1024];

  response.reset();
  response.setHeader("content-disposition", "inline;filename=untitled.pdf");
  response.setContentType("application/pdf");

  int nRead = 0;

  while ((nRead = byteIS.read(buf)) != -1) 
  {
     response.getOutputStream().write(buf, 0, nRead);
  }

  response.getOutputStream().flush();
  response.getOutputStream().close();
}



SAP BusinessObjects
http://www.sap.com/sapbusinessobjects/
Support services
http://service.sap.com/bosap-support/
Product Documentation on the Web
http://help.sap.com/