This is a migrated thread and some comments may be shown as answers.

Display Multiple Page tif in Report

1 Answer 223 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 04 Oct 2012, 12:04 PM
I am trying to display a multi-page .tif image in a telerik report.  The image is displaying, however, I can only see the first page of the image.

Is there a way to display the entire .tif image in the report?

Thanks for your help.
Mike

1 Answer, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 05 Oct 2012, 11:31 AM
Hi Mike,

Your inquiry is unusual for a reporting product as showing multiple pages of a tiff file inside a report does not fit well in the template structure of a report. Moreover, the question itself is not directly related to the product and does not fall in our support domain.
Still it can be accomplished with some code, by iterating through the collection of pages, saving them in memory and setting them as value for a PictureBox item. Here is a sample code snippet that you can modify to best fit your needs:

string tiff = HttpContext.Current.Server.MapPath("ProductCatalog.tif");
            Image image = Image.FromFile(tiff);
 
            int pageCount = image.GetFrameCount(FrameDimension.Page);
            int i = 0;
            Unit unitX = Unit.Inch(0.1);
            Unit unitY = Unit.Inch(0.1);
            SizeU size = new SizeU(Unit.Inch(1), Unit.Inch(0.5));
 
            for (int y = 0; y < pageCount; y++)
            {
                //save each frame to a bytestream
                image.SelectActiveFrame(FrameDimension.Page, y);
                MemoryStream byteStream = new MemoryStream();
                image.Save(byteStream, ImageFormat.Png);
                //create a new pictureBox and set its value to the bytestream
 
                Telerik.Reporting.PictureBox pic = new Telerik.Reporting.PictureBox();
                pic.Location = new PointU(unitX, unitY);
                pic.Size = size;
                unitY = unitY.Add(Unit.Inch(0.5));
                pic.Sizing = ImageSizeMode.AutoSize;
                pic.Style.BorderStyle.Default = BorderType.Solid;
                pic.Style.BorderColor.Default = Color.Black;
                pic.Value = Image.FromStream(byteStream);
                pic.Name = "pictureBox" + i;
                this.detail.Items.Add(pic);
                i++;
            }


Kind regards,
Steve
the Telerik team

HAPPY WITH TELERIK REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

Tags
General Discussions
Asked by
Mike
Top achievements
Rank 1
Answers by
Steve
Telerik team
Share this question
or