This project has moved and is read-only. For the latest updates, please go here.

Usually we have two kinds of images in reports:

a) Images loaded from the file system
To show this kind of images we need to change the default ColumnItemsTemplate which is TextBlock to ImageFilePath:               

columns.AddColumn(column =>
                {
                    column.PropertyName<ImageRecord>(x => x.ImagePath);
                    column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                    column.IsVisible(true);
                    column.Order(2);
                    column.Width(3);
                    column.HeaderCell("Image");
                    column.ColumnItemsTemplate(t => t.ImageFilePath(defaultImageFilePath: string.Empty, fitImages: false));
                });
Here defaultImageFilePath is the default image path in case of missing images.

b) Images stored in databases
Showing images stored as binary data in databases is similar to (a). We just need to use the suitable ColumnItemsTemplate which is ByteArrayImage template:                
columns.AddColumn(column =>
                 {
                     column.PropertyName("thumbnail");
                     column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                     column.IsVisible(true);
                     column.Order(5);
                     column.HeaderCell("Image");
                     column.ColumnItemsTemplate(t => t.ByteArrayImage(defaultImageFilePath: string.Empty, fitImages: false));
                 });

Here you can find the complete samples of (a) and (b):
ImageFilePath
DbImagePdfReport

Last edited Nov 5, 2012 at 3:43 PM by VahidN, version 1

Comments

No comments yet.