[英]How do I add the page break symbol in a txt file generated from my js code?
這是我從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+"\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();
我想在count=40
時添加一個分頁符,以便行式打印機在獲得該符號時從下一頁開始打印。 我該如何添加它?
正如@Tim Roberts 和@CBroe 所建議的,添加換頁符'\f'
有效:
if(count==40){
userDetails+='\f';
count=1;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.