nativescript - Unable to open dataurl using utils.openUrl()
问题描述
For Nativescript, I created a pdf using pdfmake
on the client side. Now using its dataUrl
, I want to display it in a browser. But while trying to open it using utils.openUrl(dataUrl)
, it gives error Error in OpenURL
pdfMake.createPdf(docDefinition)
.getDataUrl((dataUrl) => {
utils.openUrl(dataUrl);
});
But if I paste dataUrl directly into browser address, it opens.
解决方案
getDataUrl(callback)
returns a base64 data link which can not be handled by utils.openUrl(...)
. Moreover Android doesn't have the capability to open PDF in Browser.
The alternative is to write the PDF to a file and use nativescript-share-file for preview. This plugin gives user a list of options user could choose from to view / share the given file.
推荐阅读
- python - 将整个数据框行中的值与另一个数据框进行比较
- c# - 如何从 Google Cloud Storage 下载文件
- objective-c - 我正在使用标准 Cocoa API 从 NSView 创建 PDF。PDF 在预览中可以正常打开,但无法在 Adobe 应用程序中打开。有什么建议吗?
- jquery - 使用 jQuery 和自定义属性将值传递给来自锚点的隐藏表单输入
- python - 无法在 macOS Big Sur 上安装 Matplotlib
- docker-compose - 使用 docker-compose 上的 Dockerfile 使用 chown 拒绝用户权限
- google-sheets - 合并数据后如何获得 QUERY to CONCATENATE 文本?
- reactjs - 确保路径由变量定义的嵌套字段在添加到依赖数组时触发 React.useMemo 更新
- php - 如何防止 Wordpress 在标签中取消注释 php?
- python - 如何切割更大的矩阵并匹配更小的矩阵的形状