Printing cordova插件datecs打印机中的Word wrap
我正在使用ionic 1开发一个移动应用程序,对于热敏打印机的打印,我正在使用cordova插件datecs打印机插件 除了包装这个词,一切都正常。打印机在行尾剪切字有没有办法调整或启用换行以避免单词不完整? 这是我的密码:Printing cordova插件datecs打印机中的Word wrap,printing,cordova-plugins,escpos,Printing,Cordova Plugins,Escpos,我正在使用ionic 1开发一个移动应用程序,对于热敏打印机的打印,我正在使用cordova插件datecs打印机插件 除了包装这个词,一切都正常。打印机在行尾剪切字有没有办法调整或启用换行以避免单词不完整? 这是我的密码: tale += '{center}{b}Le Petit Prince{/b}{br}{br}'; tale += '{left}Once when I was six years old I saw a magnificent picture in a book, cal
tale += '{center}{b}Le Petit Prince{/b}{br}{br}';
tale += '{left}Once when I was six years old I saw a magnificent picture in a book, called True Stories from Nature, about the primeval forest. It was a picture of a boa constrictor in the act of swallowing an animal. Here is a copy of the drawing.&n the book it said: "Boa constrictors swallow their prey whole, without chewing it. After that they are not able to move, and they sleep through the six months that they need for digestion.';
//Replace & with line breaks
var text1 = tale.replace(/&/g, '{br}{br}');
cordovaPrinter.printText(text1);
结果如下:(
看看这个片段,我认为它是不言自明的
var yourString = "The quick brown fox jumps over the lazy dog"; //replace with your string.
var finalString = "";
var maxLength = 16 // maximum number of characters to extract
var count = 0;
var maxTries = ((yourString.length / maxLength) * 2);
while (yourString.length > maxLength) {
count++;
if (count > maxTries) {
break;
}
//trim the string to the maximum length
var trimmedString = yourString.substr(0, maxLength);
//re-trim if we are in the middle of a word
trimmedString = trimmedString.substr(0, Math.min(trimmedString.length, trimmedString.lastIndexOf(" ")));
yourString = yourString.replace(trimmedString + " ", "");
finalString += trimmedString + '<br>';
}
finalString += yourString;
console.log(yourString);
console.log(finalString);
var yourString=“敏捷的棕色狐狸跳过懒狗”//替换为字符串。
var finalString=“”;
var maxLength=16//要提取的最大字符数
var计数=0;
var maxTries=((yourString.length/maxLength)*2);
while(yourString.length>maxLength){
计数++;
如果(计数>最大值){
打破
}
//将字符串修剪到最大长度
var trimmedString=yourString.substr(0,maxLength);
//重新修剪,如果我们在一个词的中间
trimmedString=trimmedString.substr(0,Math.min(trimmedString.length,trimmedString.lastIndexOf(“”));
yourString=yourString.replace(trimmedString+“”,“”);
finalString+=trimmedString+'
';
}
finalString+=您的字符串;
log(您的字符串);
控制台日志(finalString);
看看这个片段,我认为它是不言自明的
var yourString = "The quick brown fox jumps over the lazy dog"; //replace with your string.
var finalString = "";
var maxLength = 16 // maximum number of characters to extract
var count = 0;
var maxTries = ((yourString.length / maxLength) * 2);
while (yourString.length > maxLength) {
count++;
if (count > maxTries) {
break;
}
//trim the string to the maximum length
var trimmedString = yourString.substr(0, maxLength);
//re-trim if we are in the middle of a word
trimmedString = trimmedString.substr(0, Math.min(trimmedString.length, trimmedString.lastIndexOf(" ")));
yourString = yourString.replace(trimmedString + " ", "");
finalString += trimmedString + '<br>';
}
finalString += yourString;
console.log(yourString);
console.log(finalString);
var yourString=“敏捷的棕色狐狸跳过懒狗”//替换为字符串。
var finalString=“”;
var maxLength=16//要提取的最大字符数
var计数=0;
var maxTries=((yourString.length/maxLength)*2);
while(yourString.length>maxLength){
计数++;
如果(计数>最大值){
打破
}
//将字符串修剪到最大长度
var trimmedString=yourString.substr(0,maxLength);
//重新修剪,如果我们在一个词的中间
trimmedString=trimmedString.substr(0,Math.min(trimmedString.length,trimmedString.lastIndexOf(“”));
yourString=yourString.replace(trimmedString+“”,“”);
finalString+=trimmedString+'
';
}
finalString+=您的字符串;
log(您的字符串);
控制台日志(finalString);
这实际上与ESC/POS无关,您应该删除该标签,imo。正如插件创建者所建议的:“请询问有关cordova插件datecs打印机和使用标签cordova插件和escpos的问题”这不是一个有用的建议。这实际上与ESC/POS无关,imo,您应该删除该标签。正如插件创建者所建议的:“请询问有关StackOverflow的问题,提及cordova插件datecs打印机并使用标签cordova插件和escpos”,这不是一个有用的建议。