0

I am building a basic document management system as a web application that has some simple functionalities for now. One feature I'd like to integrate into the app would be the ability for the user to view a document on the web page itself without having to download it. Since the documents are stored on a private local server, is there anyway to pull it up and view it directly on the webpage (like a homemade version of the document embed-er on Scribd)?

It doesn't have to be anything complicated, just a simple one that allows user to get a preview of the file. It's a php based web application. Google searches are giving back suggestions to use CrocDocs and GroupDocs which both require that you first upload the files onto their system. Snowbound viewer isn't free for use. I've also seen suggestions recommending a homemade one using OpenOffice and JODConverter plus iframe, this seems like a great solution, but it wasn't very thorough.

Any help appreciated, Thanks!

AStack
  • 1
  • 1
  • 2
  • Which formats are you planning to support? – luchosrock Jul 15 '15 at 04:12
  • @luchosrock - I was thinking pdf, basic Microsoft documents (docs and excel), images (png and jpeg), and plain text doucments (txt, rtf). – AStack Jul 15 '15 at 04:29
  • Did you finally found a solution which worked ? I have exactly the same requirement in my webapp to allow preview of PDF, docx, xls, ppt and video files (play/pause) without having to download. – NKM Jul 07 '21 at 02:10

3 Answers3

0

If you want to display pdf's then the best option is pdf.js. It is really easy to use.

You can download the latest version here.

Now extract the zip file and put it on a server(on your localhost if you are using it offline). To show the pdf files traverse to web/viewer.html from the localhost and it should load its default pdf.

To show your pdf's use: viewer.html?file=relative/path/to/your/pdf

Look here for more details on how to dynamically assign PDF file paths to the viewer.

For other documents you can use google-docs-api(supports various diff. docs). It can be used to embed documents on a webpage as well as to view them separately. Look here for an example.

Riddhesh Sanghvi
  • 1,218
  • 1
  • 12
  • 22
0

Disclaimer: I work in GroupDocs and would like to clarify the following:

Google searches are giving back suggestions to use CrocDocs and GroupDocs which both require that you first upload the files onto their system.

GroupDocs also offers downloadable .NET and Java libraries, which can be deployed on-premises and allow you to store documents locally. So, if you're fine with a paid for solution, you're welcome to try out the libraries.

0

If you don't need a protection content feature, then there is simple way to do it is using free service from Google & Microsoft

For example, you have document is hosting in your server like http://yourdomain.com/document.pdf

Then you can use iframe to embedded into your side

  1. Using Google doc viewer (support good with PDF) <iframe src="http://docs.google.com/gview?url=http://yourdomain.com/document.pdf" style="width:100%; height: 100%" frameborder="0"> </iframe>

  2. Using Microsoft document viewer (support all type of office document .docx, .doc, .pptx, ...)

<iframe src="https://view.officeapps.live.com/op/embed.aspx?src=http://yourdomain.com/document.pdf" style="width:100%; height: 100%" frameborder="0"> </iframe>

You can combined 2 types of viewer to support multiple document type.

Johnny Le
  • 1
  • 5