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>
这不会增加索引,始终打印第一个文档并且它不会停止