Sandy
Sandy

Reputation: 6353

How to read a pdf file by using HTML5?

I want to create html file by which i could read any PDF file by providing the source of that PDF file. How can i do this by using only html5? For example i want read a pdf file which is available in C drive so scr="http://virdir/mypdf.pdf".

I want something like this.

Upvotes: 1

Views: 8504

Answers (2)

cnvzmxcvmcx
cnvzmxcvmcx

Reputation: 1111

Here is an open source pdf reader written in javascript.

https://github.com/mozilla/pdf.js

There are APIs available to play with. It comes built into Firefox browser and has good support from Mozilla community.

Upvotes: 1

Matthew Flaschen
Matthew Flaschen

Reputation: 284836

You want to use the developing HTML 5 File API. Mozilla has a good explanation, and you can also refer directly to the spec.

Since PDF is a binary format, you will probably want to use FileReader.readAsBinaryString().

Parsing and rendering (e.g. to a canvas) a PDF in JavaScript is possible, but it would be very challenging.

Upvotes: 3

Related Questions