How to set dynamically height/width of an external image in rdlc report?
It seems that there is no way to dynamically set the height and width of an external image used in rdlc report, but here a workaround to make it possible
Edit: You may also generate such "padding image" dynamically to allow different widths, for example:
- Add image to you Report
- On the image properties, set it to use External image source and use a report parameter to set which image to use
- On image, set "keep original size"
Edit: You may also generate such "padding image" dynamically to allow different widths, for example:
public void GenerateReport(int width, int height) { var image =Bitmap.FromFile("your image path"); //you can use stream or other way to get the image using (var g = Graphics.FromImage(image)) { g.Clear(Color.Transparent); g.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, width, height); // here will change the size to fit in report } MemoryStream ms = new MemoryStream(); image.Save(ms, System.Drawing.Imaging.ImageFormat.Png); // and pass the image to report reportViewer.EnableExternalImages = true; reportViewer.SetParameters(new ReportParameter("dynamicimage", image)); // you can use the image it self or pass the stream and change the report itself }for full example contact me on twitter @msalem2020
Comments
Post a Comment