Report Template Thumbnail

Stimulsoft Reports.NET discussion
Post Reply
johnham
Posts: 98
Joined: Fri Sep 19, 2008 2:27 pm
Location: Richland, WA, USA

Report Template Thumbnail

Post by johnham »

I store my reports in a table in my SQL Database. As a peice of eye-candy for my application I would like to show a thumbnail of the report template for my browse dialog when someone is selecting a report to edit in the designer.

Is there a way to generate a thumbnail of the Template Layout?

Thanks,
John Hamilton
POSitive Software Company
http://www.gopositive.com
Thanks,
John Hamilton
Hamilton & Company, LLC
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Report Template Thumbnail

Post by Vital »

Hello John,
johnham wrote:I store my reports in a table in my SQL Database. As a peice of eye-candy for my application I would like to show a thumbnail of the report template for my browse dialog when someone is selecting a report to edit in the designer.

Is there a way to generate a thumbnail of the Template Layout?
You can use method GetThumbnail(int width, int height, bool isDesignTime). For example:

Code: Select all

bmp = report.Pages[0].GetThumbnail(100, 100, true);
You need call this method for first page in your report. Also take in consideration that your report can contain more that one page.

Thank you.
Brendan
Posts: 309
Joined: Sun Jul 16, 2006 12:42 pm
Location: Ireland

Report Template Thumbnail

Post by Brendan »

Hi John

Yes this can be done easily enough. First you need to load your report through the StiReport.Load method and then you can generate a thumbnail of any page in the Pages collection. Here is some sample code that generates a thumbnail to the size of a picturebox and then displays it in a picturebox. you can just replace this code with your own dimensions and save the Thumbnail to the DB or whatever.

Code: Select all

StiReport report = new StiReport();

//Load the Report to Generate Thumbnail
report.Load(mrtfile.FileName);
if (report.Pages.Count > 0)
{
    //Use First Page of Report for Thumbnail
    StiPage page = report.Pages[0];

    //Generate Thumbnail (W x H) of Design Time Report Page 1
    Bitmap bmp = page.GetThumbnail(pictureBox1.Width, pictureBox1.Height, true);
    pictureBox1.Image = bmp;
}
Edit: Looks like the master above got in their first ;)
johnham
Posts: 98
Joined: Fri Sep 19, 2008 2:27 pm
Location: Richland, WA, USA

Report Template Thumbnail

Post by johnham »

You guys have thought of everything!

Thanks,
John Hamilton
POSitive Software Company
http://www.gopositive.com
Thanks,
John Hamilton
Hamilton & Company, LLC
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Report Template Thumbnail

Post by Vital »

Hello John,
You guys have thought of everything!
We can't know everything, but your request is not first and we make this feature some of years ago.

Thank you.
Post Reply