SAP Knowledge Base Article - Public

1544094 - Groups in a Crystal report are lost when exported to PDF from a .NET application


Groups in a Crystal report are lost when exported to PDF from a Crystal Reports .NET application.



  • Visual Studio 2008.
  • Crystal Reports 2008 SP3.
  • Windows application.

Reproducing the Issue

Export a report to PDF using the Crystal Reports .NET SDK and the groups in a Crystal report are lost.


The function to maintain the groups in a PDF is not available in the Crystal Report .NET SDK.


This feature is available using Report Application Server (RAS) SDK. The following can be used for the option:


Following C# code snippet shows the implementation. Sample is attached in the Attachments section of this note.

private void btnPdf_Click(object sender, EventArgs e) 
   CrystalDecisions.CrystalReports.Engine.ReportDocument rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
   /// Calling a sample report named Employee Sales.rpt with parameter
   rd.Load(Application.StartupPath + "\\..\\..\\Employee Sales.rpt");
   rd.SetParameterValue("Login Name","Robert King");
   ISCDReportClientDocument rcd = rd.ReportClientDocument;
   ISCRPDFExportFormatOptions exportFormat = new PDFExportFormatOptionsClass();
   exportFormat.CreateBookmarksFromGroupTree = true;
   //Create an array of bytes of the report.
   PrintOutputController rasPrintOutputController;
   rasPrintOutputController = rcd.PrintOutputController;

   // Define the export format as PDF, and apply the PDF export options
   CrystalDecisions.ReportAppServer.ReportDefModel.ExportOptions expOpts = new CrystalDecisions.ReportAppServer.ReportDefModel.ExportOptionsClass();
   expOpts.ExportFormatType = CrReportExportFormatEnum.crReportExportFormatPDF;
   expOpts.FormatOptions = exportFormat;
   // Use the PrintOutputController class to export the report based on the defined export options.
   ByteArray tempByteArray = rcd.PrintOutputController.ExportEx(expOpts);
   Byte[] byteStreamOutput = tempByteArray.ByteArray;
   // Create a new file(MyExportedReport) with the specified path, name, and file extension.
   FileStream fs = new FileStream("C:\\Windows\\Temp\\MyExportedReport.pdf", FileMode.Create, FileAccess.ReadWrite);
   // Stream the bytes from the exported report to the newly created file and close the file stream.
   int maxSize = byteStreamOutput.Length;
   fs.Write(byteStreamOutput, 0, maxSize);

   MessageBox.Show("Export is done in C:\\Windows\\Temp location");

See Also

  1. Employee Sales.rpt is the sample report used. Reports are attached in the sample.
  2. Reports connect to Xtreme Sample database using ODBC connectivity.
  3. SDK guide link is provided in References section of this note.
  4. If you are unable to open the .chm file, refer Note# 1271550.


ReportAppServer, ReportDefModel, ISCRPDFExportFormatOptions, CreateBookmarksFromGroupTree, drill down, Create bookmarks from group tree , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem


Crystal Reports 2008 V1