How To Preview Doc And PDF Files In Browser

How To Preview Doc And PDF Files In Browser

File preview seems to be a common thing, so many developers might think that asking Google How to preview Word document in browser? would be enough to find a perfect solution for their project, because how such a popular thing like file preview can be so hard to achieve?

Looking it up on Google will most likely lead you to use Google docs viewer or inline HTML file embedding eg. with no specific information about the problems that both of these solutions have.

What do I mean by file preview? I mean viewing a file on a website, the same way as on a desktop, within a dedicated app. If you want to preview your file, all you need is direct the URL to the file, but how can you know that you have a direct URL? For most cases, pasting it in your browser will automatically force a download process (except pdf’s, most likely they’ll open up in your browser window). Let’s see how this can be implemented.

IN THIS BLOG POST and 2 more chapters

Preview files with HTML inline embedding

Inline embedders are: , and , their way of working is pretty much the same, they’ve got slight differences which are not significant for us at this moment.

How to use it?

Add inline embedder element on your website and in src attribute pass it a direct URL to your file.

Pros:

Cons: