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

Change Background Image Dynamically on Every Page

6 Answers 285 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Michael Sogos
Top achievements
Rank 1
Michael Sogos asked on 20 Apr 2013, 10:20 AM
Hi,

I can't figure out how i can change background image to every page.
Can you help me?

What i need is to set Report Background Image on Every Page with a different Image. I have a list of Image Path (like these "c:\temp\photo1.jpg","c:\temp\photo2.jpg","c:\temp\photo3.jpg") that in PAGE1 have its background image set to PHOTO1.JPG, same with PAGE2 with PHOTO2.JPG, same with PAGE3; when come in PAGE4 reassign PHOTO1.JPG and so on to infinity.

The codebehind that manage this "loop" i can write by my self, what really i need is to attaching on an event (or a binding expression, or what you want) that call a user function on every "start page creation" that will change the background image.



6 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 24 Apr 2013, 10:20 AM
Hello Michael,

For your scenario you can utilize the Report.PageSettings.Watermarks. Just add a picture watermark and set the Image property to expression: =GetImg(PageNumber). Then you have to add an user function GetImg(int pageNumber) to resolve the correct image as shown in the following code snippet:

public static Image GetImg(int pageNumber)
{
    //resolve the image
    return image;
}

All the best,
Peter
the Telerik team

Have you tried the new visualization options in Telerik Reporting Q1 2013? You can get them from your account.

0
Michael Sogos
Top achievements
Rank 1
answered on 24 Apr 2013, 06:49 PM
Hello Peter,

Thanks to your answer, but that is not right for me.

My report is using a custom report size (100x30 cm) and have a left margin of 20cm and a right margin of 5cm.
My background image fill up the white space generated by margin, and it work perfectly using BackgroundImage under PageSettings.
Using watermarks the background image start inside the "writeable" area.

What I ask you is, could you make possible in next SP or Release to attach on "new page" event and set in the event method the background image for actual page (or any other solution to reach this target).

Please, it is very important for us.
0
Peter
Telerik team
answered on 29 Apr 2013, 03:42 PM
Hi Michael,

We would like to understand your needs and business requirements better in order to help you find a solution that would work for you. We will appreciate it if you elaborate on you need to change the page background image dynamically based on the page number.

Regards,
Peter
the Telerik team

Have you tried the new visualization options in Telerik Reporting Q1 2013? You can get them from your account.

0
Michael Sogos
Top achievements
Rank 1
answered on 29 Apr 2013, 04:47 PM
Hi,

I will try to explain better.

We have a report that will be rendered by code in a Console Application (NO PREVIEW).

Our report is not properly a report, but a "POSTER" to show in hallways of a school. This poster contain a lot of photo (class photo), about 20 per class. This poster need to show to the students their photo so they can choose the favorite one.

This poster have two area:
- A sponsor area (there is no photo but commercial claim)
- A writeable area (where photo will be printed)

The pictures are consecutive to each other, so to reach this target we have configured the report like a multi column (8 columns per page with 0,25cm for column spacing).

The datasource (SQL SERVER) is assigned directly to the report and grouped by CLASS NAME.

The poster have a background image that perfectly fit our zone (take a look to file attached), in the "writeable area" is white, while the rest have a commercial infos.

To reach this target we have setup the margin in pagesettings to be 20cm on the left and 5cm on the right.

The result is PERFECT!

The background start to point x=0 , y=0 of the page, so cover the margin area too. Watermarks instead start to point x=20xm, y=0 (or x=0,y=0 of the writeable area, inside the margin).

The result satisfy us, but because the sponsor area can have many claims (different commercial infos) what we need is to change the background on our need and in different configuration.

For now, in console application, we can choose a background image (one of choice between 5 different backgrounds) and all goes! This result satisfy too, but we can choose only a background that remain equal to every page of our POSTER (about 30 pages).

WHAT WE NEED IS:
A way to pass a list of strings (these are the path where the backgrounds images are saved) that with a simple code I can convert a string to an image, like this PDF.PageSettings.BackgroundImage.ImageData = New Bitmap(BackgroundImagePath).

I'm imaging to do this into a User Function and to call this User Function inside an event handler (OnPageCreating). Determine which image to load as background image for a specific page is not important now. The target is to set a different background on every page of the poster.

This is enough clear? Please, do not hesitate to ask me for a clarification, but specify what is not so clear to you.
0
Peter
Telerik team
answered on 02 May 2013, 08:40 AM
Hello Michael,

Thank you for further elaborating on your scenario.

In order to have different background image for every class/page our suggestion is to utilize a report book. This way you can create a separate report instance for every class/page and set the dedicated PageSettings.BackgroundImage.ImageData. Additionally you have to add a filter with parameter so each report instance to display only a certain group/class.

Regards,
Peter
the Telerik team

Have you tried the new visualization options in Telerik Reporting Q1 2013? You can get them from your account.

0
Michael Sogos
Top achievements
Rank 1
answered on 02 May 2013, 09:24 AM
Thanks,

I will try this solution asap ;)
Tags
General Discussions
Asked by
Michael Sogos
Top achievements
Rank 1
Answers by
Peter
Telerik team
Michael Sogos
Top achievements
Rank 1
Share this question
or