skip to Main Content

I made a system (using C# and WooCommerce Rest API) for a TakeAway Website to print a Ticket after a User orders products on a Website.

I am using the EPSON TMT20 II Printer to print the Data. I am using the Printer as a Network Printer because I have to and printing Tickets is no Problem, I only have to cut the Paper after successfully printing a Ticket which is the Problem I have.

I am sending the Data via CMD Commands

(example: copy /b "D:…order_n.txt" "\ServernamePrintername") -> prints the Data I saved in a .txt File

is it possible to append the paper cut command to the .txt File that I am printing or is there another, more efficient way to cut the paper via C#?

According to the Documentation GS V 48 and GS V 0 are the commands that can be used to cut the paper

https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=87#gs_cv

I tried using the RawPrinterHelper Class and sending the Cut Command Data as Bytes but it returns me Windows Error 1801 or rather I can’t access the Printer in that way. I also tried to append the command the File I sent to the printer.

Any help would be appreciated! if I haven’t been detailed enough please let me know!
Thanks in Advance

2

Answers


  1. Chosen as BEST ANSWER

    It works now,

    I just appended these lines of Code to the Text File that I am printing

    string GS = Convert.ToString((char)29);
    string ESC = Convert.ToString((char)27);
    string COMMAND = "";
    COMMAND = ESC + "@";
    COMMAND += GS + "V" + (char)48;
    
    sw.WriteLine(COMMAND);
    

  2. If you can print the .txt file with the raw ESC/POS command and the text to be printed, copy it to the server printer device, and have the server send it directly to the printer, then at the end of the file It seems that the paper can be cut simply by adding the ESC/POS command for cutting the paper.

    In that case, please create the command according to the notes on the referenced page. The paper cut command must be in a state where no print request is made at the beginning of the line. Also, since there is a distance between the print head and the paper cutter, you will need to use the function B command to put an appropriate line break before the cut.

    By the way, 0/48 in the reference pages, such as GS V 0 and GS V 48, is 0x00/0x30. If it is function B, it becomes 0x41/0x42, and the line feed number is specified after that.

    Instead, if the program on the server converts the .txt file you sent to the server into a page image and then prints on the printer, you need to incorporate the mechanism you wrote to cut the paper. maybe.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search