like Baidu Library, such as how to implement the control? That is, no matter what type of file is uploaded, you can preview it, regardless of whether the client browser has the corresponding software installed.
because the project needs, but also need a similar function, so I also read the relevant information. summed up the previous implementation of the way. for general picture files, notepad files, the browser can be directly opened preview nature can be implemented, do not need special handlingPDF file can also be opened via JS script, do not need the client installation software specific referenceBut how does the common Word,excel,ppt file implement previews? In fact, a variety of implementation of the preview technology, basically the first conversion, such as the conversion to HTML files, or the PDF file can not be implemented preview it? As for the implementation can only preview can not download, modification, basically is to convert the file into a PDF file in a Flash file, such as the use of Pdf2swf,swftools,flexpaper can achieve similar Baidu library effect.
so the core question is how to convert the Word,excel,ppt file into a PDF file that can be previewed directly. There are several main ways to achieve this:
1 Using Microsoft's software to convert files into HTML files in fact, Microsoft itself with such a function, directly open the file save as you can. But how is it done through the program? you can only use Microsoft Office's COM components, which is relatively easy to implement, but using COM components, you must install Microsoft Office, or you must know the dependencies between COM. But using COM is prone to a variety of errors, and it is generally difficult to find a solution. Web programs to call COM, which involves permission problems, but also bad processing. Of course, you can convert the function of the file into a service, as long as the discovery of uploaded files on the conversion, there is no Web program permissions problems. in fact, Microsoft also provides an online preview of the way, specific reference, but the requirements must have an external network. or install the software in the company, how to install, I am not very clear.
2 Use of third-party software to convert to PDF, or HTML files, such as Pageoffice,aspose, etc., but are charged, there is no free of discovery. Please refer to the official website for details on how to use.
In the moment there is no good way to find, so the use of Microsoft's COM implementation of online file preview function. CSharp Call Microsoft COM convert Word to HTML CSharp call Microsoft COM to convert Excel to HTML
CSharp calls Microsoft COM to convert PPT to HTML
Reference document. NET Implement Office file preview
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
A discussion on the content technology of online preview file like Baidu Library