Background:
I am developing a windows-forms application in C# that executes the following steps:
- Read pre-configured text in a resource file (.resx) .
- Format the text obtained from the previous step with values provided in the form. (names, surnames, and current date).
- Save the information filled in SQL database.
- Using an ON 500 1 thermal printer , generate two prints of the information filled out.
Problem
At the time of printing, the thermal printer does not cut the reports (ie it does not split the generated receipts/prints), which results in paper waste.
The code I'm using to read the pre-configured text until the method invocation Print();
is:
// Imprimir recibo #1:
PrintDocument document_member1 = new PrintDocument();
document_member1.PrintPage += new PrintPageEventHandler(document_PrintPage_Member1);
document_member1.Print();
// Imprimir recibo #2:
PrintDocument document_member2 = new PrintDocument();
document_member2.PrintPage += new PrintPageEventHandler(document_PrintPage_Member2);
document_member2.Print();
My concerns are:
- How to send the command or instruction to the printer finish to cut after generating each print?
- How to define the size of each impression?
- Is there a better alternative to use
PrintDocument
to perform this functionality?
Example of sizes of prints to be made:
- Receipt #1: 360px X 360px
- Receipt #2: 360px X 560px
1 This is the brand of printer assigned to me for testing and is probably the customer's standard printer; but if there is information for "from C# to somehow interact with the printer driver" that solution would also be valid.
I have searched for terms like:
- C# POS receipt printing
- POS printing in C#
But this is very new to me and I am completely lost.
At some point a colleague had this problem, he solved it using RawPrinterHelper which is a small tool that someone developed.
With the method
SendStringToPrinter
the cut command is sent.Searching the internet for the command I found the following:
Y
And I don't remember what the exact command is, I'm also not sure if it varied between models.
Maybe if you look for the command for the model you have you can find it.