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.
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.
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’.
Lastly, we need to modify the logic in the .aspx.cs code file to set the value of the background image.
templateImage = WebServerURL + "/images/MyRealyCoolBackgroundImage.jpg";
ReportViewer1.LocalReport.SetParameters(new ReportParameter("ImageName", _templateImage));
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.