4

I have different file types such as pdf, jpeg, doc etc. I am trying to show the files without downloading. I was using Lightbox and it worked great for images files. But it doesn't work for PDFs and DOCs.

Is there any plugins to view different file types such as pdf, jpeg, doc etc?

Is there also a way to view pdf and doc using Lightbox?

1 Answers1

1

You can't render Word docs using client side libraries. As a hack you can use Google Docs to render their preview in an iframe as following

<iframe src="http://docs.google.com/gview?url=http://remote.url.tld/path/to/document.doc&embedded=true"></iframe>

Where URL is URL of the doc file.

For rendering PDF, you can use pdf.js

naqushab
  • 754
  • 1
  • 8
  • 24
  • Thank you for your response. Actually, the files are coming from the server in binary stream. In that case what could be done? – Galactic_Warrior Nov 04 '15 at 22:55
  • So you are downloading them. Yes, PDF.js will display binary stream coming from the server. – async5 Nov 05 '15 at 14:21
  • Google Docs fill download files from your server to their farm and feed you converted images from their servers. AFAIK there is a limit of documents you can convert using Docs. – async5 Nov 05 '15 at 14:23