How to display PDF, word, xls and PPT in HTML


1. Pdf file online preview

1. HTML5 new tag < embed > definition and usage

The < embedded > tag defines the embedded content. The tag is self closing. That is to say, if the browser does not support PDF embedding, the content of the tag will not be visible.


< embedded SRC = / file / operation manual. PDF “type =” application / PDF “width =” 100% “height =” 100% “/ >


The < iframe > method is one of the simplest ways to embed PDF. However, if the < iframe > browser does not support PDF rendering, it may not be able to provide enough backup content.


< iframe SRC = your PDF address "width =" 100% "height =" 100% ">
  This browser cannot support PDF, please click to view:
  Download PDF</a>


Unlike < embed >, < Object > prompts content if the browser does not support PDF embedding. All browsers support the < Object > element, but there are often differences in how they are implemented in each browser. If you use the < Object > element, be sure to thoroughly test your page in your browser and operating system.


< object data() / file / operation manual. PDF "type = Application / PDF" width = 100% "height = 100%" > the
This browser does not support PDF. Please click to view:
Download PDF < / a ></p>

2. Word, xls, PPT online preview

Word, PPT and XLS files are relatively simple to realize online preview, which can be realized directly by calling Microsoft’s online preview function (preview premise: resources must be publicly accessible)

<iframe src='' width='100%' height='100%' frameborder='1'>

SRC is the file address to implement preview

Add: Google’s document online preview implementation is the same as Microsoft’s (resources must be publicly accessible), but need to go over the wall

<iframe src=""></iframe>

3. Xdoc online preview

Xdoc can preview DOC documents represented by datauri. In addition, xdoc can also realize online preview of text, text with parameters, HTML text, JSON text, official documents, etc. for specific implementation methods, please refer to the official documents

The following method can quickly preview word, but there may be some restrictions on the editor used for the file

<a href="" target="_blank" rel="nofollow">XDOC</a>

This article about html display PDF, word, xls, PPT method example article introduced here, more related HTML display PDF, word, xls, PPT content, please search the previous articles of developeppaer or continue to browse the related articles below, I hope you can support developeppaer more in the future!

Recommended Today

The road of high salary, a more complete summary of MySQL high performance optimization in history

preface MySQL for many linux practitioners, is a very difficult problem, most of the cases are because of the database problems and processing ideas are not clear. Before the optimization of MySQL, we must understand the query process of MySQL. In fact, a lot of query optimization work is to follow some principles so that […]