How to display data URI for PDF in Chrome App?

ⅰ亾dé卋堺 提交于 2019-12-04 17:51:36

chrome.app.window.create will only load a resource from the packaged app, so you can't escape the chrome-extension://gapkhdea.../ address space there.

window.open when called from a packaged app window will use the default system handler to open the URL. I don't know of any common system configurations which have a default handler registered for the data scheme, which is probably why nothing happens.

What you want, if your goal is to display arbitrary untrusted content within a packaged app, is the webview tag. You can embed a Webview element directly into an app window's contents. You can use a data URI for its src attribute, which can be assigned dynamically.

Depending on your Chrome version, you may encounter permissions issues when the Webview attempts to load the PDF viewer plugin, but I just tested this with some PDF data and got beautifully displayed PDF rendering inside of a packaged app.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!