1

I've been at it for quite some time and all i could uncover was this pdf2dom parser and probably a reverse engineered version of this. Anyway, here are my questions. For any rendering engine its input should be a stream of data (in my case the pdf content) and its output should be a chosen format (in my case DOM, HTML & CSS).

  1. However, instead of using java or c++, is it possible that i get the stream of "pdf data" (which is something i have no idea about) from the server and store into a javascript variable and use javascript to render it and append it to the DOM?

  2. How does the raw "pdf data" appear (is there any particular format.. etc)?

All inputs are welcome.

NOTE : Should be IE compatible.

2 Answers 2

6

It's been done already. The result is pdf.js. Note that it's working by rendering the PDF onto a canvas. The result can be guaranteed that way; some features of PDF wouldn't be possible outside the canvas currently.

Sign up to request clarification or add additional context in comments.

4 Comments

Hey that's really nice, had no clue about this project.
Sorry. My bad. I did come across this, but canvas is not the option for me because i have to support ie 6,7,8 too X-D, hence i have to do the rendering myself. Ill update my question. +1 as this is next best thing.
@Astroth: you could try using it with ExplorerCanvas. It wouldn't be perfect, but I think it would probably do a generally passable job. Just as good as you could manage without using the canvas, anyway, I imagine.
hmmm.. excanvas eh? yeah ill give that a shot.
2

PDF is generally a subset of PostScript + options for embedding flash, JavaScript and all sorts of other things.

Translating PDF trivially to HTML (/DOM), and have it render in a correct-ish manner is all but impossible. As an example, PDF uses JPEG images, but with subtle changes here and there, which means you have to convert them before use anywhere else. Try reading some presentations from the PDF.js-guys, and you'll find quite a long list of WTFs.

However, if you only have simple PDF's (plain text; no images, etc.) and don't care about preserving anything but the simplest of layout, you should be able to scrape out string data from the PDF's and put it into the DOM.

Personally, however, I believe that it would be simpler either to force users to have a plugin (flash/acrobat/...), or render the PDF's server-side and serve them as images to the browser.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.