Tech Talk

Permanent link to SQL Report fails to export to PDF SQL Report fails to export to PDF

Saturday, August 30, 2008
This problem starts out vague and hard to troubleshoot. For me, is started when direct links to SQL Reporting Services PDF format reports failed to open with Adobe Acrobat telling me the file was invalid.

So, I open the report in plain HTML format - no problem. I choose the Export to Excel option, and get a nice unhelpful message:

ReportServerException: Exception message: For more information about this error navigate to the report server on the local server machine, or enable remote errors

Ohhhkay. Check the error log on the server. Woohoo! Lots of useful info: "An unhandled exception has occurred. " among other stuff.

Break open Visual Studio, and start digging. The report fails here, only when exporting to PDF, but this actually gives me a useful error:

Non-negative number required.
Parameter name: value

OK, this should be easy, just find the negative number in my data, and figure a way around it. Except, I don't have any negative numbers!! Well, I don't have many expressions on the report, so a bit more digging around reveals the trouble in the one that builds the URL for images. But everything looks fine! The strings output fine as text, the images show in non-PDF renders, just not in PDF. A few more web searches reveals that others have had this problem, and it's a bug with SRSS not being able to handle certain JPG images when exporting to PDF. Once I found the trouble image (good luck if you have lots to go through!), I stripped all extra metadata by opening/saving in good ol' Photopaint, and all is well. I've seen problems with metadata in JPG before, but not at this level of product, and not from a high-end camera such as this one was from.

Bottom Line: make sure that your images are as plain-vanilla as possible, and strip all metadata with your tool of choice (jhead will do it nicely).


LaRocque Family