[英]How to print box drawing character using ESC/POS
我想在 android 應用程序中使用 ESC/POS 將繪圖字符打印到 Epson LQ310 點陣打印機。 示例打印輸出如下,
最初,我使用下划線和豎線來繪制它的邊框。 但打印出來的結果是虛線。 我想改為連續線。
然后我看到有一個帶有 ASCII 碼的繪圖字符作為圖像附加,
使用這些 ASCII 代碼信息,我嘗試打印,但打印輸出變成了其他字符。 我發現這是由於打印機中使用了不同的字符集
通過 ESC/P 命令查看,關於字符集的命令只有這兩條。
ESC R
ESC t
我完成的示例代碼如下,我只是嘗試了幾個字符,但無濟於事。 如何注冊 PC850 字符集並使用 ESC t 命令使用它?
char[] verticalLine = {0x00B3};
char[] verticalPlusLeft = {0x00B4};
char[] upperRightCorner = {0x00BF};
char[] bottomRightCorner = {0x00D9};
char[] upperLeftCorner = {0x00DA};
char[] bottomLeftCorner = {0x00C0};
char[] horizonLine = {0x00C4};
char[] verticalPlusRight = {0x00C3};
char[] charMultiLangual = {0x001B, 0x0074, 0x0002}; //ESC,t,2(PC850)
char[] charCodeDefault = {0x001B, 0x0074, 0x0000}; //ESC,t,0(Default)
strPrintFooterTitle = new String(charMultiLangual);
strPrintFooterTitle += printFooter(new String(upperLeftCorner), "TYPE", new String(verticalLine), "QTY", new String(upperRightCorner)) + "\n";
strPrintFooterBig = printFooter(new String(verticalLine), "Crate - Big", "|", "5", "|") + "\n";
strPrintFooterSmall = printFooter("|", "Crate - Small", "|", "10", "|") + "\n";
strPrintFooter = new String(charCodeDefault);
任何幫助深表感謝。 謝謝
您可以完全使用那些畫框字符,而不是它們的代碼,如下所示:
System.out.println("┌───────────────────────┬───────┐");
System.out.println("│ Type │ QTY │");
System.out.println("├───────────────────────┼───────┤");
System.out.println("│ Crate - Big │ 7 │");
System.out.println("├───────────────────────┼───────┤");
System.out.println("│ Crate - Small │ 3 │");
System.out.println("└───────────────────────┴───────┘");
Output:
┌───────────────────────┬───────┐
│ Type │ QTY │
├───────────────────────┼───────┤
│ Crate - Big │ 7 │
├───────────────────────┼───────┤
│ Crate - Small │ 3 │
└───────────────────────┴───────┘
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.