尝试保存PDF文件时,会出现以下堆栈跟踪,并且不会下载该文件:
TypeError: Object expected
at API.save (http://localhost:8080/applications/lib/jspdf/jspdf.debug.js:3648:11)
at Anonymous function (http://localhost:8080/applications/js/<my_custom_js_file>.js:288:12)
at Anonymous function (http://localhost:8080/applications/lib/angular-1.5.8/angular.min.js:158:482)
at e (http://localhost:8080/applications/lib/angular-1.5.8/angular.min.js:45:442)
at Anonymous function (http://localhost:8080/applications/lib/angular-1.5.8/angular.min.js:48:300)
还尝试了一个简单的示例,并得到了相同的结果:
var doc = new jsPDF();
doc.text("hello", 20, 20);
doc.save("table.pdf");
答案 0 :(得分:0)
IE不支持本机Promise。因此,初始化脚本在版本1.5.3的第12016行处失败:
SCRIPT5009: 'Promise' is undefined
jspdf.debug.js (12016,5)
此后,该脚本将不再初始化所需的上下文。
修复程序应该是第三方承诺库-在添加jspdf.debug.js之前,我已经通过包含以下资源解决了该问题:
<script type="text/javascript" src="/applications/lib/ie-promise/es6-promise.js"></script>
<script type="text/javascript" src="/applications/lib/ie-promise/es6-promise@4/dist/es6-promise.auto.js"></script>