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
Keywords
How add Image Crystal Reports .NET inproc RAS SDK , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , How To