Using WPF CrystalReportsViewer and the CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument I'm able to dynamically add an image to ALL pages in the rpt by calling ImportPicture on the appropriate section. However, I want to add a different image to each page.
I've figured out how many pages need images (see How do I get the number of rendered pages from a CrystalReportsViewer?), but have not been able to get a different image on each page.
Is there a data model of the "as rendered" report that I can access? Can I add a different image per page?
I'm not sure about doing this programmatically in VS, but you can do this in the Crystal Report itself.
select pagenumber
case 1 : "C:\picture1.bmp"
case 2 : "C:\picture2.bmp"
...
default : "C:\warning.bmp"
Add all the images to the desired section, then EnableSuppress and set the formula to hide when its not on the desired page.
CrystalDecisions.ReportAppServer.ReportDefModel.PictureObject pic=ctl.ReportObjectController.ImportPicture(tempImagePath, s, 0, 0);
if (pic != null)
{
var picNew = pic.Clone();
picNew.Format.EnableSuppress = true;
CrystalDecisions.ReportAppServer.ReportDefModel.ConditionFormula f = roNew.Format.ConditionFormulas[CrObjectFormatConditionFormulaTypeEnum.crObjectFormatConditionFormulaTypeEnableSuppress];
if (f != null)
{
f.Syntax = CrFormulaSyntaxEnum.crFormulaSyntaxCrystal;
f.Text = string.Format("PageNumber <> {0}", ri.PageNumber);
}
ctl.ReportObjectController.Modify(pic, picNew);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With