I am trying to have a print button that will print multiple pdfs or files when clicked.
Is it possible to have a print all button:
<button class="btn-u btn-u-orange" name="printall" id="printall" ><i class="icon-printer"></i> Print All</button>
But then somehow have it print all the pdfs or pages when clicked. I have been trying to do it with javascript but unfortunately am failing miserably.
function PrintAll() {
var pages = ["forms/82040PDFCreator.cfm", "forms/poa.cfm", "forms/Billofsalevehicle.cfm"];
for (var i = 0; i < pages.length; i++) {
var oWindow = window.open(pages[i], "print");
oWindow.print();
oWindow.close();
}
}
$("#printall").on("click",function(){
PrintAll();
});
When I select print it is only popping up the first pdf to print and nothing else. Any help with this would be greatly appreciated.
Added coldfusion tag because I am calling .cfms that are populating the pdfs.
What Iv Tried is to create Iframes:
<iframe src="forms/82040PDFCreator.cfm" style="width:400px; height:400px;" frameborder="0"></iframe>
<iframe src="forms/poa.cfm" style="width:400px; height:400px;" frameborder="0"></iframe>
<iframe src="forms/Billofsalevehicle.cfm" style="width:400px; height:400px;" frameborder="0"></iframe>
<iframe src="forms/IRF.cfm" style="width:400px; height:400px;" frameborder="0"></iframe>
<iframe src="forms/InsuranceAffidavit.cfm" style="width:400px; height:400px;" frameborder="0"></iframe>
<iframe src="forms/FeesBreakdown.cfm" style="width:400px; height:400px;" frameborder="0"></iframe>
They wont all show though. They all work but wont all show a few error out once theres more than three iframes. I have been trying to set an interval to load them hoping they wont timeout but have been unsuccessful. If I can get them all to appear I was going to try to make the button somehow cycle through the iframes and print them. Everytime I hit refresh some iframes work some dont, constantly changing which ones do and which ones dont.
Trying to set a timeout or interval or something to get them all to appear:
$("#printall").on("click",function(){
var iframes = document.getElementsByTagName("iframe");
var i = 0;
window.setInterval(function(){
if(i < iframes.length){
i++;
}
}, 3000);
});