Use the
PrintOutputController object to
export the report to a
ByteArrayInputStream object.
ByteArrayInputStream byteIS = (ByteArrayInputStream)rcd.getPrintOutputController().export(ReportExportFormat.PDF);
Create a byte array the same size as
the exported
ByteArrayInputStream object.
byte[] buf = new byte[2000 *1024];
Create a file output stream.
FileOutputStream fos = new FileOutputStream("C:\\MyReport.pdf"); Copy the contents of the byte stream
to the file output stream.
int nRead = 0;
while ((nRead = byteIS.read(buf)) != -1)
{
fos.write(buf, 0, nRead);
} Close the file output stream.
Example:
void exportToPDF(ReportClientDocument rcd) throws ReportSDKException, IOException
{
ByteArrayInputStream byteIS = (ByteArrayInputStream)rcd.getPrintOutputController().export(ReportExportFormat.PDF);
byte[] buf = new byte[2000 *1024];
FileOutputStream fos = new FileOutputStream("C:\\MyReport.pdf");
int nRead = 0;
while ((nRead = byteIS.read(buf)) != -1)
{
fos.write(buf, 0, nRead);
}
fos.close();
}This list includes the classes used by the sample
code:
com.crystaldecisions.sdk.occa.report.application.ReportClientDocument
com.crystaldecisions.sdk.occa.report.exportoptions.ReportExportFormat
com.crystaldecisions.sdk.occa.report.lib.ReportSDKException
java.io.ByteArrayInputStream
java.io.FileOutputStream
java.io.IOException