SAP Knowledge Base Article - Public

1364497 - How to set parameter and export to PDF using the Report Application Server .NET SDK


How to set parameter and export to PDF using the Report Application Server .NET SDK ?

Reproducing the Issue

  • .NET Visual Studio 2005
  • C#
  • Resolution

    sample code:

           using CrystalDecisions.ReportAppServer.ClientDoc;
           using CrystalDecisions.ReportAppServer.DataDefModel;
           using CrystalDecisions.ReportAppServer.ReportDefModel;
           using CrystalDecisions.ReportAppServer.CommonObjectModel;

           private ReportClientDocument m_boReportClientDocument;
           private string    m_boRptFile;
           private ByteArray    m_boByteArray;

            //make sure that you change the server setting of the RAS server to this database
            m_boRptFile = "C:\\Report.rpt";
                    m_boReportClientDocument = new ReportClientDocumentClass();

                    var path = (object) m_boRptFile;
                    m_boReportClientDocument.Open(ref path, (int) CdReportClientDocumentOpenOptionsEnum.cdReportClientDocumentOpenAsReadOnly );

             catch (Exception e)
                    Console.WriteLine("ERROR in opening report: " + e.Message);

             // set parameter
             m_boReportClientDocument.DataDefController.ParameterFieldController.SetCurrentValue("", "param1", "ParameterValue1");

                    // export the report to the required format - PDF:         
                    m_boByteArray = m_boReportClientDocument.PrintOutputController.Export(CrReportExportFormatEnum.crReportExportFormatPDF, 0);

                    // set the required destination:  
                    string exportPath = "C:\\test.pdf";

                    m_ByteArray.Save(exportPath, true);


                catch (Exception e)
                    Console.WriteLine("ERROR in exporting report : " + e.Message);


    How set parameter export PDF  Report Application Server  RAS .NET SDK , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , How To


    SAP Crystal Reports, developer version for Microsoft Visual Studio