【发布时间】:2016-05-10 20:04:56
【问题描述】:
我想知道如何从 angularjs 导出 pdf 文件。我已经导出了 excel 文件,它工作正常。
以下是excel的代码
view.html
<button ng-click="vm.exportData()" class="btn btn-info"><i class="glyphicon glyphicon-download"></i> Download as pdf</button>
controller.js
$scope.exportData = function () {
debugger;
var blob = new Blob([document.getElementById('export').innerHTML], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"
});
window.saveAs(blob, "Report.xls");
},
怎么做
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"
提前致谢:)
【问题讨论】:
-
你试过
'type': 'application/pdf' -
正如@CodingNinja 所说,'type': 'application/pdf' 应该可以工作
-
是的...我试过了,文件被下载,但是当我尝试打开它时出现错误“无法加载 pdf 内容”..