生成的HTML文档文档无法正确显示图像

时间:2022-02-12 02:02:48

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:

我正在尝试将图像添加到嵌入在传统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]>

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:

图像URL是正确的,可以通过浏览器查看,但是当word文档打开时,图像有一个红色的x,并显示错误消息:

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.

无法显示图像。您的计算机可能没有足够的内存来打开图像,或者图像可能已损坏。重新启动计算机,然后再次打开该文件。如果仍然出现红色x,则可能必须删除该图像,然后再次插入。

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?

如果我复制html代码并尝试在我的本地计算机上打开word文档,它会正确显示图像。从服务器检索文档时它不起作用。这种情况发生在我尝试添加的任何图像上。是否有另一种方法可以将图像添加到可以从asp页面输出的html生成的word文档中?

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:

我注意到的一点是,当从asp页面复制单词doc代码,将其粘贴到文件中并将其重命名为word doc时,我在打开它时会收到此提示:

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.

如果我单击是,图像显示正常,如果我单击否,我会得到与上述相同的错误。我在想,因为doc这个单词来自ASP页面,它默认安全设置不显示外部项目。我已经尝试将站点URL(它是本地Intranet站点)添加到我的可信站点,并作为单词中的受信任位置,但仍然没有运气。

7 个解决方案

#1


3  

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.

您可以尝试删除o:title标记。我发现,如果那个标签有单词试图嵌入图像,但只有在适当的位置才会这样做。通过删除o:title标签,word只会将其视为链接。

#2


3  

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

进入选项,Web选项(可能在高级下),取消选中“依靠VML在浏览器中显示图形”

#3


0  

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.

是由Word 2007生成的所有代码,还是手动添加代码?有趣的是,img标签没有斜线来关闭它。

#4


0  

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.

我知道这是一个愚蠢的错误,但你确定将图像放在正确的位置,以便网页可以访问它吗?如果您只需在浏览器中输入http://xxx/image001.gif网址,该图片是否会显示?如果没有,我会说这是你的问题。

#5


0  

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.

确保图像的URL(位置)正确并添加斜杠。如果仍然不起作用,请检查是否可以显示同一目录中的任何其他图像。如果他们这样做,然后重新上传图像,然后再试一次。如果未显示其他图像,并且您确定该URL正确,则尝试编辑图像目录和图像的读取权限。我无法想象它可能是由权限引起的。

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.

除非有一个非常具体的理由在MS Word中生成HTML,否则我建议你不要这样做。即使对于之前从未见过HTML或CSS的人来说,他们既简单又整洁,可以产生比MS Word更好的结果。

#6


0  

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

Word 2007是否允许访问互联网?也许有防火墙规则阻止它?

#7


0  


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.

我相信你会得到结果。我检查了一下。

#1


3  

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.

您可以尝试删除o:title标记。我发现,如果那个标签有单词试图嵌入图像,但只有在适当的位置才会这样做。通过删除o:title标签,word只会将其视为链接。

#2


3  

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

进入选项,Web选项(可能在高级下),取消选中“依靠VML在浏览器中显示图形”

#3


0  

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.

是由Word 2007生成的所有代码,还是手动添加代码?有趣的是,img标签没有斜线来关闭它。

#4


0  

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.

我知道这是一个愚蠢的错误,但你确定将图像放在正确的位置,以便网页可以访问它吗?如果您只需在浏览器中输入http://xxx/image001.gif网址,该图片是否会显示?如果没有,我会说这是你的问题。

#5


0  

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.

确保图像的URL(位置)正确并添加斜杠。如果仍然不起作用,请检查是否可以显示同一目录中的任何其他图像。如果他们这样做,然后重新上传图像,然后再试一次。如果未显示其他图像,并且您确定该URL正确,则尝试编辑图像目录和图像的读取权限。我无法想象它可能是由权限引起的。

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.

除非有一个非常具体的理由在MS Word中生成HTML,否则我建议你不要这样做。即使对于之前从未见过HTML或CSS的人来说,他们既简单又整洁,可以产生比MS Word更好的结果。

#6


0  

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

Word 2007是否允许访问互联网?也许有防火墙规则阻止它?

#7


0  


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.

我相信你会得到结果。我检查了一下。