我正在使用cordova-pdf-generator
插件生成pdf
文件,但无法使用相对路径绑定图像。
我已经尝试过使用file://
协议和ng-scr
来代替src
,但是它没有成功。为了使它更简单,我把模板和图像放在了同一个文件夹中。
src\assets\template.html
src\assets\logo.png
HTML
标记如下所示:
<img ng-src="logo.png" alt="logo" height="40px" />
图像在生成的pdf中会出现破损。我猜这是因为生成的pdf的位置与模板的原始位置不同,但我就是不能找出正确的路径。
1条答案
按热度按时间svmlkihl1#
如果您尝试访问设备上的映像,则可能需要安装
cordova-plugin-file
安装插件后,您可以通过
cdvfile
协议访问。https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/#cdvfile-protocolhttps://github.com/cesarvr/pdf-generator/issues/38中的示例