Thursday, January 19, 2017

[SSRS] Replacing an image embedded in the report with a new one via RDL manipulation.

Quick and Dirty:

I had a report, and had to change the logo to the new&improved version.  Didn't want to actually TOUCH anything within the report, lest I break it. The person who designed it had the image embedded within the report - please don't do that, but instead reference a file or fileshare or something. (makes replacing it much easier, but then you have to make sure where the images are is "safe" and Highly Available)

Step 1: download the RDL

Step 2: open in Notepad.

Looking near the top...

Okay, this is somewhat human-readable. Figure out which image it is.  Mine was simple - only one image, 2 inches wide by 1 inch tall.  Now let's find the actual image.

Okay, that's cool.  It's a PNG file, via MIME (base64) encoding.  Let's see what it looks like.
Take everything within ImageData, copy it, and go to:

Paste, and convert.  Verify it's the right image. Yup!

Now what? Get a new image about the same size (so it'll fit when scaled - let's not touch things if we can avoid it).  Save as PNG, even.  Now go back to that askapache, and upload it.  Copy the RAW out, and refresh the page.  Paste it back in and make sure it's showing what you expect (aka the new image). 

Finally, take this new string, replace ImageData with it, save the new version, then upload->replace the RDL. Test and done!

No comments: