Feed paper on POS Printer C#

痴心易碎 提交于 2019-12-03 16:12:11

You will need sooner or later the full ESC/POS Application Programming Guide. I did obtained a copy from my EPSON dealer some years ago. In the meantime, I have found with Google a link to the FAQ for ESC/POS here: http://postechgroup.com/updata/support/drivers/EPSON/FAQ_ESCPOS.pdf

In your case, the LF control command prints the data in the print buffer and feeds one line based on the current line spacing.

ASCII: LF

Hex: 0A

Decimal: 10

If the printer is on LPT1, shell out to DOS and give to CMD.EXE or COMMAND.COM whatever the C# equivalent is of this BASIC expression:

"ECHO " & Chr(12) & ">LPT1"

Either that or append a Chr(12) to the output text.

As boost says, you need to get a form-feed / FF / ascii 12 to the printer port. In C or C++, if you opened your printer as a file, this would be

fprintf(printerfile,"%c",12);

The issue sometimes arises on these printers that the output buffer is not actually processed / flushed until a carriage return is written. You might also manually flush the stream. So you would then use

fprintf(printerfile,"%c%c",12,13);
fflush(printerfile);

An easy mistake to make when outputting to devices such as serial printers is that the communications and printing happen asynchronously to your main application. Thus it is important not to close the printer port immediately after you finish printing as this can cause loss or corruption of the final output buffer.

(Sorry this is C rather than .NET, I'm one of those C++ old-timers that hasn't moved over)

Edit: Reading alexandruls comments on my post, I my well have got this wrong. It sounds as if you might be getting an unwanted form feed becuase you have set the page length incorrectly, or the default is incorrect. Check the ESC C n group of Epson commmands to overcome this.

Are you cutting the paper? If you are cutting the paper the position of the cutter is higher than the print head. You therefore need to feed a number of lines before the cut command is sent. You should just be able to format a string with say 5 line feeds (LF -> Chr(10)), send them, and then send the cut command.

In the Epson EScPOS dcoumentation there is GS V command that will feed and cut the paper at the correct point.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!