An unofficial blog that watches Google's attempts to move your operating system online since 2005. Not affiliated with Google.

Send your tips to gostips@gmail.com.

September 9, 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.

141 comments:

  1. Where is the search feature?! :)

    ReplyDelete
  2. A bit weird that this viewer is not working with Chrome !!!

    ReplyDelete
  3. 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...

    ReplyDelete
  4. 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

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

    ReplyDelete
  6. Great tip, thanks.

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

    ReplyDelete
  7. 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

    ReplyDelete
  8. 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.

    ReplyDelete
  9. 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.

    ReplyDelete
  10. @Kevin:

    Yes, I noticed that, but the flag only works for the Chrome OS.

    ReplyDelete
  11. Bright feature.. it will help a lot for easy presentation ...Google is a dad of all with daily upgrades..!

    ReplyDelete
  12. this is good but it is not fully success it need to some optimization

    ReplyDelete
  13. 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?

    ReplyDelete
  14. Will this work documents that are only available in corporate intranets?

    ReplyDelete
  15. Why the URL to the PDF file is not URL encoded ?

    ReplyDelete
  16. 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).

    ReplyDelete
  17. @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.

    ReplyDelete
  18. 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.

    ReplyDelete
  19. i've had this feature for ages now i thought it was for everyone interesting

    ReplyDelete
  20. @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.

    ReplyDelete
  21. 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

    ReplyDelete
  22. 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?

    ReplyDelete
  23. @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.

    ReplyDelete
  24. 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

    ReplyDelete
  25. You have to be logged in to Google. Annoying?

    ReplyDelete
  26. No, you don't have to be logged in to Google. It wouldn't make any sense and the embedded viewer would be useless.

    ReplyDelete
  27. I want a pony too! Jesus, it's free people. If you want it to have different features go build your own.

    ReplyDelete
  28. Anon who likes a pony: Ok, it`s free, we just post some suggestions, may we?
    Alex Chitu: Thanks for your orientation. Good work :)

    ReplyDelete
  29. 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.

    ReplyDelete
  30. How to set this so that we don't need to specify the width and height, instead, use all the screen available.

    ReplyDelete
  31. Is it possible to refer it to a particular page? Do you can link to different parts within a PDF?

    ReplyDelete
  32. Issuu.com does the job and gives you a beautiful reading experience. And it is free... Ü

    ReplyDelete
  33. 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.

    ReplyDelete
  34. 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?

    ReplyDelete
  35. It would be great if there was a print icon/text on the toolbar instead of having to open it in a new window.

    ReplyDelete
  36. 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...

    ReplyDelete
  37. 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."

    ReplyDelete
  38. i think i'll stick with adobe for the moment, tho this feature could prove useful in developing web applications

    ReplyDelete
  39. 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?

    ReplyDelete
  40. 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

    ReplyDelete
  41. how to modify zoom, page number, view thumb on the left, etc.? Where I found the api section about it? thanks

    ReplyDelete
  42. please let there be an api where you can send search and page parameters???? pretty please!

    ReplyDelete
  43. 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 ?

    ReplyDelete
  44. 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

    ReplyDelete
  45. not working in ie6

    ReplyDelete
  46. 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.

    ReplyDelete
  47. Not working in IE8. The embedded pdf doesnt open in IE8. Try opening this same page in IE8. What could be the bug?

    ReplyDelete
  48. Thanks for posting this. Exactly what I was looking for!

    ReplyDelete
  49. Seems there's an annoying bug that prevents from viewing PDFs with spaces (%20) in the filename.

    ReplyDelete
  50. 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

    ReplyDelete
    Replies
    1. Works for me. Wonder why this important thing isn't documented...? :\

      Delete
    2. Does not work on iPad.

      Delete
  51. 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?

    ReplyDelete
  52. 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?

    ReplyDelete
  53. 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?

    ReplyDelete
  54. Works on firefox and IE8.It also Opens MS Word documents (DOC files).Got to try more file types.
    Its better avoiding file names with spaces.

    I am searching for javascript alternatives.There are document viewers like vuzit that displays dozens of formats.But it isnt so easy to use as google docs.
    Anyway, long live google.

    ReplyDelete
  55. Any chances to Google make it available for download?

    I want to use it from my own intranet.

    ReplyDelete
  56. hi
    this is Neha
    this viewer is really awesome but it didn't met my requirement completely.. I also need an image , xls , odt viewer too......can anyone help....

    ReplyDelete
  57. It would be nice if you have full control to enable the user to not be able to download the file or print the file. Just view the file.

    Thanks
    Adam

    ReplyDelete
  58. Has anyone tried http://embedit.in? They claim you can embed any file into your website. I've used it for basic stuff and it seems to work pretty well.

    ReplyDelete
  59. At http://www.google.com/google-d-s/tour1.html it says you can view "DOC, XLS, ODT, ODS, RTF, CSV, PPT, etc"...hmmm wht all does etc include?
    Has any1 tried scribd.com?

    ReplyDelete
  60. really cool tutorial-I have read another good tutorial , that useses free googlesites to upload pdf and google docs viewer to embed the pdf document here is the address http://hqsoftwaretips.blogspot.com/2010/02/how-to-embed-pdf-file-in-any-webpage.html

    ReplyDelete
  61. What if I have secure pdf and and not available online?

    ReplyDelete
  62. @anonymous

    FlexPaper is a good open source alternative if you want to be able to host your own documents and keep them secure

    http://flexpaper.devaldi.com

    ReplyDelete
  63. There is another posibility to view PDFs online or implement into a website. With https://acrobat.com its own tools.

    Its very nice, black styled and the text renders much nicer than in google docs viewer.

    ReplyDelete
  64. hi
    if i wish disable the download button in new window ???
    How can i do ???

    Thanks

    ReplyDelete
  65. is there some method to disable the buttons into the sidebar ???

    ReplyDelete
  66. I agree with lots of posts above that there are issues with IE8 - I get slow or no or partial loading of files, any idea why this is?

    ReplyDelete
  67. For the ie8 issue, http://docs.google.com must be added to trusted sites.

    ReplyDelete
  68. Please have a look at embeddable viewer... it requires users to login now...

    ReplyDelete
  69. As reported on this support page:

    http://www.google.com/support/forum/p/Google+Docs/thread?tid=22d92671afd5b9b7&hl=en

    by user rbnunes, to make the viewer work with IE, Google should add a Compact Privacy Policy to the viewer (http://compactprivacypolicy.org). If confirmed, we should press Google to do so very soon.

    ReplyDelete
  70. Is there a way to remove the ability to print or download the pdf files?

    ReplyDelete
  71. Hey... If i'm not logged in to google, the document doesn't show. A login page shows instead.
    Is this the expected behavior?

    ReplyDelete
  72. Glitching for me too, requires log in to google. Needs sorting ASAP!

    ReplyDelete
  73. Hi
    I have used this functionality and its works fine. But what if, my pdf file is modified the content but the name is same as previous one.

    In this case doc shows the old content...

    So, how to reload the new one???

    Thanks

    ReplyDelete
    Replies
    1. I have the same problem. Is there a solution?

      Delete
    2. You can force google to load documents without caching by referencing the filename with a random number, like so:

      http://link.to/file.pdf?1234

      Change "1234" to another number (such as the date) to force the refresh. If you generate the link via PHP, as I do, I add a "%3F".time() to the file name to make it always load the most current version.

      Delete
  74. I can't proceed to open pdf file when open my web.
    there is error shown "Sorry we unable to retrieve the document for viewing".

    That message came out when I open the file.But, if i open the file directly the file can be opened. Is there any suggestion or solution that anyone can give for my problem?

    ReplyDelete
  75. Can you post a link to the PDF file?

    ReplyDelete
  76. no muestra nada solo envia un mensaje SORRY WE ARE UNABLE TO RETRIEVE THE DOCUMENT FORVIEWING

    ReplyDelete
  77. is this applicable to a word document or excel spreasheet?

    ReplyDelete
  78. Word document - yes
    Excel spreadsheet - no

    ReplyDelete
  79. my ppt file displays only when I use http://docs.google.com/gview, the new path shows google login page.. is there a file size limit? because I have two files uploaded to : 50ko and 9Mg, and only the small one shows! also background image doesn't show in my small file, should I upload to google docs and convert to google format to show the background?! thanks

    ReplyDelete
  80. anybody? requires login??? Will it work without login?

    ReplyDelete
  81. Shocking. It requires a google account/login. In this thread it is said, that this would make no sense. What is true?

    ReplyDelete
  82. The viewer should work well and it shouldn't require to log in if you use any other browser except Internet Explorer. Apparently, there are some issues that need to be fixed in order to make it work properly in Internet Explorer.

    ReplyDelete
  83. Tried it with SAFARI 5.0.2 in MAC Os X Leopard

    ReplyDelete
  84. I've just tried in Safari 5.0.2 / Mac OS X 10.6.2 and it works well. Try setting "accept cookies" to "always".

    ReplyDelete
  85. Ok. I can´t get in started in Safari on Mac (maybe tomorrow?), but in every other Browser. Thanks for you efforts!

    ReplyDelete
  86. Hmm, previous comment gone. Anyway, I'm having trouble with intergrating google docs viewer on my website. I just can't make it work with files that are served by a php script to the viewer, always get the infamous "Sorry, we are unable to generate a view of the document at this time." Full description and test case available here: http://stackoverflow.com/questions/3995613/how-to-use-google-docs-viewer-for-embedding-ppt-files-on-a-webpage-if-the-file-i
    I would appreciate any help on this.

    ReplyDelete
  87. I wish there was something more stand alone rather than depending on a provider. Yes, I know about pdf2swf but the result is some files end up being larger than the PDF itself, or other problems.

    ReplyDelete
  88. Hmmm. It appears I was using a "gview" link instead of a "viewer" link. I am going to try to switch how I am accessing this feature to see if that fixes my problem.

    ReplyDelete
  89. my ppt file displays only when I use http://docs.google.com/gview, the new path shows google login page.. is there a file size limit? because I have two files uploaded to : 50ko and 9Mg, and only the small one shows! also background image doesn't show in my small file...

    Yes thank you

    ReplyDelete
  90. Hi
    I am getting error while opening PDFs on edocs
    "Sorry, we are unable to retrieve the document for viewing." I observed the PDF files not opening are of large file size like 7-8 MB. Is there any size limit for the edocs? or how can I show some Large files like more than 15MB?

    ReplyDelete
  91. I am getting error while opening PDFs on edocs
    "Sorry, we are unable to retrieve the document for viewing." I observed the PDF files not opening are of large file size like 7-8 MB. Is there any size limit for the edocs? or how can I show some Large files like more than 15MB?
    thanks.

    ReplyDelete
  92. I know about pdf2swf but the result is some files end up being larger than the PDF itself

    ReplyDelete
  93. I wish there was something more stand alone rather than depending on a provider. Yes, I know about pdf2swf but the result is some files end up being larger than the PDF itself, or other problems.

    ReplyDelete
  94. I want to remove the option "Open in new window". How can I do that Please let me know.

    ReplyDelete
  95. Google post login screen automatically requiring users to log in to the site. For analytics and security, this is excellent. Google recognizes your IP and only displays the log in to the unknown user.

    ReplyDelete
  96. Sorry, we are unable to retrieve the document for viewing or you don't have permission to view the document.
    Please try again later.

    I get this message every time I try to use the link above (https://docs.google.com/viewer). It generates the code, and I click 'view now' to test it, and the message appears. I have tried ignoring it and embedding it but it won't work. I have tried it with various formats from all over the web including Google Docs (my own account) that are open to the public. Strangely, when I copy and paste the code at the top of this page, it works. I'm tearing my hair out. Any ideas?

    ReplyDelete
  97. I have the same issue as RT

    ReplyDelete
  98. Just a note about how the docs are cached, once you update (overwrite) your PDF, the old (cached) version will still be displayed. I found a work around that seems to work though.

    In PHP, add a to the end of the document name. This will ensure the newest version is always seen. (you can manually add something like ?0001 to the end as well and simply change it each time you upload the doc.)

    End result is something like http://example.com/my_document.pdf?0001

    and when updated use something like
    http://example.com/my_document.pdf?0002

    Or simply randomize with php to get something like
    http://example.com/my_document.pdf?a120152c5f82b94e032b66bf2a687827

    You will still see the same document, but the filename will be different and Google will re-download the new document.

    Hope this helps!

    Cheers,
    Josh

    ReplyDelete
  99. Is there any way of removing the open in new window button in the viewer?

    ReplyDelete
  100. I'm also unable to see it embed on chrome. However it does work on firefox 5.

    ReplyDelete
  101. mine work fine in chrome and about the login issue did not get them at all
    and this google document viewer can be make to view all source of text file too

    ReplyDelete
  102. hmmm...it's good, we just add PDF Url there...
    so simple...
    thanks google^^ ♥

    ReplyDelete
  103. there is a typo3 extension available for this feature:
    http://typo3.org/extensions/repository/view/na15_docviewer/current/

    ReplyDelete
  104. Can anyone tell me how we can embed a .swf file or a HTML file in a google website. Actually i wish to put in an interactive quiz into a google website and google docs doesn't provide options to put in an interactive quiz... please help.

    ReplyDelete
  105. To embed a .swf file you have to generate html code for particular swf file (generated during publishing the swf file). And then simply place that code anywhere you want to display that animation (swf file).

    ReplyDelete
  106. Hi ! I needed to Hide the 'Open in New Window' button from the google viewer while i open my page using Iframe.

    Below is my src for IFrame

    src="http://docs.google.com/viewer?url=http://c272658.r58.cf1.rackcdn.com/115bb079-205f-4228-a7ab-6b97a285132b.pdf&embedded=true"

    Basically my ideas is, i dnt allow user to download the document embed in the IFrame

    Please help me !!

    ReplyDelete
    Replies
    1. Funny, I just tried to do that yesterday...
      But there's a security issue applying a CSS style to a distant iframe.
      Even with jQuery I couldn't do that...
      I guess the only way is to use the API to build his own toolbar, and not used the basic provided one.

      Delete
    2. plz tell me how do you get a .pdf url of your uploaded document mine uploaded document has url like this
      https://docs.google.com/open?id=0ByuC007zN40AZTE4MWI1NTQtYTM1YS00NmE3LTk3NDItNmVkYTM1ZDRlMGE0

      Delete
  107. Hi

    I want to disble download option ?

    How can i do this

    ReplyDelete
  108. when i upload the document in the google doc it has not .pdf link the link appear like this
    https://docs.google.com/open?id=0ByuC007zN40AZTE4MWI1NTQtYTM1YS00NmE3LTk3NDItNmVkYTM1ZDRlMGE0

    and when i embed this url through ifrmae it has weird google toolbar on the top see my embedded docs here
    http://www.booknstuff.com/competitive-exams/gat-competitive-exams/gat-general-sample-papers

    plz help me how to get rid of this google toolbar in the top of my doc and how to find a .pdf link of my uploaded doc

    ReplyDelete
    Replies
    1. Try using URLs like this:

      https://docs.google.com/viewer?a=v&pid=explorer&chrome=false&srcid=0ByuC007zN40AZTE4MWI1NTQtYTM1YS00NmE3LTk3NDItNmVkYTM1ZDRlMGE0&hl=en_US&embedded=true

      Delete
    2. where should i use the above url?

      the iframe code i am using already contain the above type url

      iframe style="width: 100%; height: 600px;" src="https://docs.google.com/open?id=0ByuC007zN40AZTE4MWI1NTQtYTM1YS00NmE3LTk3NDItNmVkYTM1ZDRlMGE0&embedded=true" frameborder="0" width="320" height="240">iframe

      Delete
  109. I have to click on compatibility mode to get this to display using IE 9. I cannot keep asking people that veiw my page to click compatibility control.

    ReplyDelete
  110. How do I embed a publicly shared folder on my wordpress blog?

    ReplyDelete
  111. How do I embed a shared folder to be viewed inside an iframe?

    ReplyDelete
  112. I get it work with IE 7,8 and 9 by encoding pdf URL like this http://docs.google.com/viewer?url=http%3A%2F%2Fresearch.google.com%2Farchive%2Fbigtable-osdi06.pdf

    ReplyDelete
  113. is there any way to hide control bar while viewing the document

    ReplyDelete
  114. Is it possible to remove "Open in new window" button when document is loaded?

    Thanks

    ReplyDelete
    Replies
    1. did u got the solution for remove new window button..i am also trying for same problem but i didn't get the solution..if u know let me know plz...

      Delete
  115. Francisco CorreiaApril 11, 2012 at 2:36 AM

    Do you know of any service like this to use only on Intranet?

    ReplyDelete
  116. very very thanks to you , this works for me.. I have 50mb pdf file which scribd or google doc not support , but this works.

    ReplyDelete
  117. How to disable "Open in new window" option?

    ReplyDelete
  118. You can use "Docs Online Viewer" browser extension to view all documents in web pages with Google Docs or related services.

    Firefox:
    http://mac.softpedia.com/get/Internet-Utilities/Firefox-Extensions/Docs-Online-Viewer.shtml

    Chrome / Greasemonkey:
    http://userscripts.org/scripts/show/127774

    ReplyDelete
  119. how can i read specific page it tried to put #page=1 but doesnot work

    ReplyDelete
  120. Great Stuff saved my lost of time..!!

    ReplyDelete
  121. it is not working ! when i tried, it shows like some house, forest etc. See the url = http://docs.google.com/viewer?url=https%3A%2F%2Fdocs.google.com%2Fopen%3Fid%3D1VoF8vlzosY9hOw_i1xYnNOU29Jepa6Ozm1rKgRvYwTDJEbEjvKLjh-FvSu98.

    now what i need to do for that.

    ReplyDelete
  122. not open for .docx file how can we open .docx files?

    ReplyDelete
  123. earlier it worked!!!!!!!!!!!!!!!!! But now its not working !!!!!!!!!!!!

    ReplyDelete