6 ms·
Google's Javascript PDF Viewer is Embeddable
- blasdel 17y agoIt also works as its own page: http://docs.google.com/gview?url= http://docs.google.com/gview?url= Does anyone know if firefox extensions can register as handlers for MIME types, or if they're restricted to diddling with chrome / pre-existing pages? It'd be really easy to write a WebKit plugin to do it, but not very useful since Safari ships with a flawless PDFKit-based viewer. I want to get this working in Firefox, but NPAPI plugins are really gross. It looks doable that way, as it appears that a naked nsplugin still gets a DOM and everything, so I could just immediately set window.location.href and be done with it.
- thristian 17y agoIt sounds like you're looking for window.navigator.registerContentHandler: https://developer.mozilla.org/en/DOM/window.navigator.registerContentHandler ...except a website can only register themselves as a content-handler. You could probably hack up a bookmarklet to do it, if you can't find an XSS vector, but I can't seem to make it work myself.
- blasdel 17y agoSo... close... It'd be easy to make a greasemonkey-style extension that calls this on *, but it wouldn't work for links to other domains (which I'd bet are the majority of PDF links)
- jacquesm 17y agoThat would already be very useful though, for things like online papers and datasheets, which as a rule sit on the same server as the page you're looking at.
- legooolas 17y agoIt's becoming more common to use a separate domain for static content like this to be cached more effectively (and to have no cookies etc sent), so it may not always be the same server as the page you're looking at.
- joubert 17y agoI presume one can't use this viewer in your own project (e.g. as a file viewer in a web app). Does anybody know of similar project but that can be used in your own web app?
- blasdel 17y agoIf you serve PDFs with public URLs that Google can GET, you can use this in your web app.
- patio11 17y agoI think he is talking about it being risky to assume that the undocumented cross-site embedding is a feature Google is committed to supporting in the coming years and not, say, a wee unintended data leak that any engineer in their megacorp could plug at any time, including smack-dab in the middle of your public launch.
- blasdel 17y agoBut it didn't do this before -- you used to have to explicitly upload the files to a Google Docs account. Someone explicitly added this feature, and I imagine that it will replace the lame "View as HTML" links on SERPs very soon. This ain't going away.
- jules 17y agoYou can always replace it with an <object> tag.
- makmanalp 17y agoFor HN as an alternative to scribd's vaccuum maybe?
- axod 17y agoscrolling/zooming even works! die flash, just die.
- apgwoz 17y agoUntil you said that, I didn't even realize it wasn't flash. This rocks!
- mooted 17y agoText copy wont work. I really dont see anything new here. This is exactly the same stuff they have at Google books. Except now its in an iframe . Flash implementations are obviously superior as of now.Also, try building a decent browser game in javascript and html5.
- ZeroGravitas 17y agoText copy worked for me. (Firefox 3.5, Ubuntu Jaunty)
- chaosprophet 17y agoActually games that don't involve too much motion tweening (think sudoku, tic tac toe etc.) can be done pretty well with js and html5.
- mooted 17y agoany live examples?
- chaosprophet 17y agoNope, it was just a thought. You're just going to be changing the innerhtml of DOM elements. Shouldn't be tough.
- tolmasky 17y agoThis is very cool. My only gripe is that if they are going to fake their own selection, then they should override command-a (select all). I tried this, and now I have google's selection AND the entire page selection, which I can't get rid of.
- Maro 17y agoI hope somebody makes a Firefox addon which lets me right-click on a PDF link and select "Preview" using the Google previewer.
- Maro 17y agoThere's this, but it sucks: https://addons.mozilla.org/en-US/firefox/addon/10737 https://addons.mozilla.org/en-US/firefox/addon/10737 You click a link and it first does some communicatin with Google Docs to get some kind of security token, so it takes 2-3 seconds for the new tab to come up. EDIT: A kickass version, just uploaded it to the Firefox Addons site: https://addons.mozilla.org/en-US/firefox/addon/14226/ https://addons.mozilla.org/en-US/firefox/addon/14226/
- blasdel 17y agoI think that addon is worse than you describe: doesn't it add the files to your logged-in Google Docs account, and do so by uploading said files from localhost?
- Maro 17y agoYou're right, I just checked my Google Docs and it added the files. The hacked version just opens the URL and passes in the PDF url as a HTTP param.
- pasbesoin 17y agoYou mean the second link in your granparent post, right? Thanks for that -- works for me. I was looking for something like this just the other day.
- blasdel 17y agoBut I don't want to right-click -- adding bloat to the chrome is entirely the wrong way to go about doing this, but unfortunately Mozilla has a bug up their ass and won't let you do it right as an extension. The right way is to register application/pdf in the browser -- which you can only really do with a native-compiled NPAPI plugin. It looks like it is possible to package them inside a extension xpi, but I'm not sure if addons.mozilla.org will distribute such things.
- stjarnljuset 17y agoIt's good to know that there are alternative ways to embed PDFs, but I'm a little confused by the reaction in the comments. Is this a big improvement over simply using the object tag? http://blog.flashcolony.com/?p=244 http://blog.flashcolony.com/?p=244
- blasdel 17y agoYes, for a wide variety of reasons: * Before version 8, Adobe's plugin was an epic piece of shit on all platforms - old versions are on hundreds of millions of computers! - it's still really crashy on Linux (especially in nspluginwrapper) - The only OS X browser they support is Safari, in which it is unnecessary * Google re-hosts the file for you * It is ridiculously snappy with no main-thread-blocking initialization * It will never crash your browser * Your users don't have an ingrained hatred towards it - Rebranding the free Acrobat as "Adobe Reader" was the stupidest thing they've ever done (ever hear a user say 'my Adobe is broken'?)
- seiji 17y agoI can't tell if you're being facetious in your last line, but I used to work at a place requiring, in their own words, "Adobe must be installed on every computer" long before they changed the Acrobat name.
- est 17y agoI wish their Chat Window on Google Spreadsheet were embeddable , too.
- ars 17y agoIt's images! Is that really better? It's not text layed (laid?) out in a cool way with HTML. It's a png image of each page of the pdf. It's quick sure, but images? Not text? It just seems wrong - why even make pdf's, if all you want is an image of the text?
- btn 17y agoGenerating an image from the PDF server-side is the only way to faithfully perserve the layout of the PDF. For some PDFs, Google will give you the option to view it as HTML (it seems to just be the PDFs returned in search results?). It's usable for mostly-text documents, but that's about it.
- jbrun 17y agoCan anyone confirm if this works in Internet Explorer?
- fauigerzigerk 17y agoIt does. Even current versions of IE can show PNGs in iframes, believe it or not ;-)
- _ck_ 17y agoHere is a bookmarklet I just wrote to look at all the links on a page and open any ending in ".pdf" in google's viewer. (if you have firefox set to open tabs for windows, it will open them in new tabs) Feel free to share and improve. - - - (select entire text and make into a link) - - - javascript:(function(){dl=document.links;for(i=0;i<dl.length;++i){if(dl[i].href.substr(-4)==".pdf"){window.open("http://docs.google.com/gview?embedded=true&url="+dl[i].href);}}})() - - -
- chaosprophet 17y agoI made this into a greasemonkey userscript. It searches for PDF links on a page and sets them to open in Google's pdf viewer. Userscript at: http://userscripts.org/scripts/show/57453 http://userscripts.org/scripts/show/57453 Tested on Minefield latest nightly, winxp, greasemonkey.
- parterburn 17y agoThanks! It needs to not work on http://docs.google.com http://docs.google.com so that you can click the "Download" link if you need to...otherwise you are stuck in a loop. Also, I noticed that the search on the full-screen page isn't always available (ie http://bit.ly/4tf1xt http://bit.ly/4tf1xt)
- chaosprophet 17y agoAbout the search not being available, I think it's something to do with google's implementation, not the script. The other, I'll fix ASAP. Edit: Fixed version available now.
- Chramard 17y agoThis one transforms the links rather than opening them automatically. For pages with a lot of pdf links. javascript:(function(){dl=document.links;for(i=0;i<dl.length;++i){if(dl[i].href.substr(-4)==".pdf"){dl[i].href="http://docs.google.com/gview?embedded=true&url=+dl[i].href;}}})()
- ntoshev 17y agoVery smooth, but why does it lack a search box?
- ZeroGravitas 17y agoThe full page version has a (pretty good) search function. I'm not sure why they don't have it the embedded one. Even if you just got taken to the results in the full version.
- ntoshev 17y agoACtually the full page version highlights the results but doesn't navigate to them. Also it seems to be substring search, not an indexed one.
- fara 17y agono search, no print, no save in the viewer. you must always open the new window...
- ComputerGuru 17y agoDo you think the same thing exists for Word documents?
- Chmiff 17y agoI hope that it will be extended to TeX, PostScript and ODF as well. The viewers for the first two formats are lagging in the UI department, it would be really nice to be able to access them online.
- stef25 17y agoScribd must love this