13 ms·
PDF Reader in JavaScript
- albb0920 15y agoCant find a link to working demo, I'm just too lazy to git clone.
- wccrawford 15y agoI'd like to see more, too. From the readme, that seems very experimental and not likely to render much of anything yet.
- devongovett 15y agohttp://devongovett.github.com/pdf.js/test.html http://devongovett.github.com/pdf.js/test.html
- GetOberIt 15y agoThis doesn't show anything but garbled text everywhere (in Chrome). My minimum font size of 14 screwing it up?
- micheljansen 15y agoI couldn't find a demo online and was too lazy to deal with Chrome Local Policy madness, so I temporarily put one up here: http://pumpkin.micheljansen.org/~dawuss/pdf.js/test.html http://pumpkin.micheljansen.org/~dawuss/pdf.js/test.html It has some obvious flaws, but it already works surprisingly well!
- karolist 15y agogit cloned test.html did not work with latest versions of Firefox, Chrome, Safari for me, yet yours does. I find it strange that there's some policy more restrictive on local content than on remote one, provided yours work perfectly.
- micheljansen 15y agoChrome does not allow scripts to access files on a local filesystem unless you specifically tell it to do so by starting it with --disable-web-security as an argument. See http://code.google.com/p/chromium/issues/detail?id=40787 http://code.google.com/p/chromium/issues/detail?id=40787 for a discussion (and a lot of frustrated people).
- lisperforlife 15y agoTo simply start an arbitrary HTTP server to serve up files in a directory I use python's SimpleHTTPServer. This works on most Linux and Mac boxes as they package python along with the distribution or the OS. python -m SimpleHTTPServer This serves the files off the current folder under port 8000.
- bergie 15y agoSomething similar for Node.js: https://github.com/balupton/simple-server https://github.com/balupton/simple-server
- knowtheory 15y agoChrist on a stick. I submitted this and an example 3 hrs ago. sigh. oh well. http://news.ycombinator.com/item?id=2657412 http://news.ycombinator.com/item?id=2657412
- deleted 15y ago[deleted]
- knowtheory 15y agoYeah, stuff falls off the top of "new" so easily too, since there's so much crap shoveled into it. Edit: not sure why parent was deleted, it said that timing matters (which it does).
- joshuacc 15y agoYou may wish to edit your comment to be less offensive to Christians and other religious readers. We may not be particularly vocal around here, but we do exist.
- knowtheory 15y agoNo, i don't think i'll edit it (nor do i wish to), but i will apologize for offense i have caused, as that was not my intent. Edit: I just want to be clear, you see things like "goddamnit" and other ppl using the words "christ" or "god" (in what others may see as taking them in vain) all over the place including on HN. I don't see what the big deal is there either. So really, i do mean it when i say i intended no offense.
- joshuacc 15y agoThank you for the apology. The distinction I would make between your comment and "goddamnit" is that while I don't particularly like either one, "goddamnit" doesn't actively mock God/people's religious beliefs about God. On the other hand "Christ on a stick" certainly seems like going out of one's way to mock the crucifixion/people with religious attachment to the crucifixion. Does that help explain where I'm coming from?
- stephth 15y agoDoesnt seem to work on MobileSafari. Using iOS 4.2.1.
- swah 15y agoI also hoped this submission could trigger a discussion about the code style. This guy is a Mozilla contributor, probably what other posts mean when they talk about "great programmers", right? Yet, for now, his implementation is a single 3000 line file. [edited for alternate ending] So there is this guy who writes a PDF viewer in a 3000 line file, and the guy who writes another simple web app neatly organized in 42 files... Which one would you want on your team? I wonder how jslinux source code is organized.
- drivebyacct2 15y agoWhat are you asking me to agree about? I would never get caught dead working on a 3000 line file, and honestly, that seems like a terrible way to have to add new features.
- barrkel 15y agoSome perspective: $ wc -l expr.c decl.c 26638 expr.c 34860 decl.c
- drivebyacct2 15y agoReally? Downvoted this much for simply implying that I don't appreciate 3000 line files? I didn't imply that it was bad or wrong, just that I wouldn't prefer to work with that type of style. And I hardly think that a couple of hyper counter examples takes away from my own opinion in coding style.
- ChrisArchitect 15y agonice technology demo -- I like using google quick view for pdf reading...this is a nice alternative... dreaming up uses for it - immediate display and download of pdf receipts that sort of thing?
- ChrisArchitect 15y agospeaking of google ..... so much for Chrome's built in pdf viewer..heh.
- Lennie 15y agoFeels a bit like deja vu from the google native client. As it was proven that many, many things are already fast in JavaScript.
- bzbarsky 15y ago"Fast" is always a relative concept.... http://devongovett.github.com/pdf.js/test.html http://devongovett.github.com/pdf.js/test.html is about 4x faster in a tip Firefox than a tip Chrome for me.
- starwed 15y agoThe author points out in a blog post that this, being pure .js, doesn't need any sandboxing. Also, it'll actually be used by FF for rendering PDFs in the future, apparently.
- Gerdus 15y agoSweet. Scribd has an HTML5 document viewer so a PDF viewer is certainly doable. Maybe this will be included someday as a minimal PDF viewer in firefox. Now all we need is a proper javascript printing api and almost all business application can be done in the browser.
- windsurfer 15y agoBut this is pure client-side. Scribd does server-side generation of the HTML5 page.
- bennytheshap 15y agoI think it's not just the Chrome local policy that's getting in the way, but that the code does an XHR request and I don't think any browser passes that through straight to the filesystem.
- pcwalton 15y agoFirefox does, if the calling web page is itself a local file and the XHR requests a file in the same directory as or in a subdirectory of that page.
- rdamico 15y agoAt Crocodoc we tested out a similar approach using the Canvas element to render pages, but ultimately opted to go the @font-face route for a number of reasons, including: - Near-instant client-side rendering (albeit a one-time ~5 second wait during server-side processing) - Native font rendering (Canvas rasterizes all text and doesn't benefit from technologies like ClearType) - Native text selection (which is important for overall UX and our annotation tools such as highlighting) - Better performance on mobile devices (this is an ongoing project) Here's a comparison of the test file micheljansen links to (thanks!) compared with the same PDF in Crocodoc: - Canvas rendering: http://bit.ly/kU0mlW http://bit.ly/kU0mlW - Crocodoc rendering: http://bit.ly/je2wcv http://bit.ly/je2wcv Edit: By the way, we're really impressed by this canvas implementation :-)
- pbreit 15y agoThe only reason this project is interesting is because it does not use any server side processing (beyond serving).
- bfirsh 15y agoI expect PDFs could be rendered client-side with @font-face by using data URIs.
- swah 15y agoI had never heard of crocodoc and was very impressed with this rendering. What browsers do you guys support?
- 15y ago
- neovive 15y agoVery interesting. Is there a performance benefit to using "const" instead of "var" to declare variables in JS?
- tomp 15y agoExample rendere document: http://devongovett.github.com/pdf.js/test.html http://devongovett.github.com/pdf.js/test.html
- singingfish 15y agoDoes this library provide the potential to extract the text out of the PDF for further processing?
- mbrubeck 15y agoHere's a blog post by the authors (members of Mozilla's graphics and JavaScript teams) explaining the motivation and direction of the project: http://andreasgal.com/2011/06/15/pdf-js/ http://andreasgal.com/2011/06/15/pdf-js/
- johnx123 15y agoCorrection: It's not "reader", but "writer" (rendering) There are other libs out there: WPS: PostScript for the Web http://logand.com/sw/wps/index.html http://logand.com/sw/wps/index.html jspdf http://code.google.com/p/jspdf/ http://code.google.com/p/jspdf/
- georgemcbay 15y agoIt is a "reader" from the context of the user -- it is software the user uses to read a PDF. In this context a "writer" would be software you use to author a new PDF file. I think it is safe to say this is the more widely accepted terminology on this sort of thing considering Adobe's own PDF viewer is of course called "Adobe Reader".
- tiddchristopher 15y agoTypographic ligatures (character combinations such as ff and fi) are being displayed as gray rectangles in Firefox 4 on Windows 7.
- lloeki 15y agoSame with Fx4 on OS X. Chrome 12 skips ligatures entirely (so difficult reads difcult), while Safari 5 just renders a big boxed nothing in lieu of the document. There seem to be some trouble with curly braces around the emails in the header.
- bnewbold 15y agoI've been having very good results with the Inkscape SVG renderer (inkscape -z input.pdf -l output.svg). Not pixel-perfect, but handles images and vector diagrams pretty well, and text is selectable/searchable. This would be a server-side solution, not client-side.