Background Images in Reporting Services

,

Adding images to a Reporting Services report is easy, just drop the image

control onto the report and you get a nice wizard that gives you the four

options (project, embedded, web, database) for sourcing the image. Pick the storage technique that suites your situation, point to

the image and you're done. But if you want to set a background image you'll find

no convenient wizard. This article will demo the techniques for setting

background images.

Start up BI Design Studio and add a blank report. No data source needed, just

an empty RDL file. Right click on the body of the report, click properties, and then

expand the Background Image property to see the details, as follows:

The first think you might notice is that the project option seems to have

disappeared. It's not listed, but we can still achieve the same affect using

external source as you'll see in a moment. Let's start with the easiest, an

external image that will be sourced from a URL. We'll set the value to our

favorite web logo:

Switch to the preview tab and you'll see this absolutely nothing! Amend the

URL by adding the http:// prefix and it works. Because the backgroundrepeat

property is set to repeat we'll see something like this:

RS actually ignores the MimeType when the source is set to external, though

it will let you enter a value. Now let's use an image that is part of our

project. Download the SSC logo and add to your project in the same folder as

your test report. Change the property to just the image name:

If you deploy the report in this state you'll see both the report and the

image file we added to the project.

There's nothing wrong with having the image visible in Report Manager, the

worst that will happen is a user will click on it and just see the logo

rendered. There is a way to hide it if you want. Click Show Details, then

properties of the image and select 'Hide in List view'. Interesting;y if you

redeploy the project the hidden setting seems to be preserved, though I can find

no setting in the project itself to control the behavior.

Now let's move to the embedded option. The concept here is to embed the image

directly into the RDL file, making it easy to send a complete report to someone

since the image dependencies are included. The downside is that if you're

embedded your logo in all your reports and the logo changes, well, you've got a

a lot of reports to alter. There are two simple ways to add an embedded image.

The first is to click Reports, Embedded Images, and browse to the image. The

other method is to drop an  image control on the report, set the embedded option, and then once

done, just remove the image control. The embedded image remains in the RDL file.

If you click view code on the RDL and look for the embedded tag, you'll see

something like this:

Now back to the properties window where we set the background image

properties. If you click the drop down for the value property, you'll see that

you can now select 'sqlservercentral_logo' - make sure you don't type in the

full file name of sqlservercentral_logo.gif. The image should display the same

as before.

The last technique is to retrieve the image from a database. You'll need to

create a datasource that points to a table containing images. For my example I

had a small table containing a number of PNG formatted images. Once you have the

data source you'll see the possible values in the drop down list; in this

example we'll use the image column which is filestream.value. Remember, you need

the field that contains the image, not the image name.

To get images from the database to work the MimeType property has to be set.

If it's blank you'll receive a processing error, but in my limited testing it

didn't seem to matter if the mime type matched the image type or not. In the

next image you can see I've marked it as a JPG, but the source image is PNG and

works just fine.

To wrap up, the last thing you can set is the BackgroundRepeat property.

You've seen an example above of it set to repeat, but there are also options for

norepeat, repeatx, and repeaty, the latter two control if the image is tiled

horizontally or vertically. Don't over do the usage of background images in your

reports but if you need them, now you know enough to get going quickly.

Rate

1 (1)

Share

Share

Rate

1 (1)