SSRS can't properly render *some* images within PDF
image, pdf, reporting-services, ssrs-2008
Solution
Current Workaround
I never ended up getting SSRS to display the the problem images as they were, however, determining before running the report which images would be included in the non-displayable set so they could be converted to a supported format (automatically) was also a solution.
In my case, all images were supplied via users uploading to a website, so I was able to identify and convert images as they arrived. For all existing images, I was able to run a script that identified the problem images and convert them.
Identifying problem images
From the thousands of images I had, I was able to determine that the images that wouldn't render correctly had the following properties:
- Image had CMYK colorspace or;
- Image had extended color profiles or;
- Both of the above
Converting an image
I was originally using the standard .NET GDI (`System.Drawing`) to manipulate images however the API is often prone to crashes (`OutOfMemoryException`) when dealing with images that have extra data. As such, I switched to using ImageMagick where for each of the identified images I:
- Stripped the color profiles and;
- Converted to RGB
Note that the conversion to RGB from CMYK without stripping the color profiles was not enough to get all images to render properly.
I ended up just doing those items on every image byte stream I received from users (without first identifying the problem) before saving an uploaded image to disk. After which, I never had the rendering problem again.
Problem
I have a report that renders images (jpg) that have been collected from various sources. This works fine within the report viewer, and when exporting via Excel. However, when exporting to PDF, about 5% of the images are rendered incorrectly as can be seen below, with the original on the left, and what is rendered on the right; I find that if I open up one of these images in mspaint, and just click save, on the next report-run the image is now rendered correctly. Are there any rules as to what image properties/format are valid for SSRS to render the image correctly within a PDF? Essentially I'd like to somehow find these images that will render incorrectly before the report is run and fix them prior...