evargas
evargas

Reputation: 71

Feed paper on POS Printer C#

I've been trying to programatically feed the paper on a pos printer (Epson TM-U220D). The problem I have is that the last line of the document don't get printed, instead, it is printed as the first line of the next document printed. I tried POS for .NET sending the "ESC|flF" command, also tried to send the raw esc/pos command using the serial port, but it doesn't work. Any ideas?

Upvotes: 6

Views: 13650

Answers (4)

alexandrul
alexandrul

Reputation: 13246

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: https://web.archive.org/web/20111229102746/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

Upvotes: 3

JDibble
JDibble

Reputation: 744

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.

Upvotes: 0

SmacL
SmacL

Reputation: 22922

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.

Upvotes: 0

bugmagnet
bugmagnet

Reputation: 7769

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.

Upvotes: 0

Related Questions