在IFRAME中嵌入Google文档PDF查看器 [英] Embed Google Docs PDF viewer in IFRAME

查看:176
本文介绍了在IFRAME中嵌入Google文档PDF查看器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将PDF上载到Google文档(使用Python的gdata库)时,我获得了指向该文档的链接:

When I upload PDF to Google Docs (using Python's gdata library), I get 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'

不幸的是,在IFRAME中使用该链接对我不起作用,因为PDF查看器正在重定向到其自身,从而脱离了IFRAME.

Unfortunately using that link in IFRAME is not working for me because PDF viewer is redirecting to itself, breaking out of IFRAME.

在寻找解决方案时,我发现了以下内容: http ://googlesystem.blogspot.com/2009/09/embeddable-google-document-viewer.html -看起来非常不错,但是我找不到将其用于上载到Google文档的文档的方法.有人知道该怎么做/如果可能的话?

Looking for the solution, I've found this: http://googlesystem.blogspot.com/2009/09/embeddable-google-document-viewer.html - which looks very nice, but I can't find a way to use it with document uploaded to Google Docs. Does somebody know how to do it/if it's at all possible?

推荐答案

仅作记录-我还没有找到任何强制内部" google google pdf查看器不退出iframe的方法.正如我在问题中提到的,我找到了一个不错的独立查看器: http://googlesystem.blogspot.com/2009/09/embeddable-google-document-viewer.html ,可以像这样使用:

Just for the record - I haven't found any way to force "internal" google google pdf viewer to not go out of 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, that can be used like this:

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

-但是要使用它,您必须将PDF发布到外界.这不会是一个糟糕的解决方案,因为发布的文档具有唯一的ID,可能比Google docs帐户的密码更难猜测.不幸的是,即使使用最热门的Google Docs API版本3 API,似乎也无法以编程方式发布PDF.

-- but in order to use it you have to publish your PDF to the outside world. This wouldn't be a bad solution, because published document has unique id that is probably harder to guess than a password to google docs account. Unfortunately, even with hottest Google Docs API version 3 API, there seems to be no way of publishing PDF programatically..

最后,我混合使用了以下内容:Google的独立PDF查看器和其他一些允许以编程方式上传和发布PDF的网络服务.有点半生半熟的解决方案,但到目前为止效果很好.

In the end, I went for a mix of: standalone PDF viewer from google and some other web service that allows to programatically upload and publish PDF. A bit half-baked solution, but it works well so far.

这篇关于在IFRAME中嵌入Google文档PDF查看器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆