admin管理员组文章数量:1302270
There is a team drive full of PDFs.
I have set up oauth2 and can successfully login users. They can then enter in a file Id and my site will return all of the metadata for that file.
However I cannot seem to embed this PDF file. In the metadata there are two urls:
- webContentLink
- webViewLink
I tried creating an iFrame with both links but neither work.
Is this even possible to do?
I am using JS to do all of this and I am requesting the .metadata.readonly scope.
There is a team drive full of PDFs.
I have set up oauth2 and can successfully login users. They can then enter in a file Id and my site will return all of the metadata for that file.
However I cannot seem to embed this PDF file. In the metadata there are two urls:
- webContentLink
- webViewLink
I tried creating an iFrame with both links but neither work.
Is this even possible to do?
I am using JS to do all of this and I am requesting the https://www.googleapis./auth/drive.metadata.readonly scope.
Share asked Jan 8, 2018 at 13:02 RyanRyan 5419 silver badges28 bronze badges2 Answers
Reset to default 7webContentLink and the embeddable link have minor differences.
webContentLink:
https://drive.google./file/d/PDF_DRIVE_ID/view?usp=drivesdk
Embed URL:
https://drive.google./file/d/PDF_DRIVE_ID/preview
Right now, I haven't seen a direct API method to fetch the embedabble link but if you plan to do this by code, you can just manipulate the webContentLink so that it removes the view?usp=drivesdk
part and replace it with preview
.
Sample snippet:
<iframe src="https://drive.google./file/d/PDF_DRIVE_ID/preview" width="640" height="480"></iframe>
You can do this with an object
tag like so:
<object data="https://drive.google./file/d/[id]/preview" type="application/pdf" width="100%" height="500px"></object>
Here's a nice place you can try that.
https://www.w3docs./tools/code-editor/1085
本文标签: javascriptEmbed PDF File Hosted on Google Drive on WebsiteStack Overflow
版权声明:本文标题:javascript - Embed PDF File Hosted on Google Drive on Website - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741704062a2393457.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论