Skip to Content

Crystal Reports - .NET Runtime - Process Pictures in the RPT files

Hello, I'm trying to write storage for the RPT reports.
I have a task - process all incoming RPT files and patch its all Picture Objects.
So the pseudo-code:

ReportDocument crystalReport = new ReportDocument();
crystalReport.Load(fileName);

var allPictureObjects = crystalReport.ReportDefinition.Areas.SelectMany(x=>x.Sections).SelectMany(x=>x.ReportObjects).OfType<PictureObject>();
foreach(PictureObject pictureObject in allPictureObjects) {
  var bmp = pictureObject.GetBitmap();
  ApplyWatermark(bmp);
  pictureObject.SetBitmap(bmp);
}

so I'm searching the possibility to "GetBitmap" from the picture object and apply it back.

Is it possible from the .NET API?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Mar 21, 2017 at 08:50 PM

    {
    CrystalDecisions.ReportAppServer.ReportDefModel.PictureObject boPictureObject = new CrystalDecisions.ReportAppServer.ReportDefModel.PictureObject(); ;

    #region Original
    //rpt.Load(@"D:\CPP Net 2010\RASXIR2Printer2K8\oleobject.rpt");
    //rptClientDoc = rpt.ReportClientDocument;

    //this is a bug for Nice I tracked, can't use \temp.temp\ for an image location - ADAPT01323018
    //String MyfilePath = @"c:\temp\sample1.jpg";
    //String MyfilePath = "C:\\temp.temp\\sample1.jpg";
    String MyfilePath = "C:\\temp\\mansheart.jpg";

    //Determine which section to add the picture field to - in this case the report header section
    CrystalDecisions.ReportAppServer.ReportDefModel.Section boSection;
    boSection = rptClientDoc.ReportDefController.ReportDefinition.ReportHeaderArea.Sections[0];
    boSection.Height = 1010; // in twips

    boPictureObject.Left = 1010;
    boPictureObject.Width = 500;
    boPictureObject.Height = 200;
    boPictureObject.Top = 100;
    boPictureObject.OriginalWidth = 50;
    boPictureObject.OriginalHeight = 30;
    boPictureObject.Name = "dontest";

    //Add it to the report
    boPictureObject = rptClientDoc.ReportDefController.ReportObjectController.ImportPicture(MyfilePath, boSection, 1, 1);

    rpt.SaveAs("c:\\temp\\savedimage.rpt", true);

    Don

    Add comment
    10|10000 characters needed characters exceeded