希望在基于mvc的asp.net网页中查看doc,pdf [英] wish to view doc,pdf in an mvc based asp.net web page

查看:53
本文介绍了希望在基于mvc的asp.net网页中查看doc,pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,





i有一个网页,我希望在网页paeg.how中查看doc,pdf等文档去做。请帮帮我。



提前谢谢



更清楚



考虑我是否有一个html页面,其中包含一个div标签。我需要在html中显示指定div中的doc。







i需要在我的网页上显示我们的PDF而不需要任何插件,它需要在所有浏览器中查看



问候,
shefeek

Hi all,


i have a webpage and i wish to view documents like doc,pdf in that web paeg.how to do that. please help me.

thanks in advance

more clearly

consider if i have an html page and which contains a div tag.i need to display the doc in that specified div in html.



i need to display our PDF in my web page without any plugin and it needs to view in all browsers

Regards,
shefeek

推荐答案

DOC可能意味着过时的Microsoft Word文档(现在的格式是Open XML,文件是命名为* .docx),PDF为PDF。尽管PDF是标准,但它不是W3标准的一部分,因此并非所有系统/浏览器都支持它,支持该标准的那些可能会使用一些用户可能不想安装的插件(我个人使用PDF查看器)浏览器不支持,无法在网页上查看这些文档,也不在乎它。因此,您永远不应该假设所有用户都将在浏览器中查看PDF。我不认为这是一个问题。忘记专有的Word文档。



尽管如此,网站也经常支持Word文档。在某些地区,这甚至是非常典型的(一个例子是求职网站)。秘诀很简单:文档在内部支持,仅在服务器端支持。文档的查看和编辑总是通过HTML呈现,模仿Word文档外观和样式,具有一定程度的相似性。



对于解析Word文档,您需要使用Microsoft Open XML文件格式。您可以随时学习格式,因为它们是标准化的。请参阅:

http://en.wikipedia.org/wiki/Office_Open_XML [< a href =http://en.wikipedia.org/wiki/Office_Open_XMLtarget =_ blanktitle =New Window> ^ ],

http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats [ ^ ],

http ://en.wikipedia.org/wiki/Office_Open_XML_file_formats [ ^ ]。



(不要将它们与OpenDocument混合, http://en.wikipedia.org/wiki/OpenDocument [ ^ ]。)



现在,还有另一种方法。有第三方产品使用Microsoft Office文档。如果他们能做到,你也可以做到。您只需下载一些开源产品的源代码并了解其工作原理。我所知道的唯一开源代码是OpenOffice本身(其中.odt来自)和它的 fork LibreOffice。请参阅:

http://en.wikipedia.org/wiki/OpenOffice.org [ ^ ],

http://www.openoffice.org/ [ ^ ],

http:// en.wikipedia.org/wiki/LibreOffice [ ^ ],

http://www.libreoffice.org/ [ ^ ]。



您可以下载源代码并查找代码使用几乎所有版本的Office文档。当然还有.ODT和所有其他OpenOffice / LibreOffice文档。



不建议在服务器端使用Office Interop程序集。请参阅以下Microsoft文章:

http:// support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2 [ ^ ],

http://support.microsoft.com/kb/257757/en-us [ ^ ]。



相反,建议使用Microsoft Open XML SDK:

或者,您可以使用Open XML SDK:



http://www.microsoft.com/en-us/download/details.aspx?id=30425 [ ^ ]。



这样,您就可以支持基于XML的新Office格式(如.DOCX,.XLSX),ECMA-376标准。



这是另一种方法: http://npoi.codeplex.com [ ^ ]。



请同时查看我过去的答案:

将Office文档转换为PDF而不互操作 [ ^ ],

您好如何使用c#.net 在Windows应用程序中显示word文件[ ^ ]。



-SA
"DOC" probably means obsolete Microsoft Word document (present-days format is Open XML, files are named *.docx), and PDF is PDF. Even though PDF is the standard, it's not a part of W3 standards, so not all systems/browsers support it, and those supporting the standard may use some plug-ins which some user may not want to install (I personally use the PDF viewer not supported by browser, cannot view those documents on the Web pages and don't care a bit about it). So, you should never assume that all users will view PDFs in a browser. I don't think this is a problem though. And forget about proprietary Word documents.

Nevertheless, Word documents are also often supported by Web sites. In some areas this is even very typical (one example is job hunting sites). The secret is simple: the documents are supported internally, only on server side. Viewing and edition of the documents are always presented through HTML which mimics Word document look and styling, with some degree of similarity.

For parsing Word document, you would need to use Microsoft Open XML file format. You can always learn the formats, as they are standardized. Please see:
http://en.wikipedia.org/wiki/Office_Open_XML[^],
http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats[^],
http://en.wikipedia.org/wiki/Office_Open_XML_file_formats[^].

(Don't mix them up with OpenDocument, http://en.wikipedia.org/wiki/OpenDocument[^].)

Now, there is another approach to it. There are third-party products working with Microsoft Office document. If they can do it, you can, too. You just need to download source code of some open-source products and find out how it works. The only open-source code I know is OpenOffice itself (where .odt came from) and its fork LibreOffice. Please see:
http://en.wikipedia.org/wiki/OpenOffice.org[^],
http://www.openoffice.org/[^],
http://en.wikipedia.org/wiki/LibreOffice[^],
http://www.libreoffice.org/[^].

You can download the source and find the code working with nearly all versions of Office documents. And, of course, .ODT and all other OpenOffice/LibreOffice documents.

It is not recommended to use Office Interop assemblies on the server side. Please see these Microsoft articles:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2[^],
http://support.microsoft.com/kb/257757/en-us[^].

Instead, Microsoft Open XML SDK is recommended:
Alternatively, you can use Open XML SDK:

http://www.microsoft.com/en-us/download/details.aspx?id=30425[^].

This way, you can support new XML-based Office formats (such as .DOCX, .XLSX), ECMA-376 standard.

And this is another approach: http://npoi.codeplex.com[^].

Please also see my past answers:
Convert Office-Documents to PDF without interop[^],
Hi how can i display word file in windows application using c#.net[^].

—SA


使用Google Doc Viewer!只需在你的DIV中添加如下标记:



Use Google Doc Viewer! just add a markup like the following inside your DIV:

<iframe src="http://docs.google.com/gview?url=http://infolab.stanford.edu/pub/papers/google.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>





只需将自己的文档文件设置为urlque ry string param就是这样!我在许多项目中使用它,它就像一个魅力。



Just set up your own documents file to the "url" query string param and that's it! I use it in many project and it works like a charm.


这篇关于希望在基于mvc的asp.net网页中查看doc,pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆