I am working on a .NET application that runs an RDLC file to generate a PDF. The generated PDF has a nice looking watermark in the background. I inherited the part of the application that actually generated the report so I never really gave it much thought about how the background image is displayed. That quickly changed when I received a requirement that I needed to change the background image based on business logic in the application.

I found out that the original report had the image embedded as the background.

Blog3_pic1-RDLC-Dynamic

In order to make our required changes, we first need to create a new parameter in the report in order to pass in the image URL.

Adding New Image Paramenter

Next, we need to set the ‘Source’ of the background image to ‘External’. We will set the value of the background image to the previous parameter ‘ImageName’.

Report to accept image from external

Lastly, we need to modify the logic in the .aspx.cs code file to set the value of the background image.

 

At this point, you will simply need to work on getting the image sized and positioned appropriately. Hopefully this will save you a little time accomplishing your goal of changing the background image.

 

Like this post? Share it!