So Tired !_! 逆水行舟, 不进则退!

9Jun/10

POS58 票据热敏打印机,怎么用ESC/POS命令控制打印文字大小?

Posted by Nick Xu

使用的是POS58票据热敏打印机,怎么控制文字大小?
我知道ESC/POS指令,可不会用。
ASCII :ESC ! n
十 进制 :27 33 n
十六进制:1B 21 n

在C#里用十进制,是不是(char)(27)+(char)(33)+ (char)(n)就可以把文字放大一倍打印了?
主要是想放大文字打印。n不知道取多少? 是48吗?

比如要将"中国"这个字符串放大一倍打印,具体怎么写的?

____________________________________________________

经过多次尝试,终于搞懂了.

先用字符的形式发送命令:

send = "" + (char)(27) + (char)(64) + (char)(27) + (char)(33) + (char)(48);

for (int i = 0; i < send.Length; i++)
{
buf[i] = (byte)send[i];
}

fs.Write(buf, 0, buf.Length);

解释:  (char)(27) + (char)(64)是将打印机初始化, (char)(27) + (char)(33) + (char)(48); 是设置打印字符格式命令,最后的48可以为0,16,32,48

接着直接打印输出:

printLPT.PrintData("中国" );

欢迎有同类问题的朋友指教!

*************************************************************************************

更正:其实可以把控制命令字符和输出字符写在一起.不管用什么方式,如果是多条数据就要在一个输出程序里同时输出,而不要写成函数的形式来调用,那 样是不会成功的.这是我经过一天一夜研究出来的结果,网上也能找到ESC/POS打印指令使用的程序,人家就是写在一起的,但没有控制字符大小的例子.我 自作聪明的把它改成一个函数,费了一天一夜的功夫才发现走了弯路.不过也值得,终于弄懂了ESC/POS指令怎么用了.

Tagged as: , , No Comments
25May/10

如何使用并口控制打印机打印的字体大小

Posted by Nick Xu

These should work on most DMPs especially EPSON ones.
Basically there are 3 font sizes built into the printer firmware.

1) Normal size

2) Large size - Use chr(14)

Eg; Print #1, chr(14); "ABCDE"

Will print ABCDE in large sized font. To revert back to normal size you can use chr(18)

Eg; Print #1, chr(14); "ABCDE"; chr(18); "XYZ"

Will print ABCDE in large sized font and XYZ in normal sized font.

3) Condensed - Use chr(15)

Eg; Print #1, chr(15); "ABCDE"

Will print ABCDE in condensed font. To revert back to normal size you can use chr(18)

Eg; Print #1, chr(15); "ABCDE"; chr(18); "XYZ"

Will print ABCDE in condensed font and XYZ in normal sized font.

This is all that I know.

Regarding pagesize, there are specific codes. These may be found in the Printer manual.

As far as I am concerned, in the progrmme I count the number of lines and send a page eject (chr(12)) when required. For example if the length of paper is 12" and you are printing @ 6 lines per inch with 1" margin on top and bottom, you can print 60 line on a sheet. After 60 lines you give a page eject to start the new page.

1. How can i give blank line between lines ? (IF i need one blank line)

Print #1, vbnewline

2. Suppose my paper width is 9 inches, How many characters to be printed in one line ? (horizontal line)

Depends on the font size. Normally it is 10 cpi. So after leaving 1 inch margin on left and right it will be 7*10 = 70 characters.

   
site
site