views:

127

answers:

1

When you create a report using SQL Server Reporting Services 2008 (SP1), that uses .jpg images sometimes you get the following error when you export the report to word.

Index was outside the bounds of the array. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Exception: Index was outside the bounds of the array.
A: 

Having discussed this with Microsoft support (a helpful chap called Mikael Ljunghorn) it would appear to be related to whether the .jpg image you are using in your report is encoded using 'progressive' encoding.

To prevent this from occuring, try to avoid using progressive encoded .jpg images in your report.

Mikael also suggested that the following workaround to convert a jpg image to a png sidestepping the conversion problem in word:

1)
Add this custom code block through the Report > Report Properties > Code window.

Function ConvertToPNG(ByVal bytes As Byte()) As Byte() Dim inStream As New System.IO.MemoryStream(bytes) Dim bmp As New System.Drawing.Bitmap(inStream) Dim outStream As New System.IO.MemoryStream() bmp.Save(outStream, System.Drawing.Imaging.ImageFormat.PNG) Return outStream.GetBuffer() End Function

2)
Wrap the database image Value expression in this call: =Code.ConvertToPNG(Fields!ImageBlobField.Value)

AndyM

related questions