Wednesday, September 09, 2009

Embeddable Google Document Viewer

Google Docs offers an undocumented feature that lets you embed PDF files and PowerPoint presentations in a web page. The files don't have to be uploaded to Google Docs, but they need to be available online.



Here's the code I used to embed the PDF file:

<iframe src="http://docs.google.com/gview?url=http://infolab.stanford.edu/pub/papers/google.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>

but you should replace the bold URL with your own address. As I mentioned, the document viewer works for PDF and PPT files.

Some other sites that offer similar features: Zoho Viewer, PdfMeNot.

Update (Sept. 25): The viewer is now available at https://docs.google.com/viewer. You can use it to embed PDF documents, PowerPoint presentations, and TIFF files.

Labels: ,

  58 comments ( Post a comment )
Where is the search feature?! :)
It's coming.
A bit weird that this viewer is not working with Chrome !!!
Scribd does the same, with way more features. But I like the idea that you can keep your files on Google Docs. If only it worked for other filetypes as well...
works for me in chrome
it's work on firefox!
My Google docs that host my PDFs takes a different format - there is no suffix with .PDF at the end of the URL.

For example: one document that I would like to share from google docs gives me the following URL:

http://docs.google.com/fileview?id=0B5ImRpiNhCfGZDVhMGEyYmUtZTdmMy00YWEyLWEyMTQtN2E2YzM3MDg3MTZh&hl=en

Please let me know where I am going wrong.

Thanks
Great tip. Thanks. Hopefully Google will provide the Embed code of the PDF and PowerPoint files directly in Google Docs.
Great tip, thanks.

And I'm sure Google will extend the viewer to other file types once Google Docs is able to accept them :-)
Alex,

Someone found that this may be extended to Chrome with the "--enable-viewer" flag.

http://www.downloadsquad.com/2009/09/09/google-docs-hidden-viewer-feature-coming-to-chrome-os/

Kevin
1 Place: Upload the PDF to Google Sites or other hosting. The URL of the file in Sites is something like http://sites.google.com/site/TITLESITE/PAGEX/NAMEFILE.pdf?attredirects=0, remove ?attredirects=0 and works fine.
Good feature. I'm agree with the other comments.
Why not a download feature in the viewer? What's a matter between GDocs and the PDFs??? Isn't very pretty to put a link outside the viewer to download the file...
And please, notice this feature in GDocs and allow other formats, but the PPT/PPS and the spreadsheets already have the embeddable viewer feature, too as an iframe.
@Kevin:

Yes, I noticed that, but the flag only works for the Chrome OS.
Bright feature.. it will help a lot for easy presentation ...Google is a dad of all with daily upgrades..!
this is good but it is not fully success it need to some optimization
How would people go about to making this content accessible to screen readers? I realise the document probably wont be read by a screen reader, but are their any tips on why this is better than linking externally and adding in the Anchor tag a title saying "This is a link to an external pdf document"?

What do you all think to that?
Will this work documents that are only available in corporate intranets?
Why the URL to the PDF file is not URL encoded ?
where's the print button?
I am missing the download button - there is no reason why you wouldn't someone let it download if he can view it (and even more extract the PDF link from the HTML source).
@Joscha, Fernando:

You can print/download the document if you click on the "open in new window" button.

@Lennert:

The document must be publicly accessible, so that Google can process it.
For print and download, just click the "Open in new window" button in the top right of the embedded object. Download and print options are available in this new window.
i've had this feature for ages now i thought it was for everyone interesting
@Alex Chitu yes, but that's not embedded. It would be nice to have print & save options without having to leave the page (thats the point of embeding the doc) as scribd does.
I agree with the comments above: dedicated 'Print' and 'Save As...' functions -- without opening another window/tab -- should be a must. Otherwise, this is just an interesting toy, without much real-world practicaility. //TB
I tried this out with my own pdf hosted on a public site and it didn't work. Got an error message saying, "Sorry, we are unable to generate a view of the document at this time." I changed the url to a pdf that was cached by Google and it worked. So has anyone managed to get this to work on a pdf that is not cached by Google?
@Anon:

It should work for most PDF/PPT files available online, even if they aren't indexed by Google. I've just uploaded a PDF file to Google Page Creator and the viewer displayed the file.
For those who want to see download/print links in the viewer, just add &chrome=true to the code.

http://docs.google.com/gview?url=URL&embedded=true&chrome=true
You have to be logged in to Google. Annoying?
No, you don't have to be logged in to Google. It wouldn't make any sense and the embedded viewer would be useless.
I want a pony too! Jesus, it's free people. If you want it to have different features go build your own.
Anon who likes a pony: Ok, it`s free, we just post some suggestions, may we?
Alex Chitu: Thanks for your orientation. Good work :)
It may be free - but how about animated page turning?

Google doc viewer doesn't cut the mustard for me (yet). I'd be much happier with the free offering from www.issuu.com.
How to set this so that we don't need to specify the width and height, instead, use all the screen available.
Is it possible to refer it to a particular page? Do you can link to different parts within a PDF?
Issuu.com does the job and gives you a beautiful reading experience. And it is free... Ü
Issuu.com and Scribd.com are great, but there are two downsides:

- they use Flash-based viewers, which are slower and might crash your browser
- you need to create an account and upload the files before embedding them, much like for YouTube. Google's viewer is a general-purpose solution for the files already available online.
Google has seemed to index the pdf. I cannot update the pdf in the reader without changing the pdf to a new and unique name on my site server. I've tried different browsers and clearing the cache.

Any thoughts out there?
It would be great if there was a print icon/text on the toolbar instead of having to open it in a new window.
This viewer don't work in Internet Explorer 8. In status bar: Wait: https://www.google.com/accounts/ServiceLogin?....... And IE try and try to connect...
Does anyone know if there is a size limit on the files? I am trying to post a .ppt that is about 3.8 MB, and the viewer gets to about 50%, stops, and gives me the message that "we are unable to retrieve the document."
i think i'll stick with adobe for the moment, tho this feature could prove useful in developing web applications
i have for example this link
http://delo.si/plugins/pedition/widgets/showpdfpage.php?date=20090921&pub=Delo&page=1
In real it's pdf but genarated with php, but this Embeddable Google Document Viewer recognize it us unknown file ...it would be much better that it would also allowed liks like this

iframe src="http://docs.google.com/gview?url=http://page.com/papers/index.php?&exportfile=myfile.pdf&embedded=true&TYPE=PDF"
style="width:600px; height:500px;" frameborder="0"

or. can be this problem solved on any other solution?
@Anonymous:

Encode the URL and it will work just fine.
will there be some javascript API for this Doc viewer?
So that u can for example - api.setPage, api.setFullscreen etc...
Like Scribd has
http://www.scribd.com/developers/api?method_name=Javascript+API
how to modify zoom, page number, view thumb on the left, etc.? Where I found the api section about it? thanks
please let there be an api where you can send search and page parameters???? pretty please!
What if I have some privacy documents I don't want to be publicly available?

Is there a way to disable indexing/caching of such documents by Google SE ?
I like it, it works fine. But i hav a question: is there a way to have just the viewer with no control buttons at the top ( page, zoom, fullpage, etc ), is there a code for that?
Thanks
Gustavo
not working in ie6
today i gave the german looky-look.net - flapdf a try.
this seems to be pretty fast and flexible and for free.
i worry, it is not opensource, but though i use their swf now, which is cooler than my previous pdf viewer..
here's their demo for any pdf URL of your choice and a german tutorial on how to implement it easily (one line ^^ in source code) can be found at where it says [flapdf][2].

i tried with bigger pdfs and it still seems to run fast although the free-version comes without caching.
Not working in IE8. The embedded pdf doesnt open in IE8. Try opening this same page in IE8. What could be the bug?
Thanks for posting this. Exactly what I was looking for!
Seems there's an annoying bug that prevents from viewing PDFs with spaces (%20) in the filename.
To load a specific page in the document, all you need to do is add a hash to the end of the embedded URL.

Page IDs are numbered sequentially like this: :0.page.0, :0.page.2, :0.page.3...

So to load page 15 of the document shown above, just use this:

http://docs.google.com/gview?url=http://infolab.stanford.edu/pub/papers/google.pdf&embedded=true#:0.page.14
Once the file is embedded there doesn't seem to be any way to change it. Google must cache the file. If I upload an updated PDF the viewer continues to show the old file. Anyone find a way to fix this or to force Google to reindex?
Having issues with the embedded viewer in Internet Explorer IE8 & IE7. What could be the issue!?

I get an red X that makes it unable to display image - Anyone know what could be causing this?! I thought it was the PDf generation, so I updated the pdf to Google Docs and then redownloaded it and am still having the issue.

Thoughts?
Great feature but I get a security warning if I try to embed the viewer into a secure web page (https://). I think the culprit is a non-secure reference to http://csi.gstatic.com/csi in the gview_local_gview_base_mod.js javascript file. Any plans to fix this or any workarounds?