首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在ASP中插入word文件中的图像

在ASP中插入word文件中的图像
EN

Stack Overflow用户
提问于 2011-01-28 14:06:50
回答 1查看 2.6K关注 0票数 0

我正在尝试使用ASP Classic在服务器上自动制作一些word文件。它工作得很好,但唯一的问题是,当我下载文件时,里面没有图片,相反,我得到了类似占位符的东西。下面是我的代码:

set fso = createobject("scripting.filesystemobject")

Set act = fso.CreateTextFile(server.mappath("/") & file_being_created, true)

act.WriteLine("<html xmlns:v=""urn:schemas-microsoft-com:vml""")

act.WriteLine("xmlns:o=""urn:schemas-microsoft-com:office:office""")

act.WriteLine("xmlns:w=""urn:schemas-microsoft-com:office:word""")

act.WriteLine("xmlns:m=""http://schemas.microsoft.com/office/2004/12/omml""")

act.WriteLine("xmlns:css=""http://macVmlSchemaUri"" xmlns=""http://www.w3.org/TR/REC-html40"">")

act.WriteLine("<title>testing</title>")

act.WriteLine("<body> " )

act.WriteLine("<img src='http://mysite.com/images/pic.jpg' width='800' height='200'/><br />" )

act.WriteLine(rsInvoices("invoiceClientID") & "<br />" )

act.WriteLine(rsInvoices("invoiceNumber") )

act.WriteLine("</body></html>")"

act.close

有没有想法在word文件中有图片?提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-01-29 15:06:51

好的,为了得到这个答案,我创建了一个新的Word文档(使用Word 2010),从我的硬盘中插入一张图片,然后将文件保存为HTML文件。然后我看了看结果页面,试图解构Word在做什么。我发现除了超文本标记语言<img>标记之外,Word还创建了一个被conditional comment隐藏的<v:shape>元素。这是我根据你的例子想出来的:

代码语言:javascript
复制
<!--[if gte vml 1]>
<v:shape id="Picture1" style="width:800px;height:200px;">
 <v:imagedata src="http://mysite.com/images/pic.jpg"/>
</v:shape>
<![endif]-->
<![if !vml]>
<img src='http://mysite.com/images/pic.jpg' width='800' height='200' v:shapes="Picture1"/>
<![endif]>

如果您将此文件作为.doc文件提供服务,则可以通过只包含<v:shape>元素并省略条件注释来节省一些空间和重复内容。

代码语言:javascript
复制
<v:shape id="Picture1" style="width:800px;height:200px;">
 <v:imagedata src="http://mysite.com/images/pic.jpg"/>
</v:shape>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4825370

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档