Background image not showing in printpreview in telerik report viewer

I am using telerik reporter and I have set a background image with the following code:

this.Style.BackgroundImage.ImageData = System.Drawing.Image.FromFile(HttpContext.Current.Server.MapPath(emzaUrl));

When I run the project, the background image is not displayed in printpreview, but when I press the print button in the Reportviewer, the background appears ... I want to show the background in preview so that the user can decide which background he should / she uses .. What is the problem with Print Preview mode?

I set the background manually via the properties window, but the problem still exists ...


Answer: I finally used a watermark:

Telerik.Reporting.Drawing.PictureWatermark pictureWatermark1 = new Telerik.Reporting.Drawing.PictureWatermark();
pictureWatermark1.Image = "http://www.telerik.com/images/reporting/cars/NSXGT_7.jpg";
pictureWatermark1.Position = Telerik.Reporting.Drawing.WatermarkPosition.Behind;
pictureWatermark1.PrintOnFirstPage = true;
pictureWatermark1.PrintOnLastPage = true;
pictureWatermark1.Sizing = Telerik.Reporting.Drawing.WatermarkSizeMode.ScaleProportional;
pictureWatermark1.Opacity = 1;
report1.PageSettings.Watermarks.Add(pictureWatermark1);

      

+3


source to share


1 answer


It looks like the property you are trying to set has changed overtime and some issues may still affect it.

try this:

report.Style.BackgroundImage.ImageData = System.Drawing.Image.FromFile(HttpContext.Current.Server.MapPath(emzaUrl));

      

For more information on this issue, you can find more details here .

Update

I do not know your context because you did not describe it. Since your problem might be caused by using a property that is no longer in use, the answer above indicates that the property has been replaced with a new one, with a link to Telerik's post detailing the topic.



However, you can add background images to your report in the entire report, in the header section, in the detail section, and in the footer section. In this screenshot, you can see that I have added background images in all of the above cases.

enter image description here

To achieve the above, I just used the property of each section by adding an image. The corresponding code generated in the designer.cs file of the report is as follows:

 // pageHeaderSection1
        // 
        this.pageHeaderSection1.Height = Telerik.Reporting.Drawing.Unit.Cm(2.5D);
        this.pageHeaderSection1.Name = "pageHeaderSection1";
        this.pageHeaderSection1.Style.BackgroundImage.ImageData = ((System.Drawing.Image)(resources.GetObject("pageHeaderSection1.Style.BackgroundImage.ImageData")));
        this.pageHeaderSection1.Style.BackgroundImage.MimeType = "image/gif";
        this.pageHeaderSection1.Style.BackgroundImage.Repeat = Telerik.Reporting.Drawing.BackgroundRepeat.NoRepeat;
        // 
        // detail
        // 
        this.detail.Style.BackgroundImage.ImageData = ((System.Drawing.Image)(resources.GetObject("detail.Style.BackgroundImage.ImageData")));
        this.detail.Style.BackgroundImage.MimeType = "image/gif";
        this.detail.Style.BackgroundImage.Repeat = Telerik.Reporting.Drawing.BackgroundRepeat.NoRepeat;
        // 
        // pageFooterSection1
        //
        this.pageFooterSection1.Style.BackgroundImage.ImageData = ((System.Drawing.Image)(resources.GetObject("pageFooterSection1.Style.BackgroundImage.ImageData")));
        this.pageFooterSection1.Style.BackgroundImage.MimeType = "image/gif";
        this.pageFooterSection1.Style.BackgroundImage.Repeat = Telerik.Reporting.Drawing.BackgroundRepeat.NoRepeat;

         //Report1
        this.Style.BackgroundImage.ImageData = ((System.Drawing.Image)(resources.GetObject("Report1.Style.BackgroundImage.ImageData")));
            this.Style.BackgroundImage.MimeType = "image/gif";

      

Here you can find a video with the result. If you still have problems, please describe your context exactly (versions, code, report type, if it is in a class library or if it is trdx, etc.). With the information you provided, this is the best I could answer.

Alternatively, you can try setting a watermark instead of a background image.

+1


source







All Articles