Get the ability to download numerous files simultaneously with pdfMake

Hello there, I am currently working with the pdfMake plugin in my Angular project. You can find the plugin here: https://github.com/bpampuch/pdfmake. I am facing a problem where I need to download multiple files with different document definitions. I have an array of Docs and when I loop through the array and call the download function, the files I get are all the same (reflecting the content of the last document in the array).

Strangely, when I log the array in the console, the documents appear to be different. I would greatly appreciate any solutions you might have for this issue. Your help is invaluable to me. Thank you in advance.

Answer №1

After exhausting various options, I finally discovered the setInterval method. By setting a time interval for each download, I was able to successfully achieve my goal.

var counter = 0;
var timer = setInterval(function() {
    if (counter < documentArray.length) {
        pdfGenerator.createPdf(documentArray[counter]).download('Export.pdf');
        counter++;
    } else {
        clearInterval(timer);
    }
}, 200);

I am grateful for the valuable resource found at which greatly assisted me in completing my task.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is there a way to filter and tally the JSON objects that have latitude and longitude within a 10km radius from the

I'm currently working on filtering and counting objects from an API endpoint that fall within a 10km radius of the specified origin. My main challenge lies in correctly filtering the API results and tallying the number of matching items. While I succ ...

Transforming an image object into a File object using Javascript

My goal is to utilize HTML5 on the client side in order to convert an "image object" into a "File object" for uploading to azure blob storage. I am working with AngularJs and my approach involves: Converting the image to a file Uploading the file to blob ...

Is it possible to modify the inline onkeyup function?

Looking for a solution to change the onkeyup function in a textarea element from 255 characters to 150 characters without directly editing the code? <textarea cols="50" rows="4" id="textbox" onkeyup="limitArea(this, 255, '')"></textarea ...

JS - Activate the ghost element feature by using the preventDefault function

I am currently working on a project where I need to drag elements from a list of img tags to various svg:rect containers. The process involves using mousedown and mouseup events to track which img is being picked from the list and where it is dropped with ...

I'm curious about the distinction between React's one-way data binding and Angular's two-way data binding. Can someone please clarify the key differences

My understanding of these concepts is a bit hazy. If I were to develop the same ToDo application using AngularJS and ReactJS, what exactly distinguishes React ToDo's use of one-way data binding from AngularJS's two-way data binding? From what I ...

The Slack Bot is having trouble downloading files from direct messages, but it is successfully downloading them when uploaded to a channel

I have developed a program to retrieve files using a code snippet provided by a Slack bot. Below is the code: var https = require('https'); var fs = require('fs'); var downloadFile = function (url, dest){ var slug = url.split(&apos ...

Using Jquery to make an Ajax request to a PHP script that retrieves JSON data

Hello, I am new to working with JSON. I have a PHP script that contains a multidimensional array, which is then encoded into JSON format like this: <?php header('Content-Type: application/json'); $lista = array ( 'Conoscenti'=&g ...

In Safari, the scrollbar appears on top of any overlays, popups, and modals

On my webpage, I have a div with the CSS property overflow-y: scroll. The page also features several popup modals and overlays. Strangely, the scrollbar of the div appears on top of these overlays instead of behind them. I attempted to resolve this issue b ...

Response received from AngularJS http get request

I am making an HTTP GET request here $http({ method: 'GET', url: baseURL + '/couponManager/createCoupon?token=' + token + query1 + query2 + query3 + query4 + query5, }).then(function successCall ...

Combine similar JSON objects into arrays

I'm working with a dataset returned by a library, and it's structured like this: var givenData = [{"fName": "john"}, {"fName": "mike"}, {"country": "USA"}] My goal is to group the "fName" values together and add '[]' to achieve the fo ...

Ng-Grid error: Trying to access property 'on' of a null value

Currently, I am in the process of creating an angular.js directive that involves a JQuery dialog box containing a grid component. Directive Template: <div class="datasetsGrid" ng-grid="gridOptions"></div> The Issue Whenever I click on the " ...

Difficulty Communicating Recapcha 2 with the PHP Script

I am currently testing the installation of reCaptcha 2 with server-side verification using a form with one input field. My process involves sending the reCaptcha response via Ajax to a PHP page for verification. While I am able to capture the information p ...

Why isn't the show/hide feature in Jquery functioning properly?

I have a div that needs to be displayed after hovering over another element. These elements are not within the same div. The popup info should appear when an icon with the class .option_36_124 is hovered over. $(".option_36_124").hover(function(){ $(& ...

Receiving an `Invalid module name in augmentation` error is a common issue when using the DefaultTheme in Material

After following the guidelines outlined in the migration documentation (v4 to v5), I have implemented the changes in my theme: import { createTheme, Theme } from '@mui/material/styles' import { grey } from '@mui/material/colors' declar ...

Converting TypeScript to JavaScript: A Step-by-Step Guide

I have this code written in Typescript and I need to convert it to JavaScript const Home = (props) => { return ( <div> {props.name ? 'Hi ' + props.name : 'You are not logged in'} </div> ); }; How can I re ...

Troubleshooting issue with Bootstrap collapse functionality failing with dynamic IDs

Having trouble creating dynamic ids for bootstrap collapsing functionality. I want each topic in an ng-repeat to collapse and display its respective question list when clicked. The issue is that when I click on a second topic, the question list data from ...

Meteor chat platform now offers the option to create multiple chat rooms

I've been working on an application that features multiple chat rooms. Currently, one of the rooms is functional in terms of sending and receiving messages. However, when I navigate to a different room and try to send a message, the message doesn&apos ...

What is the functionality of the post method in PHP?

Is there a solution to this issue? //error_reporting(0); $token = $_POST['token']; $invite = $_POST['invite']; $url = "https://mywebsite.com/asd/".$invite.""; $dingaling = "$token" ?> When: ERROR: Notice: Undefined index: token ...

Ensure that you provide distinct values for both the model and view in your input

Is there a way to automatically format the numbers I type with a $ symbol in the input field, without actually storing the $ in the model? I've tried different methods but so far, if there is already a value in the model (not null), it displays with $ ...

NodeJS and ExpressJS fail to redirect to the main landing page

I am currently developing a shopping cart application using nodejs/expressjs. I have encountered an issue with redirecting back to the homepage ('/') after the user submits their credentials during sign up. Despite my search for relevant articles ...