This is my code to extract data from my html table and print them in a .txt file:
$('table tbody tr').each(function(){
count+=1;
var detail='';
var arr1=[];
$(this).find('td').each(function(){
detail=$(this).text();
arr1.push(detail);
});
detail='';
for(var k=0;k<arr1.length;k++){
detail+=arr1[k];
detail+=' ';
}
userDetails+=detail+"\r\n";
userDetails+='--------------------------------------------------------------------------------------------------------------------------------------------------------------------';
userDetails+='\n';
if(count==40){
//add page break symbol here
count=1;
}
});
var a = document.createElement('a');
var file = new Blob([userDetails], {type: 'text/plain'});
a.href = URL.createObjectURL(file);
a.download = "IPAS_electric_data.txt";
a.click();
a.remove();
I want to add a page break symbol when count=40, so that the line printer starts printing from the next page when it gets the symbol. How do I add it?
As suggested by @Tim Roberts and @CBroe, adding the formfeed character '\f' worked:
if(count==40){
userDetails+='\f';
count=1;
}