I have multiple pdf's. With one button I want to open print preview for all documents seperately. The solution can be in javascript or jquery.
Thanks a lot
In most browsers, you cannot open multiple print dialogs. Instead, you can open them sequentially. The easiest way to print PDFs in Javascript is with PrintJS
Here's a recursive example that prints an array of PDFs.
var documentURLs = ["https://example.com/pdf1.pdf", "https://example.com/pdf2.pdf"]
function printDocuments(index){
if(index > documentURLs.length){
return;
}
printJS({
printable: documentURLs[index],
type: 'pdf',
onPrintDialogClose: function () {
printDocument(index+1)
}
})
}
You'd start it with printDocuments(0). Be sure to download and include the PrintJS library with <script src="print.js"></script>