Paste the Google Docs Viewer IFRAME

When I load a PDF into Google Docs (using the Python gdata library), I get a link to the document:

>>> e.GetAlternateLink().href Out[14]: 'http://docs.google.com/a/my.dom.ain/fileview id=<veery-long-doc-id>&hl=en' 

Unfortunately, using this link in IFRAME does not work for me, because the PDF viewer redirects to itself, breaking out of IFRAME.

Looking for a solution, I found this: http://googlesystem.blogspot.com/2009/09/embeddable-google-document-viewer.html - it looks very nice, but I can’t find a way to use it with a document loaded in Documents Google Does anyone know how to do this / if at all possible?

+4
source share
5 answers

Just for the record - I did not find a way to force the "internal" google google pdf viewer not to exit the iframe. And, as I mentioned in the question, I found this nice standalone viewer: http://googlesystem.blogspot.com/2009/09/embeddable-google-document-viewer.html , which can be used as follows:

  <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 to use it you must publish your PDF file in the outside world. This would not be a bad decision, because the published document has a unique identifier, which is probably harder to guess than the password for the google docs account. Unfortunately, even with the most popular API Docs API version 3, there seems to be no way to publish PDF programmatically.

In the end, I went for a combination: a standalone PDF viewer from Google and some other web services, which allows you to programmatically download and publish PDF. A bit baked solution, but it still works well.

+7
source

To embed the pdf files present in your Google documents on your site, use the code below:

 <iframe src="http://docs.google.com/gview?a=v&pid=explorer&chrome=false&api=true&embedded=true&srcid=<id of your pdf>&hl=en&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe> 
+3
source

Embedding Google Docs in an iframe through a viewer is problematic in IE8 if it hasn't been cached yet and it just doesn't match the much better Scribd tool, which allows you to simply make a simple html page with a document embedded through their supplied object code for the document. Then I use it as the source file for my iframe. It shows the print (as well as the full-screen button) right on the page of the embedded frame. Much more friendly and reliable for visitors to the page.

+1
source

Try it!

Same as the other answers above ...

 <iframe src="https://docs.google.com/gview?url={magical url that works}"></iframe> 

besides magical url that works there is https://drive.google.com/uc?id=<docId>&embedded=true .


Google Drive / Docs provides a bunch of different URLs:

  • https://drive.google.com/open?id=<docId> Share the link.
  • https://docs.google.com/document/<docId>/edit Open in Google Drive.
  • https://docs.google.com/document/d/<docId>/view Same as edit above. I think.
  • https://docs.google.com/document/d/<docId>/pub?embedded=true To attach to iframe if you File -> Publish to the web...
  • https://drive.google.com/uc?export=download&id=<docId> Direct download link.

I came across this solution after a bunch of trial and error with different links. Hope this helps!

0
source

The following worked for me:

 <iframe src="https://drive.google.com/viewerng/viewer?url=url_of_pdf?pid=explorer&efh=false&a=v&chrome=false&embedded=true" embedded=true></iframe> 
0
source

Source: https://habr.com/ru/post/1301313/


All Articles