I've got a project where I'm needing to print the HTML page the user is on, as well as multiple PDF files (multiple prompts is OK)
After hunting around on Google and Stackoverflow I found Printing multiple PDF files using JavaScript which is close, but not quite working.
The code below prints the HTML page fine, and creates a print prompt for the PDF, but the PDF print prompt is for a blank page.
I've triple checked the example address and the fine is definitely at http://www.mydomain.co.nz/wp-content/uploads/Golden-China1.pdf.
Anyone spot what I'm doing wrong?
function PrintAll(file1, file2, file3) {
window.print();
var pages = [file1, file2, file3];
for (var i = 0; i < pages.length; i++) {
if (pages[i] != undefined) {
var oWindow = window.open(pages[i], "print");
oWindow.print();
oWindow.close();
}
}
}
$('.print-btn').click(function() {
PrintAll('/wp-content/uploads/Golden-China1.pdf');
});