javascript - 使用 pdfMake 下载多个文件

标签 javascript angularjs pdfmake

对不起,我在我的 Angular 中使用 pdfMake 插件。 https://github.com/bpampuch/pdfmake 我想下载多个文件(不同的文档定义)。我有一系列文档。当我循环数组并调用函数下载时,我得到的文件数量取决于数组的长度,这是正确的,但文档都是相同的(数组的最后一个文档是每个文件的内容)。

但是,当我登录控制台时,在该数组中,文档是不同的。此问题的任何解决方案。 我确实需要你的帮助。每个答案将不胜感激。

最佳答案

在尝试找到许多解决方案后,我想出了 setInterval。所以我设置了每次下载的时间间隔。这对我来说很有效。

var index = 0;
var interval = setInterval(function()
    {
        if (index < docArray.length){ // docArray here is array of docs contents
            pdfMake.createPdf(docArray[index]).download('Export.pdf');
            index++;
        }
        else {
            clearInterval(interval);
        }
    },
    200);

谢谢你http://eysermans.com/post/sequentially-download-multiple-files-with-jquery这使我能够继续我的任务。

关于javascript - 使用 pdfMake 下载多个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41220342/

相关文章:

javascript - 多个文件上传 - Blueimp jQuery uploader

javascript - 使用 ng-repeat 后专注于特定行

angularjs - 模板内的嵌套指令放置在顶部

javascript - AngularJS 压缩 $http 发布数据

javascript - 使用 pdfmake.js 在列中自动宽度图像

javascript - ng 以 Angular 存储列表

javascript - 从中心开始用颜色部分填充 FLOT 饼图切片

javascript - 滚动一次触发播放功能

pdfmake - 我想在使用 javascript 从 html 创建 pdf 后下载并上传它

javascript - AngularJS 将 SVG 导出为 PDF