var documentURLs = ["maca.pdf", "maca2.pdf"]
function printDocuments(index){
if(index > documentURLs.length){
return;
}
else {
printJS({
printable: documentURLs[index],
type: 'pdf',
onPrintDialogClose: function () {
console.log(index);
printDocuments(index++)
}
})
}
}
<button type="button" onclick="printDocuments(0)">Print</button>
This is not incrementing the index, always print first document and it is not stopping