Generated HTML word document not displaying image correctly

Posted by spiderdijon on Stack Overflow See other posts from Stack Overflow or by spiderdijon
Published on 2010-03-19T03:37:02Z Indexed on 2010/03/19 3:41 UTC
Read the original article Hit count: 264

Filed under:
|
|

I'm trying to add an image to a generated html word document that is embedded in a classic ASP page. The code looks something like this:

<%
    Response.ContentType = "application/msword"    
%>

<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word">

...

<v:shape id="_x0000_s1030" type="#_x0000_t75" style='position:absolute;
 left:0;text-align:left;margin-left:0;margin-top:17.95pt;width:7in;height:116.85pt;
 z-index:2;mso-position-horizontal:center;mso-position-horizontal-relative:page;
 mso-position-vertical-relative:page'>
 <v:imagedata src="http://xxx/image001.gif" o:title="image001"/>
 <w:wrap anchorx="page" anchory="page"/>
 <w:anchorlock/>
</v:shape><![endif]--><![if !vml]><span style='mso-ignore:vglayout;position:
absolute;z-index:0;left:0px;margin-left:0px;margin-top:24px;width:672px;
height:156px'><img width=672 height=156
src="http://xxx/image001.gif" v:shapes="_x0000_s1030"></span><![endif]>

The image URL is correct and can be viewed through a browser, however when the word document opens, the image has a red x, with the error message:

The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may be corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.

If i copy the html code and try to open the word document on my local machine, it displays the image correctly. It just doesn't work when retrieving the document from the server. This happens for any images I try to add. Is there another way to add images to html-generated word documents that can be output from an asp page?

Thanks.

© Stack Overflow or respective owner

Related posts about msword

Related posts about html