我正在尝试将图像添加到嵌入在传统ASP页面中的生成的html word文档中.代码看起来像这样:
<%
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]>
Run Code Online (Sandbox Code Playgroud)
图像URL是正确的,可以通过浏览器查看,但是当word文档打开时,图像有一个红色的x,并显示错误消息:
无法显示图像.您的计算机可能没有足够的内存来打开图像,或者图像可能已损坏.重新启动计算机,然后再次打开该文件.如果仍然出现红色x,则可能必须删除该图像,然后再次插入.
如果我复制html代码并尝试在我的本地计算机上打开word文档,它会正确显示图像.从服务器检索文档时它不起作用.这种情况发生在我尝试添加的任何图像上.是否有另一种方法可以将图像添加到可以从asp页面输出的html生成的word文档中?
谢谢.
更新:
我注意到的一点是,当从asp页面复制单词doc代码,将其粘贴到文件中并将其重命名为word doc时,我在打开它时会收到以下提示:
此网页中的某些文件不在预期的位置.你想要下载它们吗?如果您确定网页来自受信任的来源,请单击"是".
如果我单击是,图像显示正常,如果我单击否,我会得到与上述相同的错误.我想因为doc这个词来自ASP页面,它默认安全设置不显示外部项目.我已经尝试将站点URL(它是本地Intranet站点)添加到我的受信任站点,并作为单词中的受信任位置,但仍然没有运气.