我如何在从我的js代码生成的txt文件中添加分页符?



这是我从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;
}

最新更新