使用Google Drive Viewer显示通过Google Drive API创建的文件

Displaying a file created through Google Drive API with the Google Drive Viewer

本文关键字:Google Drive 创建 文件 API Viewer 显示 使用      更新时间:2023-09-26

我能够通过谷歌驱动api创建一个文档。

我得到一些网址:

  • alternateLink:

https://docs.google.com/document/d/xxxsome_idxxxxx/edit?usp=drivesdk

  • embedLink

https://docs.google.com/document/d/xxxsome_idxxxxx/preview

感谢谷歌文档查看器,我想显示创建的文档,就像这里一样:http://architects.dzone.com/articles/embedding-google-docs-and

问题是,我无法使用以上URL在查看器中打开文档。

我还尝试直接从谷歌驱动器发布文档(菜单文件>发布到网络…)。url类似于:

  • https://docs.google.com/document/d/xxx_some_id_xxx/pub

同样,该文件无法在查看器中渲染。

有人知道如何做到这一点吗,即让查看器以pdf模式显示从api在驱动器中创建的文档?

谢谢!

您可以将文档转换为pdf,然后将pdf url传递给谷歌文档查看器。事实上,你不必为此付出任何艰苦的工作。有了文件对象谷歌提供的嵌入链接,其中一个将是pdf。只需将此pdf链接传递给谷歌查看器即可。