Everything works fine except the qr code doesn't get printed. Barcode on the other hand is printed fine. Can you help? Pos thermal printer printer support qr code printing and it is shown when we print test page.
Using raw printing, how can i programmatically change the print side when the printer has 2 heads. Ie which esc sequence can i send to the printer. Something similar to what PosPrinter.ChangePrintSide from the .net sdk does
@@techsapphire Rephrasing my question a bit. How can i switch between Slip and Roll printing programatically? Roll printing works but it does not switch to Slip printing mode
Is it possbile to set both height and width for a text print, it seems that the last setting you apply is the active one, so either the text is high or wide, but not both??PrintByteArray = PrintExtensions.AddBytes(PrintByteArray, obj.CharSize.DoubleHeight8()); PrintByteArray = PrintExtensions.AddBytes(PrintByteArray, obj.CharSize.DoubleWidth8());In this example the text gets wide, but not high??
Thank you for the code, it works perfect. Did you find a way to get feedback from the printer? Ideally, i would like to get a print response after each print command.
If you are using EPSON printer than use this video of mine, here I am using EPSON SDK, their we can get anything th-cam.com/video/5eN1Irt5ViQ/w-d-xo.html
Sent, kindly check your email. Note: I also provide commercial support. Please contact if needed. If you find this solution helpful than donate comfortable amount on papal to my email ID or link www.paypal.me/bimlamehla . Donation is not mandatory, it is just a request to support free tutorials.
After installing PritnerUitility & build code at .cs file there are showing two error are show :- Error 1) The type or namespace name 'PrinterUtility' could not be found (are you missing a using directive or an assembly reference?) 2) The primary reference "PrinterUtility, Version=1.0.2.0, Culture=neutral, processorArchitecture=x86" could not be resolved because it was built against the ".NETFramework,Version=v4.6.1" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5.1".
@@FgroupIndonesia this is my business model, I gain communication with person. If he needs any commercial support than it is easy to ask if communication is already open
I have EPSON TM-T82 with me, connected to my notebook/laptop through USB port. But everytime I tried to print with the printer path "\\\\\\EPSON TM-T82 Receipt", I always get "System.IO.IOException: The specified path is invalid". Have you experienced this issue before?
An unhandled exception of type 'System.IO.IOException' occurred in mscorlib.dll Additional information: Cannot create a file when that file already exists. which file??
Hi, Nice tutorial, I would like to know, is there a possibility to create a template and generate the receipt dynamically, for example in one template the store address is in the beginning and in the other template the address is at the last.... something like that??
Hi. thanks for tutorial. Could you help me. I am receiving error "System.IO.IOException: 'A device attached to the system is not functioning." while using printer utility with everycom printer. but its working fine when I pass direct print command .
@@techsapphire Thanks for reply. Can we write big string (len=20) into barcode. If no How much char we can write?. Currently when I try it skip the barcode data and print the rest slip.
Hi, I try your PrinterUtility NutGet work great for 32bits application. But my application build on 32 and 64bits on Visual Studio 2015. Do you have 64bit version? Can I have the source code or buy from you?
I am having issue setting printer path. I've set it as you have told to do in the tutorial but I'm getting error "The Specified path is invalid" Can you please help me out with this?
I'm getting this exception, can tell me the work around for that ? "An exception of type 'System.IO.IOException' occurred in mscorlib.dll but was not handled in user code Additional information: The network name cannot be found." It was working good but suddenly started giving this exception.... I'm working with ASP MVC5 WebProject.
If you face exception "Error the network name cannot be found" during printing. Than use below link to make work around. www.techsapphire.in/index/pos_printer_error_the_network_name_cannot_be_found/0-184
Thanks For reply :) please tell me where to use this code ? if (File.Exists(".\\tmpPrint.print")) File.Delete(".\\tmpPrint.print"); File.WriteAllBytes(".\\tmpPrint.print", BytesValue); RawPrinterHelper.SendFileToPrinter("POS1", ".\\tmpPrint.print"); try { File.Delete(".\\tmpPrint.print"); } catch { }
You can directly print file without temp file use this code public static bool SendValueToPrinter(string szPrinterName, Byte[] BytesValue) { Byte[] bytes = BytesValue; bool bSuccess = false; // Your unmanaged pointer. IntPtr pUnmanagedBytes = new IntPtr(0); int nLength = 0; nLength = Convert.ToInt32(bytes.Length); // Read the contents of the file into the array. // Allocate some unmanaged memory for those bytes. pUnmanagedBytes = Marshal.AllocCoTaskMem(nLength); // Copy the managed byte array into the unmanaged array. Marshal.Copy(bytes, 0, pUnmanagedBytes, nLength); // Send the unmanaged bytes to the printer. bSuccess = SendBytesToPrinter(szPrinterName, pUnmanagedBytes, nLength); // Free the unmanaged memory that you allocated earlier. Marshal.FreeCoTaskMem(pUnmanagedBytes); return bSuccess; } //RawPrinterHelper.SendValueToPrinter(PrinterName, BytesValue); Note:RawPrinterHelper you can find online
Thanks bro... could u possibly share me the source code with ethernet type connection to rajkumarbtech4@gmail.com, it would be great if i could look into your code further.
Sent please check your email. Second version of video is also available. Where you can learn to print directly from web browser. th-cam.com/video/MQMD4Pb7jzY/w-d-xo.html
Wich way is the best for a better flexibility like font, color, text arrangement for printing, using a report like let's say Quick repor or the Microsoft's RawPrinterHelpler.cs class ? thank's for the tutorial. Any other solution using an SDK is welcome.
Rawprinting is very simple and limited, you don't have much to customize there. But you can use POS for .NET specialy with EPSON, Zebra and Citizen printer. With POS for .NET you can do amazing things. I have already recorded on lecture on it, you can try this : th-cam.com/video/5eN1Irt5ViQ/w-d-xo.html
Yes it works in WPF like charm. I am mailing you code. In code print method seems to be problem with some developer so I made one more tutorial to have work around. I am mailing you link for that issue too.
If you check technical specification for any POS printer. They will mention character set. If they are passing EPSON character set simulator than this will work. Also IBM too.
Usually most of the printer follows EPSON or IBM. So you need to check which it is. You can build for IBM if it doesn't works. These are character only so you can build one for your own.
Sorry Filbert, I can't suggest on that. I can share my code. For that you need to check printer specification and document explaining character set which print needs.
Hi Sir I am in the process of developing a pos system. Can I use the print code that you have mailed? I am sure I might need to make a few changes. Regards VENU
it works with almost all escpos printers, but commands might change. You can try this video, it is about generic printing for all printers. th-cam.com/video/osI7P1YdL3o/w-d-xo.html
Hi Mohamad you need to test by printing as size of EPOS printer vary as per paper size. No predefined configuration comes. Share your email ID I will mail you project so that you can reference it,
Great video ... I'm trying to use a solution in linux with a local printer how do I? Do you have an example of how to call this printer being shared? I also saw rawPrinterHelper but winspol.drv is unique to windows. If you have any tips .... Thanks
It work with all POS printers. As basic marking for all text printers are same. But only POS for normal printer you need to use crystal report or RDLC type reporting standards.
Hello sir, Every thing is working fine , is it possible to change the printing language to hindi or else any indian regional language.I m currently using epson thermal tmt82-printer.
Below code worked for Chinese so try to find encoding for Hindi: var encoding = Encoding.GetEncoding(936); // convert the text into a byte array byte[] source = Encoding.Unicode.GetBytes("百順藥房");
@@techsapphire Thanks for your response. My thermal printer is GPrinter and i've tested it only to print a Png with Qrcode. If it doesn't support Qrcode i can't use PrinterUtility package?
If it doesn't support QR code than you can use some third party dll to generate QR code in image and use that image to print via printer. If your printer is not supporting, you can't do any thing other than that. If my solution help you, you can support me by doing some donation on link: paypal.me/yogeshmehla Donation help in keeping free community work. Sent please check your email. Second version of video is also available. Where you can learn print using POS for .NET on epson printer : th-cam.com/video/5eN1Irt5ViQ/w-d-xo.html Where you can learn to print directly from web browser. th-cam.com/video/MQMD4Pb7jzY/w-d-xo.html
Sent please check your email. Second version of video is also available. Where you can learn print using POS for .NET on epson printer : th-cam.com/video/5eN1Irt5ViQ/w-d-xo.html Where you can learn to print directly from web browser. th-cam.com/video/MQMD4Pb7jzY/w-d-xo.html
I am making a software and I need to print on the client side since it is from an asp.net web portal c #, and the client will enter a web page published on the internet, not on the intranet, is this possible?
Hi Hector second version of this video is also available. Where you can learn to print directly from web browser. th-cam.com/video/MQMD4Pb7jzY/w-d-xo.html
Hello Sir, I could manage to print out but stuck at its not cut out after finishing the print. I have select 'No Cash Drawer' in Printer Properties. Please help me. Waiting for your kind reply. Best Regards
Hi tech Saphire... I was using your way of printing for last one year and is very useful..but can you please advice me how can i add a line of arabic string in the print..i tried to do it like below.. bytes = PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes("Tax Invoice ")); bytes = PrintExtensions.AddBytes(bytes, System.Text.Encoding.Unicode.GetBytes("فاتورة ضريبية")); bytes = PrintExtensions.AddBytes(bytes, System.Text.Encoding.UTF32.GetBytes("فاتورة ضريبية"));
you can try something like this : var encoding = Encoding.GetEncoding(936); // convert the text into a byte array byte[] source = Encoding.Unicode.GetBytes("百順藥房");
@@techsapphire sorry iam not using Epson printer ...I have to go with your first option ..but can you please confirm whether there is a typo because I cannot see u used encoding ...but used Normal Encoding
sdk k printer specific. For Epson use epsont sdk for brother use brother. So no preference in that. Usually POS receipts are never customized with font, max logo's are used. Their purpose is to print fast only.
Below code worked for Chinese so try to find encoding for Arabic: var encoding = Encoding.GetEncoding(936); // convert the text into a byte array byte[] source = Encoding.Unicode.GetBytes("百順藥房"); // convert that byte array to the new codepage. byte[] converted = Encoding.Convert(Encoding.Unicode, encoding, source); // Perform the conversion from one encoding to the other. BytesValue = PrintExtensions.AddBytes(BytesValue, converted );
Hi i am getting this error, PrintExtensions.Print(BytesValue, DesktopPrintApp.Properties.Settings.Default.PrinterPath); Error CS0029 Cannot implicitly convert type 'void' to 'byte[]'
Hi Yogesh dear receipt is not printing to my printer i am using 3 inch thermal printer when i press print button i get an error the file is already exist you cannot print
hi, yogesh. your code is working very fine. Thanks for such an example video? what if i wanted to print same from my web application???? can you help me out for that ???
IT works Like a charm Thanks Very much , But Cash Drawer connected to Reciept Printer not Opening (not on all cases) .Can you guess what may be the issue so that we can update it to this?
obj.Guilhotina.CutFull(); this is the method for cutting page. Good video though, thanks. I am getting extra spaces below the barcode and can't add the text of barcode just below the barcode like it has everywhere, can you solve that?
yes it will give error. In general in stores you will never see alpha numeric barcode. Item number are always character. So common POS don't support alpha numeric barcodes.
techsapphire Thanks... But is there any alternative ? And one more question auto cut receipt how to implement that. One you had given Not working. I tested same on Epson and TVS 2 different model everything is working perfectly except alphanumeric barcode and auto cut
yes alternative is available but for that you have to use POSfornet SDK using EPSON api's. Which I never used. Auto cut code is available in code I shared.
@@techsapphire Hai I need to prind data in a4 sheet but multiple of items data in multiple particion box's in a4 sheet 7013338512 my contact number Raihaan.october6@gmail.com My mail ID please help me
Sent please check your email. Second version of video is also available. Where you can learn print using POS for .NET on epson printer : th-cam.com/video/5eN1Irt5ViQ/w-d-xo.html Where you can learn to print directly from web browser. th-cam.com/video/MQMD4Pb7jzY/w-d-xo.html
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Printing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using PrinterUtility; namespace printertesttvs { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { PrinterSettings printerSettings = new PrinterSettings(); printerSettings.PrinterName = "YourPrinterName"; printerSettings.DefaultPageSettings.PaperSize = new PaperSize("Custom", 300, 150); // Create a PrintDocument object and assign the printer settings to it PrintDocument printDoc = new PrintDocument(); printDoc.PrinterSettings = printerSettings; // Add a PrintPage event handler to the PrintDocument object printDoc.PrintPage += new PrintPageEventHandler(PrintPage); // Call the Print method on the PrintDocument object to print the document printDoc.Print(); } void PrintPage(object sender, PrintPageEventArgs e) { // Define the font and brush for the text Font font = new Font("Arial", 10); Brush brush = Brushes.Black; // Define the text to be printed string headerText = "કર્ણાવતી એગ્રીકલ્ચર માર્કેટ યાર્ડ"; string dateText = "Date: 3/23/2023"; string item1Text = "Item 1: 10.00"; string item2Text = "Item 2: 20.00"; string totalText = "Total: 30.00"; // Define the position and spacing for the text float xPos = 0; float yPos = 0; float ySpacing = 20; // Draw the header text e.Graphics.DrawString(headerText, font, brush, xPos, yPos); yPos += ySpacing; // Draw the date text e.Graphics.DrawString(dateText, font, brush, xPos, yPos); yPos += ySpacing; // Draw the item 1 text e.Graphics.DrawString(item1Text, font, brush, xPos, yPos); yPos += ySpacing; // Draw the item 2 text e.Graphics.DrawString(item2Text, font, brush, xPos, yPos); yPos += ySpacing; // Draw the total text e.Graphics.DrawString(totalText, font, brush, xPos, yPos); yPos += ySpacing; } } }
Sent, kindly check your email. Note: I also provide commercial support. Please contact me if needed. If you find this solution helpful than donate comfortable amount on papal to my email ID or link www.paypal.me/bimlamehla. Donation is not mandatory, it is just a request to support free tutorials.
Thank you for the tutorial. Glad that you recommended this one to me .... Can I have the source code of this one please ? Thank again for the great job you're doing.
Sent, kindly check your email. Other Tutorials: POS printing using POS for .NET. th-cam.com/video/5eN1Irt5ViQ/w-d-xo.html Also if you face exception "Error the network name cannot be found" during printing. Than use below link to make work around. www.techsapphire.in/index/pos_printer_error_the_network_name_cannot_be_found/0-184 For text formatting please refer this lecture: th-cam.com/video/3IcJWpw6wL8/w-d-xo.html Note:I also provide commercial support. Please contact if needed.If you find this solution helpful than donate comfortable amount on papal to my email ID or link www.paypal.me/bimlamehla.Donation is not mandatory is it just request to support free tutorials.Video tutorial to support all printer brand for POS print: th-cam.com/video/osI7P1YdL3o/w-d-xo.html
Thank you for the tutorial. I'm having trouble finding documentation about this library. Can you send me the source code please? It would help a lot... Thank you
@@sweaterhijauzzz sent kindly check your email. Note: I also provide commercial support. Please contact if needed. If you find this solution helpful than donate comfortable amount on papal to my email ID or link www.paypal.me/bimlamehla . Donation is not mandatory, it is just a request to support free tutorials.
Hello Sir, Now Everything Has Been Resolved. A very big thanks after all.
Sorry for late reply. Glad you found your fix.
if i change the esc/pos command to other printer command it can work? like TVS printer .IF i want change some esc/pos command how can i do it
You can customize source code which I share.
One question : this code change printer settings ? Because when using other programs that needs to print , the print comes out with different format
Everything works fine except the qr code doesn't get printed. Barcode on the other hand is printed fine. Can you help?
Pos thermal printer printer support qr code printing and it is shown when we print test page.
Check if your printer supports QR code or not, Or if it is not Epson than code might be diff for that.
@@techsapphire I use Aures ODP 333 which is esc/pos compatible and support qr code.
@@alevak09 than you need to check what command it need for QR code
Using raw printing, how can i programmatically change the print side when the printer has 2 heads. Ie which esc sequence can i send to the printer. Something similar to what PosPrinter.ChangePrintSide from the .net sdk does
I don't have printer to test it so cannot suggest.
@@techsapphire Rephrasing my question a bit. How can i switch between Slip and Roll printing programatically? Roll printing works but it does not switch to Slip printing mode
Thanks anyways i was able to get the correct sequences
27 c 48 4 Slip
27 c 48 1 Roll
its working now
Nice tutorial. Do you have any suggestions about how to print to the slip output of the printer? (ribbon ink)
if you are talking about epson t220, yes I know. But it is little different from this code.
Hey! thanks for this tutorial, this can be used for other thermal printers? por example GHIA GTP801.
Yes, absolutely, for non english char you might need to experiment
Is this only for Epson Printer
Is it possbile to set both height and width for a text print, it seems that the last setting you apply is the active one, so either the text is high or wide, but not both??PrintByteArray = PrintExtensions.AddBytes(PrintByteArray, obj.CharSize.DoubleHeight8());
PrintByteArray = PrintExtensions.AddBytes(PrintByteArray, obj.CharSize.DoubleWidth8());In this example the text gets wide, but not high??
POS printer need to reset. So once formatted text is printed, you can add normal font too. obj.CharSize.Normal();
hi. What is the c# code for getting item name, price, quantity and total from the user and print in thermal printer. ?
you can take code covered in video and play around it.
hello, where do we find the library please
Kindly drop me mail at yogesh.mehla@gmail.com for source code
I tested the printer utility on Xamarin android and its works , I did some extra steps to print in a Bluetooth printer.
Please share source code. It will be help to community.
Does it work with Epson printers only?
Generally esc commands are common, but still I encounter where printer use diff codes.
Thank you for the code, it works perfect. Did you find a way to get feedback from the printer? Ideally, i would like to get a print response after each print command.
If you are using EPSON printer than use this video of mine, here I am using EPSON SDK, their we can get anything th-cam.com/video/5eN1Irt5ViQ/w-d-xo.html
Hi Is this supported for Command Apps C# DotNet Core Framework?
yes
thank you can i use it for asp core also? ...please code ?
share your email for code. Yes I provide commercial support for customization
@@techsapphire yaser.m.alhousen@gmail.com
Sent, kindly check your email. Note:
I also provide commercial support. Please contact if needed.
If you find this solution helpful than donate comfortable amount on papal to my email ID or link www.paypal.me/bimlamehla .
Donation is not mandatory, it is just a request to support free tutorials.
Could i use this code on an other brand of printer rather tnan EPSON ?
For POS, code may change according to printer brand and even with model.
After installing PritnerUitility & build code at .cs file
there are showing two error are show :-
Error 1) The type or namespace name 'PrinterUtility' could not be found (are you missing a using directive or an assembly reference?)
2) The primary reference "PrinterUtility, Version=1.0.2.0, Culture=neutral, processorArchitecture=x86" could not be resolved because it was built against the ".NETFramework,Version=v4.6.1" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5.1".
do you have the library out there for open sourced?
i was wondering how to connect to usb thermal printer?
yes, you can share your email. I will mail you source code used. You just need printer name to print.
@@techsapphire why dont you stored it inside github? it's more open sourced...
@@FgroupIndonesia this is my business model, I gain communication with person. If he needs any commercial support than it is easy to ask if communication is already open
is this work only epson printers ?
no most of esc printers
I have EPSON TM-T82 with me, connected to my notebook/laptop through USB port. But everytime I tried to print with the printer path "\\\\\\EPSON TM-T82 Receipt", I always get "System.IO.IOException: The specified path is invalid". Have you experienced this issue before?
try this video th-cam.com/video/MZlLy-zhL4Y/w-d-xo.html
An unhandled exception of type 'System.IO.IOException' occurred in mscorlib.dll
Additional information: Cannot create a file when that file already exists.
which file??
+1 :(
Hi,
Nice tutorial, I would like to know, is there a possibility to create a template and generate the receipt dynamically, for example in one template the store address is in the beginning and in the other template the address is at the last.... something like that??
Source code is available you can play with it.
Hi. thanks for tutorial. Could you help me. I am receiving error "System.IO.IOException: 'A device attached to the system is not functioning." while using printer utility with everycom printer. but its working fine when I pass direct print command .
Can't suggest without looking into it
@@techsapphire Printer Utility is not support alphanumeric character in barcode. Please suggest if there is any alternative.
@@MohitAggarwal8830 Hi Mohit, try below code:
public byte[] Code39(string code)
{
int height = 300;
var command = new List {0x1D, 0x68, (byte)height, 0x1D, 0x77,(byte)2,0x1D, 0x6B, 0x45, (byte)code.Length };
command.AddRange(code.ToCharArray().Select(x => (byte)x));
return command.ToArray();
}
@@techsapphire Thanks for reply. Can we write big string (len=20) into barcode. If no How much char we can write?. Currently when I try it skip the barcode data and print the rest slip.
Hi, will this work for a non epson printer too?
You can try generic printing solution. th-cam.com/video/osI7P1YdL3o/w-d-xo.html
Hi, I try your PrinterUtility NutGet work great for 32bits application. But my application build on 32 and 64bits on Visual Studio 2015. Do you have 64bit version? Can I have the source code or buy from you?
I am having issue setting printer path. I've set it as you have told to do in the tutorial but I'm getting error
"The Specified path is invalid"
Can you please help me out with this?
Kindly check th-cam.com/video/MZlLy-zhL4Y/w-d-xo.html
Does it support unicode font?
Try this tutorial, if you want to different fonts th-cam.com/video/osI7P1YdL3o/w-d-xo.html
Will it work if port will be ip adress of ip POS printer, not installed on Windows as a device? Like 192.168.1.10, for example?
yes it can work with network printer
I'm getting this exception, can tell me the work around for that ?
"An exception of type 'System.IO.IOException' occurred in mscorlib.dll but was not handled in user code
Additional information: The network name cannot be found."
It was working good but suddenly started giving this exception....
I'm working with ASP MVC5 WebProject.
If you face exception "Error the network name cannot be found" during printing. Than use below link to make work around.
www.techsapphire.in/index/pos_printer_error_the_network_name_cannot_be_found/0-184
Thanks For reply :)
please tell me where to use this code ?
if (File.Exists(".\\tmpPrint.print"))
File.Delete(".\\tmpPrint.print");
File.WriteAllBytes(".\\tmpPrint.print", BytesValue);
RawPrinterHelper.SendFileToPrinter("POS1", ".\\tmpPrint.print");
try
{
File.Delete(".\\tmpPrint.print");
}
catch
{
}
mailed you code to print without temp file.
Thanks Man. It Worked :)
You'r great man!!
I Appreciate that.
One thing more, If have some Clients of this application then this code can also work for them to print receipt from their computers ??
Mini Receipt Printer ARP-990KC I have this model thermal printer. Will this code works with that
no Idea, you need to try
@@techsapphire Sir thanks your code works with my printer. But I have a problem . I want two copies of receipts how I will do that
send print command 2 times. Its simple.
Sir it says that temp file is used by another process. That file is not deleting by your code
You can directly print file without temp file use this code
public static bool SendValueToPrinter(string szPrinterName, Byte[] BytesValue)
{
Byte[] bytes = BytesValue;
bool bSuccess = false;
// Your unmanaged pointer.
IntPtr pUnmanagedBytes = new IntPtr(0);
int nLength = 0;
nLength = Convert.ToInt32(bytes.Length);
// Read the contents of the file into the array.
// Allocate some unmanaged memory for those bytes.
pUnmanagedBytes = Marshal.AllocCoTaskMem(nLength);
// Copy the managed byte array into the unmanaged array.
Marshal.Copy(bytes, 0, pUnmanagedBytes, nLength);
// Send the unmanaged bytes to the printer.
bSuccess = SendBytesToPrinter(szPrinterName, pUnmanagedBytes, nLength);
// Free the unmanaged memory that you allocated earlier.
Marshal.FreeCoTaskMem(pUnmanagedBytes);
return bSuccess;
}
//RawPrinterHelper.SendValueToPrinter(PrinterName, BytesValue);
Note:RawPrinterHelper you can find online
Hi bro, how to connect to a epson ethernet type printer tm-t88v via c# (ip printer via c#)
any suggestions!
You can do by using address along with printer name.
Thanks bro... could u possibly share me the source code with ethernet type connection to rajkumarbtech4@gmail.com, it would be great if i could look into your code further.
Sent please check your email. Second version of video is also available.
Where you can learn to print directly from web browser. th-cam.com/video/MQMD4Pb7jzY/w-d-xo.html
Thanks for sharing such a helpful tutorial. The code works only for epson printer or any other thermal printer? Can you please share the code?
please share your email id.
@@techsapphire shahedexc@gmail.com
@@techsapphire does your code work for all thermal printer or only for epson?
Code mostly work for epson or printer support esc/pos commands. for Generic solution use printdocument
Superb Effort. Nicely done...
What if we have list more than 2 items? Should we use for loop? Or..?
yes. Their is no concept of data binding so you need loop.
techsapphire and paper will automaticaly adjust height size? Also what if printer is not epson? Thanks
yes POS printer auto increase height.
Good day, After deploying a Windows Form Application the printer gives error "tmpPrint.print is denied". Thank you
Wich way is the best for a better flexibility like font, color, text arrangement for printing, using a report like let's say Quick repor or the Microsoft's RawPrinterHelpler.cs class ? thank's for the tutorial.
Any other solution using an SDK is welcome.
Rawprinting is very simple and limited, you don't have much to customize there. But you can use POS for .NET specialy with EPSON, Zebra and Citizen printer. With POS for .NET you can do amazing things. I have already recorded on lecture on it, you can try this : th-cam.com/video/5eN1Irt5ViQ/w-d-xo.html
in printing did you setup the paper size sir?
That depends upon your page size it varies form 30mm to 80 mm so you have to adjust spacing as per that.
so when designing about the printing. I should know first what size of paper does POS printer used?
How did you figure out the settings for your Cut Page? Is it part of ESC/POS commands?
It is there Faracus in code.
And does this work on WPF? And how to open the cashier draw? Thanks
Yes it works in WPF like charm. I am mailing you code. In code print method seems to be problem with some developer so I made one more tutorial to have work around. I am mailing you link for that issue too.
Hello Mr. Yogesh, Thank you for this great tutorial. Is there a way to check if printing was successful? something like a callback
It is possible if you do status binding. th-cam.com/video/tYDezxaoNaQ/w-d-xo.html
Great Video... Just one question... Is it working for all the POS printers?
If you check technical specification for any POS printer. They will mention character set. If they are passing EPSON character set simulator than this will work. Also IBM too.
techsapphire thanks.. if it does not pass epson character set is there any other libraries like this that i can do this?
Usually most of the printer follows EPSON or IBM. So you need to check which it is. You can build for IBM if it doesn't works. These are character only so you can build one for your own.
I want to ask why doublewidth not working in epson tm-u220. can you give me a hint?
Sorry Filbert, I can't suggest on that. I can share my code. For that you need to check printer specification and document explaining character set which print needs.
Hi Sir
I am in the process of developing a pos system. Can I use the print code that you have mailed? I am sure I might need to make a few changes.
Regards
VENU
yes you can use. Play with code as you want.
Nice tutorial. Is this for EPSON printer only?
it works with almost all escpos printers, but commands might change. You can try this video, it is about generic printing for all printers. th-cam.com/video/osI7P1YdL3o/w-d-xo.html
wroking all printer
hi. thanks for tutorial. Could you help me to set paper size? I tried to google the documentation but failed. thanks
Hi Mohamad you need to test by printing as size of EPOS printer vary as per paper size. No predefined configuration comes. Share your email ID I will mail you project so that you can reference it,
Hi Yogesh, Thanks for quick reply. Kindly send the project to kharulli@gmail.com
Please help me open Cash drawer, which connected to Printer. Thanks!
I need beeping hex code for a ESC/POS. I couldn't find a working one. I need help so bad.
I can only share my solution my friend. I did it long time ago I don't have setup to try new things.
techsapphire thanks anyway. I'm fucked up I think
sorry man for not being more help
pls advise on how to get the printer path from the local system. Print method fails for me
use this tutorial to fix local printer issue.
th-cam.com/video/MZlLy-zhL4Y/w-d-xo.html
Great video ... I'm trying to use a solution in linux with a local printer how do I? Do you have an example of how to call this printer being shared? I also saw rawPrinterHelper but winspol.drv is unique to windows. If you have any tips .... Thanks
Sorry I haven't worked o linux solution.
But do you have any suggestions for me to be able to perform this process on linux? If you have something, it will be of great help. Thank you
Does this code work for all printers in the market or just epson ??
It work with all POS printers. As basic marking for all text printers are same. But only POS for normal printer you need to use crystal report or RDLC type reporting standards.
thanks for the insights :)
Hello sir,
Every thing is working fine , is it possible to change the printing language to hindi or else any indian regional language.I m currently using epson thermal tmt82-printer.
Below code worked for Chinese so try to find encoding for Hindi:
var encoding = Encoding.GetEncoding(936);
// convert the text into a byte array
byte[] source = Encoding.Unicode.GetBytes("百順藥房");
Excelent video, this only will work with epson printers??? and can u share the source code please... thanks in advance
Kindly share your email, it will work with most of them.
Hello. i have a problem with QrCode. I can't pritn it. it prints ???????. can you help please?
Hi Maria, you need to check if your printer support qr code. My code is mainly tested on epson printer though it works on all esc/pos device.
@@techsapphire Thanks for your response. My thermal printer is GPrinter and i've tested it only to print a Png with Qrcode. If it doesn't support Qrcode i can't use PrinterUtility package?
If it doesn't support QR code than you can use some third party dll to generate QR code in image and use that image to print via printer. If your printer is not supporting, you can't do any thing other than that.
If my solution help you, you can support me by doing some donation on link: paypal.me/yogeshmehla
Donation help in keeping free community work.
Sent please check your email. Second version of video is also available.
Where you can learn print using POS for .NET on epson printer : th-cam.com/video/5eN1Irt5ViQ/w-d-xo.html
Where you can learn to print directly from web browser. th-cam.com/video/MQMD4Pb7jzY/w-d-xo.html
Dear sir, thank u pls where can i insert this code and print when after adding what a client want to buy. am still new to this. thank u sir
Hi Emmy, code you need to modify as per your requirement. If you need I provide commercial support, you can reach me on skype yogesh.mehla@live.com
@@techsapphire ok sir thank u
Tharmal printer recept process?????
please elaborate, unable to get your point.
Sir plz send me this project
ambrishmishra.tz@gmail.com
Sent please check your email. Second version of video is also available.
Where you can learn print using POS for .NET on epson printer : th-cam.com/video/5eN1Irt5ViQ/w-d-xo.html
Where you can learn to print directly from web browser. th-cam.com/video/MQMD4Pb7jzY/w-d-xo.html
I am making a software and I need to print on the client side since it is from an asp.net web portal c #, and the client will enter a web page published on the internet, not on the intranet, is this possible?
Hi Hector second version of this video is also available.
Where you can learn to print directly from web browser. th-cam.com/video/MQMD4Pb7jzY/w-d-xo.html
this is my code
protected void Page_Load(object sender, EventArgs e)
{
PrinterUtility.EscPosEpsonCommands.EscPosEpson obj = new PrinterUtility.EscPosEpsonCommands.EscPosEpson();
System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath("/Images/TechComLogoMovil.jpg"));
byte[] BytesValue;
using (MemoryStream ms = new MemoryStream())
{
img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
BytesValue = ms.ToArray();
}
BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator());
BytesValue = PrintExtensions.AddBytes(BytesValue, obj.CharSize.DoubleWidth6());
BytesValue = PrintExtensions.AddBytes(BytesValue, obj.FontSelect.FontA());
BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Center());
BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Title
"));
BytesValue = PrintExtensions.AddBytes(BytesValue, obj.CharSize.DoubleWidth4());
BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Sub Title
"));
BytesValue = PrintExtensions.AddBytes(BytesValue, obj.CharSize.Nomarl());
BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator());
BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Invoice
"));
BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Left());
BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Invoice No. : 123
"));
BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Date. : 08/04/2018
"));
BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Itm Qty Net Total
"));
BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator());
BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-40}{1,6}{2,9}{3,9:N2}
", "item1", 12, 11, 144.00));
BytesValue = PrintExtensions.AddBytes(BytesValue, string.Format("{0,-40}{1,6}{2,9}{3,9:N2}
", "item2", 10, 15, 184.00));
BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Right());
BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator());
BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("Total
"));
BytesValue = PrintExtensions.AddBytes(BytesValue, Encoding.ASCII.GetBytes("288.00
"));
BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Separator());
BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Lf());
BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Left());
BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Center());
//BytesValue = PrintExtensions.AddBytes(BytesValue, obj.BarCode.Code128("12345"));
//BytesValue = PrintExtensions.AddBytes(BytesValue, obj.QrCode.Print("12345",PrinterUtility.Enums.QrCodeSize.Medio));
BytesValue = PrintExtensions.AddBytes(BytesValue, "------- Gracias por visitarnos ------");
BytesValue = PrintExtensions.AddBytes(BytesValue, obj.Alignment.Left());
BytesValue = PrintExtensions.AddBytes(BytesValue, CutPage());
// PrinterUtility.PrintExtensions.Print(BytesValue, @"\\LOCALHOST\XP");
Context.Response.BinaryWrite(BytesValue);
}
public Byte[] CutPage()
{
List oby = new List();
oby.Add(Convert.ToByte(Convert.ToChar(0x1D)));
oby.Add(Convert.ToByte('V'));
oby.Add((byte)66);
oby.Add((byte)3);
return oby.ToArray();
}
but when I send the bytes to context.response.binarywrite it just shows me trash, do you have an email to send you the sample project and what it shows me?
Sure share me your email id please
hector.floresj@gmail.com
sent please check your email
Hello Sir, I could manage to print out but stuck at its not cut out after finishing the print. I have select 'No Cash Drawer' in Printer Properties. Please help me. Waiting for your kind reply. Best Regards
Hi tech Saphire... I was using your way of printing for last one year and is very useful..but can you please advice me how can i add a line of arabic string in the print..i tried to do it like below.. bytes = PrintExtensions.AddBytes(bytes, Encoding.ASCII.GetBytes("Tax Invoice
"));
bytes = PrintExtensions.AddBytes(bytes, System.Text.Encoding.Unicode.GetBytes("فاتورة ضريبية"));
bytes = PrintExtensions.AddBytes(bytes, System.Text.Encoding.UTF32.GetBytes("فاتورة ضريبية"));
you can try something like this : var encoding = Encoding.GetEncoding(936);
// convert the text into a byte array
byte[] source = Encoding.Unicode.GetBytes("百順藥房");
Or if you are using EPSON printer check my this tutorial :POS for .NET on epson printer : th-cam.com/video/5eN1Irt5ViQ/w-d-xo.html
@@techsapphire sorry iam not using Epson printer ...I have to go with your first option ..but can you please confirm whether there is a typo because I cannot see u used encoding ...but used Normal Encoding
Hi. Im getting access to the path is denied? How to fix? Also can I use default printer
access is denied for which path ? You need to pass printer name
I think this link provides you solution to it th-cam.com/video/MZlLy-zhL4Y/w-d-xo.html
is this code can work on sprt sp-pos88v ?
You can test, if it doesn't work you can try print document.
HI, how can initialize var BytesValue without GetLogo(); ??
you can initialize to bytesarray.
Hi Sir, seems the barcode only accept number, not any letter. Any idea?
All the fonts looks similar, is there a way to add our own fonts?
for that u need to use SDK not generic text print
techsapphire can you recommend any sdk? Help really appreciated
sdk k printer specific. For Epson use epsont sdk for brother use brother. So no preference in that. Usually POS receipts are never customized with font, max logo's are used. Their purpose is to print fast only.
Does it support the Arabic characters ?
Below code worked for Chinese so try to find encoding for Arabic:
var encoding = Encoding.GetEncoding(936);
// convert the text into a byte array
byte[] source = Encoding.Unicode.GetBytes("百順藥房");
// convert that byte array to the new codepage.
byte[] converted = Encoding.Convert(Encoding.Unicode, encoding, source);
// Perform the conversion from one encoding to the other.
BytesValue = PrintExtensions.AddBytes(BytesValue, converted );
try with this Encoding.GetEncoding("windows-1256")
Thank you for your reply, i will try it.
Hi i am getting this error,
PrintExtensions.Print(BytesValue, DesktopPrintApp.Properties.Settings.Default.PrinterPath);
Error CS0029 Cannot implicitly convert type 'void' to 'byte[]'
Send me your email ID I will ping you example code I used.
is there any way for it to work from a web application, I worked locally, but I need it to work from the web client, Thank you if you can help me.
You can create chrome or firefox extn. Than u can print using that. Directly you can't do.
Hi Yogesh dear receipt is not printing to my printer i am using 3 inch thermal printer when i press print button i get an error the file is already exist you cannot print
hi, yogesh. your code is working very fine. Thanks for such an example video? what if i wanted to print same from my web application???? can you help me out for that ???
sent you mail
@@techsapphire thank you so much. Glad that you replied so quickly.
i am getting this error Could not load file or assembly 'PrinterUtility, Version=1.0.2.0
kindly check shared source code
Thanks for sharing. Do you have the source code for this example?
share your email or mail me at yogesh.mehla@gmail.com
Hi, I can't seem to find the link to the code, can you pls share the link?
Kindly share your email.
@@techsapphire dev.notify5@gmail.com
When I print the logo, it comes out with white lines. How can i fix it.
Don't use big image, resize it to small, also use black and white image for logo.
IT works Like a charm Thanks Very much , But Cash Drawer connected to Reciept Printer not Opening (not on all cases) .Can you guess what may be the issue so that we can update it to this?
Sorry I figured it Out add
string eClear = ('' + "@");
string eDrawer = (eClear + ('' + ("p" + ('\0' + ".}"))));
BytesValue = PrintExtensions.AddBytes(BytesValue, eDrawer); after rintExtensions.AddBytes(BytesValue, CutPage());
Glad my tutorial helped you :)
please send me the full source code to rajeshraju002@gmail.com
sent please check your email.
Please help me open cash drawer, thank you!
i want to pick the items from datagridview how can i go about that? i am coding in vb.net
code directly print text you supply. That's on you. You can supply from gridview or text box doesn't matter.
Hello, I would like to obtain the source code of this example, I can not find it on your site. Thanks for the Video.
Please share your email id
Hello I would like to know where I can find the package documentation, or if you can send me the video code thanks
Send your email ID I can share code. You can re engineer code by yourself too.
obj.Guilhotina.CutFull();
this is the method for cutting page. Good video though, thanks.
I am getting extra spaces below the barcode and can't add the text of barcode just below the barcode like it has everywhere, can you solve that?
Hi Tiring, sorry I don't support dev queries, as for that you need to play with code. If you need commercial support, than that is separate.
How to print in asp.net mvc side client?
Please check this solution, this will help you th-cam.com/video/MQMD4Pb7jzY/w-d-xo.html
how to check printer availability?
Sorry I don't have sample code for that. You need to google it ourself.
thanku bro please email me this code b013.052@gmail.com
sent please check your email.
Thanku so much :)
Hi.. I am getting error while printing alphanumeric character in barcode
yes it will give error. In general in stores you will never see alpha numeric barcode. Item number are always character. So common POS don't support alpha numeric barcodes.
techsapphire Thanks... But is there
any alternative ? And one more question auto cut receipt how to implement that. One you had given
Not working. I tested same on Epson and TVS 2 different model everything is working perfectly except alphanumeric barcode and auto cut
yes alternative is available but for that you have to use POSfornet SDK using EPSON api's. Which I never used. Auto cut code is available in code I shared.
techsapphire hi.. Is it possible to build in lower version of. Net framework. It's not working in 2.0
can't say. You can decompile library with jetbrains and try to compile it again with 2.0 framework. And see if that works.
i have to print receipt on thermal printer for a pharmacy. kindly send me this code plz
please share your email id
@@techsapphire malikarslan160572@gmail.com
Actually I have to print my data table ( which contains item , qty and subtotal ) so where and how can i add my data table in it. Plz guide me.
I have mailed you code. Please customize as per you need. I provide commercial support if needed.
@@techsapphire Hai I need to prind data in a4 sheet but multiple of items data in multiple particion box's in a4 sheet 7013338512 my contact number
Raihaan.october6@gmail.com
My mail ID please help me
Hello, its posible to get that code?
sent please check your email.
THANKS!!!!!!
Hello, Could you please attach the code in the description?
share your email, I will mail code to you.
May I ask you for code or example ? thank you
Please share your email id
techsapphire johnyor@gmail.com
sent please check your email inbox
Hello Mr. Yogesh, thanks for this tutorial. Can I have the source code of this one, please ?
Kindly share your email or mail me at yogesh.mehla@gmail.com
Thank you so much for this tutorial 👍👍
you are welcome :)
techsapphire if i will used other brand of termal printer, can i use PrinterUtility also?
Hi, all printer from all brand supporting EPSON character set are supported.
Thanks 😊
@@techsapphire
Could you send the source code to me ??
Yosef200200.yu@gmail.com
hello sir, can I use this in vb.net?
yes you can use any .net supported language
I am having some issues also. May I get the sourcecode?
jkwilkinson99@juno.com
Sent please check your email. Second version of video is also available.
Where you can learn print using POS for .NET on epson printer : th-cam.com/video/5eN1Irt5ViQ/w-d-xo.html
Where you can learn to print directly from web browser. th-cam.com/video/MQMD4Pb7jzY/w-d-xo.html
How to save the document?
you cannot save esc pos command print as preview
Excellent video. I am new in c#.
Can I have the source code of this one please?
Thank You
Kindly mail me at yogesh.mehla@gmail.com for source code or leave your email in comment.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using PrinterUtility;
namespace printertesttvs
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
PrinterSettings printerSettings = new PrinterSettings();
printerSettings.PrinterName = "YourPrinterName";
printerSettings.DefaultPageSettings.PaperSize = new PaperSize("Custom", 300, 150);
// Create a PrintDocument object and assign the printer settings to it
PrintDocument printDoc = new PrintDocument();
printDoc.PrinterSettings = printerSettings;
// Add a PrintPage event handler to the PrintDocument object
printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
// Call the Print method on the PrintDocument object to print the document
printDoc.Print();
}
void PrintPage(object sender, PrintPageEventArgs e)
{
// Define the font and brush for the text
Font font = new Font("Arial", 10);
Brush brush = Brushes.Black;
// Define the text to be printed
string headerText = "કર્ણાવતી એગ્રીકલ્ચર માર્કેટ યાર્ડ";
string dateText = "Date: 3/23/2023";
string item1Text = "Item 1: 10.00";
string item2Text = "Item 2: 20.00";
string totalText = "Total: 30.00";
// Define the position and spacing for the text
float xPos = 0;
float yPos = 0;
float ySpacing = 20;
// Draw the header text
e.Graphics.DrawString(headerText, font, brush, xPos, yPos);
yPos += ySpacing;
// Draw the date text
e.Graphics.DrawString(dateText, font, brush, xPos, yPos);
yPos += ySpacing;
// Draw the item 1 text
e.Graphics.DrawString(item1Text, font, brush, xPos, yPos);
yPos += ySpacing;
// Draw the item 2 text
e.Graphics.DrawString(item2Text, font, brush, xPos, yPos);
yPos += ySpacing;
// Draw the total text
e.Graphics.DrawString(totalText, font, brush, xPos, yPos);
yPos += ySpacing;
}
}
}
Thank you so much for the tutorial.can u please share code sir.
Thanku 😊
Sent, kindly check your email. Note:
I also provide commercial support. Please contact me if needed.
If you find this solution helpful than donate comfortable amount on papal to my email ID or link www.paypal.me/bimlamehla.
Donation is not mandatory, it is just a request to support free tutorials.
Thank you for the tutorial. Glad that you recommended this one to me .... Can I have the source code of this one please ?
Thank again for the great job you're doing.
Sent, kindly check your email. Other Tutorials:
POS printing using POS for .NET. th-cam.com/video/5eN1Irt5ViQ/w-d-xo.html
Also if you face exception "Error the network name cannot be found" during printing. Than use below link to make work around.
www.techsapphire.in/index/pos_printer_error_the_network_name_cannot_be_found/0-184
For text formatting please refer this lecture:
th-cam.com/video/3IcJWpw6wL8/w-d-xo.html
Note:I also provide commercial support. Please contact if needed.If you find this solution helpful than donate comfortable amount on papal to my email ID or link www.paypal.me/bimlamehla.Donation is not mandatory is it just request to support free tutorials.Video tutorial to support all printer brand for POS print: th-cam.com/video/osI7P1YdL3o/w-d-xo.html
Can you share the project code that is available in Video?
share your email id
@@techsapphire pavan14323@gmail.com
Can you share me the code Today
sent please check
Thanku for video. can you share code. will be very thankufull
kindly check video description.
Where i kan find the printerutility file?
Link please
Thanks
You can install printer utility using nuget packages. Or share your email ID I will mail you source code, it contains printerUtility dll.
Thank you for the tutorial. I'm having trouble finding documentation about this library. Can you send me the source code please? It would help a lot... Thank you
Kindly share your email
@@sweaterhijauzzz sent kindly check your email. Note:
I also provide commercial support. Please contact if needed.
If you find this solution helpful than donate comfortable amount on papal to my email ID or link www.paypal.me/bimlamehla .
Donation is not mandatory, it is just a request to support free tutorials.
Hiii,I want print format as text boxes usng c#...can anyone will help me,its urgent...thanks
formatting is not fixed you have to hit and try as it depend upon page size supported by printer.
hello, can i please have a copy of the source code? am having trouble with a project like this. thanks a lot for your video!
send mail at yogesh.mehla@gmail.com
Hi... it's a very good tutorial.. how can I get the source code? would you mind sharing it with me? Thank you
Share your email