1296803 - How to add an image to a report using the Crystal Reports .NET inproc RAS SDK

SAP Knowledge Base Article - Public

1296803 - How to add an image to a report using the Crystal Reports .NET inproc RAS SDK

Symptom

How to add an Image to a report using the Crystal Reports .NET inproc RAS SDK ?

Reproducing the Issue

  • Crystal Reports XI Release 2 Service Pack 2 and later 
  • C#

Resolution

sample code :

         using System;
         using System.Data;
         using System.Drawing;
         using System.Text;
         using System.Windows.Forms;

         using CrystalDecisions.CrystalReports.Engine;
         using CrystalDecisions.ReportAppServer.ClientDoc;



        ReportDocument                                                                                        m_boReportDocument;
        ISCDReportClientDocument                                                                     m_boReportClientDocument;

        CrystalDecisions.ReportAppServer.ReportDefModel.Section             m_boSection;
        CrystalDecisions.ReportAppServer.ReportDefModel.PictureObject   m_boPictureObject;

        //create a new ReportDocument
        m_boReportDocument = new ReportDocument();

        //load the RPT file 
        m_boReportDocument.Load("..\\..\\imageReport.rpt");

        //access the ReportClientDocument in the ReportDocument (EROM bridge)
        m_boReportClientDocument = m_boReportDocument.ReportClientDocument;

        //determine which section to add the picture field to - in this case the report header section
        m_boSection = boReportClientDocument.ReportDefController.ReportDefinition.ReportHeaderArea.Sections[0];

        //add it to the report
        m_boPictureObject = boReportClientDocument.ReportDefController.ReportObjectController.ImportPicture("..\\..\\catinbootjpg.jpg", m_boSection, 1, 1);

        //display in reportviewer
        crystalReportViewer1.ReportSource = m_boReportDocument;

See Also

  • SAP Note 1201097 - How can I modify a report using the Crystal Reports .NET SDK
  • SAP Note 1284635 - How can I add a report formula using the Crystal Reports .NET inproc RAS SDK
  • SAP Note 1285078 - How can I add a Database field using the Crystal Reports .NET inproc RAS SDK
  • SAP Note 1288988 - How to add a group using the Crystal Reports .NET inproc RAS SDK
  • SAP Note 1295770 - How to add a SummaryInfo to a report using the Crystal Reports .NET SDK
  • Keywords

    How add Image Crystal Reports .NET inproc RAS SDK , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , How To

    Product

    SAP Crystal Reports, developer version for Microsoft Visual Studio