Question

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

Was it helpful?

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

OTHER TIPS

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.

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top