简体   繁体   English

如何在aspx页面上显示Word文档?

[英]How to display word document on a aspx page?

I want to display my updated document to the aspx page. 我想将更新后的文档显示到aspx页面。 I searched a lot for this. 我为此进行了大量搜索。 But I am not able to find any proper way. 但是我找不到任何合适的方法。 I have tried so many things. 我已经尝试了很多东西。

  1. I have tried Microsoft Interop dll to convert word document to pdf and then I display pdf file to the page it worked but found Issue that Interop dll cannot be used on production machine. 我已经尝试过Microsoft Interop dll将Word文档转换为pdf ,然后将pdf文件显示到它可以工作的页面,但是发现不能在生产计算机上使用Interop dll的问题。 And other thing Interop dlls cannot be copy to project. 其他Interop dll无法复制到项目中。
  2. I am updating my word document using OpenXml. 我正在使用OpenXml更新我的Word文档。 So I tried OpenXmlPowerTool to convert Document to Html. 因此,我尝试使用OpenXmlPowerTool将Document转换为HTML。 But It is not converting document properly. 但是它不能正确转换文档。 Images are not visible some formatting of the text are not proper. 图片不可见,某些文本格式不正确。

The other problem is that I cannot use third party tool which I have to purchase. 另一个问题是我无法使用必须购买的第三方工具。 I can use only open source product which are freely available. 我只能使用免费提供的开源产品。

Can anyone knows how can I do this? 谁知道我该怎么做?
Any suggestions will be appreciated..! 任何建议将不胜感激..!

您可以使用一些专有库(例如aspose )将其转换为pdf,并通过adobe acrobat套件( codeproject howto )向用户显示pdf文件。

This works for me, but you need to have your document as a binary array. 这对我有用,但是您需要将文档作为二进制数组。 You can, however, work from here: 但是,您可以从这里工作:

...
byte[] docFile = null;
...
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment; filename=\"Document.doc\"");
Response.ContentType = "application/x-unknown";
Response.BinaryWrite(docFile);
Response.End();

Note: application/x-unknown is used to force the browser to prompt the user to open or save 注意:application / x-unknown用于强制浏览器提示用户打开或保存

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM