Im building an asp.net application and im using crystal report to generate pdf reports, my main issue was in the .rpt report that i need to change the existing picture with another URL path, i set it as fix path . So i reach to point where i changed the picture , but i faced a stopper which is i can't change the width of a new picture to be suitable and fit with all reports width
can you help me
i will be grateful for any suggestion
best regards
i try this code to replace the Picture ?
private void ReplaceHeaderAndFooter(ReportDocument report)
{
var clientDoc = report.ReportClientDocument.ReportDefController;
const string HeaderPath = "Reports\\Images\\headerSIS.png";
const string FooterPath = "Reports\\Images\\footerSIS.png";
string newHeaderImagePath = Path.GetFullPath(HeaderPath);
string newFooterImagePath = Path.GetFullPath(FooterPath);
//Determine which section to add the picture field to
var headerSection = clientDoc.ReportDefinition.ReportHeaderArea.Sections[0];
var allRptObjKindPicture = clientDoc.ReportObjectController.GetReportObjectsByKind(CrystalDecisions.ReportAppServer.ReportDefModel.CrReportObjectKindEnum.crReportObjectKindPicture);
int oldWidth = 0;
int oldHight = 0;
if (allRptObjKindPicture.Count > 0)
{
if (headerSection.ReportObjects.Count > 0)
{
string rptObjPictureHeaderName = String.Empty;
for (int i = 0; i < headerSection.ReportObjects.Count; i++)
{
if (headerSection.ReportObjects[i].Kind == CrystalDecisions.ReportAppServer.ReportDefModel.CrReportObjectKindEnum.crReportObjectKindPicture)
{
rptObjPictureHeaderName = headerSection.ReportObjects[i].Name;
oldWidth = headerSection.ReportObjects[i].Width;
oldHight = headerSection.ReportObjects[i].Height;
}
}
if (!String.IsNullOrEmpty(rptObjPictureHeaderName))
{
clientDoc.ReportObjectController.Remove(headerSection.ReportObjects[rptObjPictureHeaderName]);
clientDoc.ReportObjectController.ImportPicture(newHeaderImagePath, headerSection, 0, 0);
}
}
var allRptObjKindPictureAfrter = clientDoc.ReportObjectController.GetReportObjectsByKind(CrystalDecisions.ReportAppServer.ReportDefModel.CrReportObjectKindEnum.crReportObjectKindPicture);
if (headerSection.ReportObjects.Count > 0)
{
string rptObjPictureHeaderName = String.Empty;
for (int i = 0; i < headerSection.ReportObjects.Count; i++)
{
if (headerSection.ReportObjects[i].Kind == CrystalDecisions.ReportAppServer.ReportDefModel.CrReportObjectKindEnum.crReportObjectKindPicture)
{
CrystalDecisions.ReportAppServer.ReportDefModel.ISCRPictureObject newPictureObj = (CrystalDecisions.ReportAppServer.ReportDefModel.ISCRPictureObject)headerSection.ReportObjects[i];
newPictureObj.Width = w;
newPictureObj.Height = h;
}
}
}
I expect that the width of the new picture be equal to the old picture width and when i generate the report the header picture with the same old picture width .