I have a web worker that generates pdf of a table and post it on the main js file. The code is something like this
worker.js
onmessage = function(e) {
var pdf = window.generatePdf();
postMessage(e.data[0]);
}
main.js
var worker = new Worker('worker.js');
worker.postMessage([config]);
worker.onmessage = function(e) {
save(e.data);
}
But window object can no be accessed in worker.js file. Any idea on how to make it accessible in that file or how to achieve the functionality otherwise. Thanks.
Edit: I am using pdfmake.min.js to generate pdf file. Can this file be accessed from within worker.js?