gpt4 book ai didi

javascript - 如何将 PDF 作为二进制传递给 window.open()?

转载 作者:行者123 更新时间:2023-11-28 07:26:59 25 4
gpt4 key购买 nike

我正在使用 Cordova/ionic 构建一个应用程序,现在我从 API(我已通过该 API 进行身份验证)获取 PDF。然后我想在 inAppBrowser 中显示此 PDF,我通常使用 window.open('http://example.com/the-file.pdf', "_blank", "location=no");< 打开。但由于我已经获取了数据,所以我无法提供 url,但我想以二进制形式提供数据。

我四处搜寻,但只找到 this SO answer ,不幸的是这对我不起作用。

有人知道如何通过 window.open() 将 PDF 作为二进制数据传递吗?欢迎所有提示!

最佳答案

在这里查看答案:https://stackoverflow.com/a/43297424/1426222 :

window.open("data:application/pdf;base64,JVBERi0xLjcKCjEgMCBvYmogICUgZW50cnkgcG9pbnQKPDwKICAvVHlwZSAvQ2F0YWxvZwogIC9QYWdlcyAyIDAgUgo+PgplbmRvYmoKCjIgMCBvYmoKPDwKICAvVHlwZSAvUGFnZXMKICAvTWVkaWFCb3ggWyAwIDAgMjAwIDIwMCBdCiAgL0NvdW50IDEKICAvS2lkcyBbIDMgMCBSIF0KPj4KZW5kb2JqCgozIDAgb2JqCjw8CiAgL1R5cGUgL1BhZ2UKICAvUGFyZW50IDIgMCBSCiAgL1Jlc291cmNlcyA8PAogICAgL0ZvbnQgPDwKICAgICAgL0YxIDQgMCBSIAogICAgPj4KICA+PgogIC9Db250ZW50cyA1IDAgUgo+PgplbmRvYmoKCjQgMCBvYmoKPDwKICAvVHlwZSAvRm9udAogIC9TdWJ0eXBlIC9UeXBlMQogIC9CYXNlRm9udCAvVGltZXMtUm9tYW4KPj4KZW5kb2JqCgo1IDAgb2JqICAlIHBhZ2UgY29udGVudAo8PAogIC9MZW5ndGggNDQKPj4Kc3RyZWFtCkJUCjcwIDUwIFRECi9GMSAxMiBUZgooSGVsbG8sIHdvcmxkISkgVGoKRVQKZW5kc3RyZWFtCmVuZG9iagoKeHJlZgowIDYKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDEwIDAwMDAwIG4gCjAwMDAwMDAwNzkgMDAwMDAgbiAKMDAwMDAwMDE3MyAwMDAwMCBuIAowMDAwMDAwMzAxIDAwMDAwIG4gCjAwMDAwMDAzODAgMDAwMDAgbiAKdHJhaWxlcgo8PAogIC9TaXplIDYKICAvUm9vdCAxIDAgUgo+PgpzdGFydHhyZWYKNDkyCiUlRU9G", "mypdf", "width=700px,height=600px");

关于javascript - 如何将 PDF 作为二进制传递给 window.open()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29539438/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com