Need to view ms office documents in a php web based document management system

半城伤御伤魂 提交于 2019-12-11 10:56:59

问题


I want to make a document viewer for MS office docs and pdf for my inhouse Document Management System made in php and mysql. I dont want the users to be able to edit these documents. we need to make it browser friendly as our system is web based.

Thanks in advance

Chintan


回答1:


You can also use iframe for that

<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>

but you should replace the http://infolab.stanford.edu/pub/papers/google.pdf with your own address. As I mentioned, the document viewer works for PDF and PPT files.




回答2:


You can use Google Docs and embed it in your page. You can do as below:

http://docs.google.com/viewer?url=YourDocumentUrlHere

All viewer URLs should use the path http://docs.google.com/viewer . This path accepts two parameters:

url : The URL of the document to view. This should be URL-encoded.
embedded : If set to true , the viewer will use an embedded mode interface.

EDIT:

After your comment that you don't want to have your files uploaded to the Google server, you can still use COM libraries in Operating System through PHP to open the MS Office Documents.

$doc = new COM("word.application") or die ("Could not initialise MS Word object.");
$doc->Documents->Open(realpath("YourDocument.doc")); 
// Extract content.
$content = (string) $doc->ActiveDocument->Content;
echo $content;
$doc->ActiveDocument->Close(false);
$doc->Quit();
$doc = null;
unset($doc);

You can further go on formatting the text to be shown using CSS and HTML. Hope this helps you out.




回答3:


We did it!!!

While uploading the document we are storing the original document in the repository. While viewing the document, we are using JODconverter and openoffice to view the documents in the iframe.




回答4:


You can use GroupDocs Viewer for the purpose. All you would need to do is embed it into your page and the document (DOC, PDF, PPT, XLS etc.) will be available to be viewed. It is a user and browser-friendly tool. To embed docs, it will provide an embed code and you can make use of it.

I am recommending it because I have found this viewer to be more secure compared to Google docs and the document rendering is quite fast and close to the original.



来源:https://stackoverflow.com/questions/14726288/need-to-view-ms-office-documents-in-a-php-web-based-document-management-system

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!