Change Background Image Dynamically on Every Page

7 posts, 0 answers
  1. Michael Sogos
    Michael Sogos avatar
    5 posts
    Member since:
    Jul 2012

    Posted 20 Apr 2013 Link to this post

    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.



  2. Peter
    Admin
    Peter avatar
    1611 posts

    Posted 24 Apr 2013 Link to this post

    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.

  3. DevCraft banner
  4. Michael Sogos
    Michael Sogos avatar
    5 posts
    Member since:
    Jul 2012

    Posted 24 Apr 2013 Link to this post

    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.
  5. Peter
    Admin
    Peter avatar
    1611 posts

    Posted 29 Apr 2013 Link to this post

    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.

  6. Michael Sogos
    Michael Sogos avatar
    5 posts
    Member since:
    Jul 2012

    Posted 29 Apr 2013 Link to this post

    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.
  7. Peter
    Admin
    Peter avatar
    1611 posts

    Posted 02 May 2013 Link to this post

    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.

  8. Michael Sogos
    Michael Sogos avatar
    5 posts
    Member since:
    Jul 2012

    Posted 02 May 2013 Link to this post

    Thanks,

    I will try this solution asap ;)
Back to Top
DevCraft banner