Report Application Server XI Release 2 Java SDK

Export a report to PDF

This sample shows you how to export a Crystal Report to PDF format. RAS enables you to export reports to a specific format, such as Excel, PDF, or RTF.

This sample does the following:

Managed RAS environment
Unmanaged RAS environment


   page import="*,*,*,*,,





<title>Export a Report to PDF</title>




/* Include the file AlwaysRequiredSteps.jsp, which contains the code to:

   - Create a new Report Application Session

   - Create a RAS service

   - Set the RAS server to be used for the service

   - Initialize the RAS service

   - Create the ReportClientDocument object

   - Set the RAS Server to be used for the report

   - Open the report, and set the open type to Read Only



<%@ include file="AlwaysRequiredSteps.jsp"%>


//Use the report document's PrintOutputController to export the report to a ByteArrayInputStream

ByteArrayInputStream byteIS = (ByteArrayInputStream) clientDoc.getPrintOutputController().export(ReportExportFormat.PDF);

//Create a byte[] that is the same size as the exported ByteArrayInputStream

byte[] buf = new byte[2000 * 1024];

int nRead = 0;

//Set response headers


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


//Send the Byte Array to the Client

while ((nRead = != -1) {

  response.getOutputStream().write(buf, 0, nRead);


//Flush the output stream


//Close the output stream



Business Objects
Support services
Product Documentation on the Web