Current Position:Home > How to generate PDF report directly instead of RPT report by using JRC ?

How to generate PDF report directly instead of RPT report by using JRC ?

Update:11-30Source: network consolidation
Good Day !
How to generate PDF report directly instead of RPT report by using Crystal Reports XI Release 2 Java Reporting Component (JRC) in desktop (Swing thick-client) ?
My GUI program will generate a RPT report, then i can export to PDF file, this is ok, no problem.
i want it direct to generate a PDF report, not a RPT report.
The code like below (2 java files)
ReportClientDocument reportClientDoc = new ReportClientDocument();, 0);  
ParameterFieldController paramFieldController = reportClientDoc.getDataDefController().getParameterFieldController();
paramFieldController.setCurrentValue("", "XXX", DomainClass.getXXX());        
new ReportViewerFrame(reportClientDoc);
// End of
// Begin
public class ReportViewerFrame extends JFrame
       //Initial window frame properties.
     private final int XPOS = 80;
     private final int YPOS = 60;
     private final int WIDTH = 760;
     private final int HEIGHT = 550;
     private ReportViewerBean reportViewer = new ReportViewerBean();     
     private ReportClientDocument reportClientDoc = new ReportClientDocument();     
     public ReportViewerFrame(ReportClientDocument reportClientDoc) throws    Exception
          //Initialize frame properties.
          this.setLocation(XPOS, YPOS);
          this.setSize(WIDTH, HEIGHT);
          this.setTitle("Crystal Report Java Viewer");
          //Add GUI components to the frame including the ReportViewerBean.
          //Add GUI listeners to the frame.
          //Set the report that the ReportViewerBean will display.
          this.reportClientDoc = reportClientDoc;
          //Display the frame.
How to set the export option to PDF base on existing code ?
Where can i download this package/jar ?

The Best Answer

Please find a console app that you can extend it to a JFrame app by importing the relevant swing package:
//Crystal Java Reporting Component (JRC) imports.
import com.crystaldecisions.reports.sdk.*;
//Java imports.
public class ExportReport {
     static final String REPORT_NAME = "ExportReport.rpt";
     static final String EXPORT_FILE = "C:\\myExportedReport.pdf";
     public static void main(String[] args) {
          try {
               //Open report.               
               ReportClientDocument reportClientDoc = new ReportClientDocument();               
     , 0);
               //NOTE: If parameters or database login credentials are required, they need to be set before.
               //calling the export() method of the PrintOutputController.
               //Export report and obtain an input stream that can be written to disk.
               //See the Java Reporting Component Developer's Guide for more information on the supported export format enumerations
               //possible with the JRC.
               ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream)reportClientDoc.getPrintOutputController().export(ReportExportFormat.PDF);
               //Release report.
               //Use the Java I/O libraries to write the exported content to the file system.
               byte byteArray[] = new byte[byteArrayInputStream.available()];
               //Create a new file that will contain the exported result.
               File file = new File(EXPORT_FILE);
               FileOutputStream fileOutputStream = new FileOutputStream(file);
               ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(byteArrayInputStream.available());
               int x =, 0, byteArrayInputStream.available());
               byteArrayOutputStream.write(byteArray, 0, x);
               //Close streams.
               System.out.println("Successfully exported report to " + EXPORT_FILE);
          catch(ReportSDKException ex) {
          catch(Exception ex) {
As to the relevant jar(s) deployment refer to this link (Java Reporting Component Configuration):