这是我从html
表中提取数据并在.txt
文件中打印它们的代码:
$('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+"rn";
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();
我想在count=40
时添加换页符符号,以便行打印机在获得该符号时从下一页开始打印。怎么加呢?
根据@Tim Roberts和@CBroe的建议,添加formfeed字符'f'
工作:
if(count==40){
userDetails+='f';
count=1;
}