Featured Post

SQL Query in SharePoint

The "FullTextSqlQuery" object's constructor requires an object that has context but don't be fooled. This context will no...

Monday, May 30, 2011

Why does my image become smaller when inserting into Word?

I recently rewrote a report generation system which used to create word documents in Word (running on the server) to a new system which generates these reports in OpenXML. The report output from the new system had to completely match the output from the old system. One of the discrepencies we found was that some images that were being inserted were larger than those in the old system.

With a little investigation I found out that when inserting images into Word, it scales them down to 96 DPI (If larger). One specific image was 300 DPI so when inserting it using OpenXML is was MUCH larger than in the Word Generator output. I've been working with word for 7 years and I've never noticed or knew that this happened!!! Maybe I'm the only one but I thought this was rather interesting - hence this post.
So if you need your OpenXML code to insert your images the same way Word does here is some code to change the dpi of an image if its greater than 96: