Previously I made the VB.NET version here:
https://rani-irsan.blogspot.com/2019/12/vbnet-printing-pos-receipt-directly-to.html
But there're some requests to make the C# version. So here it is direct printing which is often used to print cashier receipts through the POS (Point of Sales) application.
I created 2 classes for supporting the printing process. These classes also allow us to print images or logos and arrange fonts as desired. The classes can be downloaded using the below link:
- PrintingFormat.cs --> for formatting printing object
- Printer.cs --> for sending a print command Directly to printer
After downloading those 2 files, copy them into your project/solution as in the image below.
Then open the project/solution using Visual Studio. Go to Solution Explorer then click/activate "show all files" as below. After the files are displayed, select and right-click on it --> Include In Project. Now, we're ready to use it.
On UI Design we'll only add a button into the Form1. Printing will be triggered by Button1_Click()
And here is the behind code:
Let's run and click the button1 to print.
This is the result:
If you want to download the sample project, download it here!
0 Comments