开发者

Generated HTML word document not displaying image correctly

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.

Update:

Something that I've noticed is that when copying the word doc code from the asp page, pasting it into a file and renaming it as a word doc, I get this prompt when opening it:

Some of the files in this Web page aren't in the expected location. Do you want to download them anyway? If you're sure the Web Page is from a trusted source, click Yes.

If I click Yes, the image displays fine, if I click No, I get the same error as I described above. I'm thinking that because the word doc is coming from an ASP page, it is defaulting the security setting to not display external items. I've tried adding the site URL (it is a local intranet site) to my trusted sites and as a trusted location in word, but still no luck.


You could try removing the o:title tag. I've found that if that tag is there word tries to embed the image, but will only do so if it is in the proper location. By removing the o:title tag, word just treats it as a link.


Go into Options, Web Options (which might be under Advanced), uncheck "Rely on VML for displaying graphics in browsers"


Is all that code generated by Word 2007, or are you adding code by hand? It's interesting that the img tag doesn't have a slash to close it.


I know its a silly mistake, but did you make sure to put the image in the right place so that it can be accessed by the web page? If you just type in the http://xxx/image001.gif url into your browser, does the image appear? If not, I would say thats your problem.


Make sure the image's URL (location) is correct and add a slash. If it still doesn't work, check if any other images from the same directory can display. If they do then re-upload the image and try again. If other images don't display and if you're sure that the URL is correct, then try editing the read permissions on the image directory and the images. I can't imagine that it could be caused by permissions though.

Unless there's a very specific reason to generate the HTML in MS Word, I'd advise you not to do it. Even for somebody who never saw HTML or CSS before, they're both very simple and tidy to learn and can produce much better results than MS Word.


Is Word 2007 allowed to access the internet? Maybe there's a firewall rule blocking it?



Replace the following line

"<v:imagedata src="............" o:title="image001"/>"

with simple a single line of code

"<img src="............"/>"

I am sure you will get the result. I have checked it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜