Dynamically Pass An Image Into An RDLC File

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.

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!

Newsletter

Sign up for our newsletter to learn new technology, receive the latest tech news, and follow step-by-step tutorials.

3 Comments

Deepika
on March 23, 2014 at 9:53 am

Hello,

I tried the above mentioned solution, but the image does not display to me when the PDF is rendered. I am trying to display a captcha image in the PDF that is rendered from the rdlc file. I am saving the randomly generated image to my local disk, and then have to retrieve the image and display in PDF. Please advice.

Are you using the ReportViewer to render your PDF file? If so, what is the name of your ReportViewer? In this example it is named ReportViewer1; if your ReportViewer is name something else, you would have to adjust for it in the code where you are setting the parameters.

i want to change the image as per the report that i am generating.. am not talking about the background image.. just a normal image.. the images will be saved in the database… i should be able to retrieve it as per my conditions….
can you please help me on this context…..