I use this code to print text file to POS printer (EPSON):
AssignFile(prnfile, 'file.txt');
Reset(prnfile, 1);
AssignFile(port, 'COM3');
Rewrite(port, 1);
repeat
BlockRead(prnfile, buffer, SizeOf(buffer), Read);
BlockWrite(port, buffer, Read);
until EOF(prnfile) or (Read <> SizeOf(buffer));
CloseFile(prnfile);
CloseFile(port);
Text is printed, but I need to cut a receipt.
I have EPSON command codes, but I don't know how to send them to printer.
Can anybody write an example?
Thank You.
Best Answer
I've tried a lot and finally I've written this code that works:
so the solution is:
Anyway, my suggestion is to use a tComPort component instead of a direct use of Writeln. Using a tComPort you can handle the return value from the printer in case of errors like "End Paper", "Printer OffLine" and so on.