Barcode Printing Sato LM408e c#

2.2k views Asked by At

I'm making an application that produce barcode labels. I'm using Sato LM408e thermal printer. In order to print I'm using sbpl command. I got no error, but the printer doesn't print anything. Is there anyone who has experience printing with sato barcode printer? lm 408e to be more specific

My Code:

PrintDialog printDia = new PrintDialog();
printDia.PrinterSettings = new PrinterSettings();
DialogResult result = printDia.ShowDialog();
StringBuilder sb = new StringBuilder();
        sb.AppendLine("<STX><ESC>A");
        sb.AppendLine("<ESC>H0001<ESC>V0001<ESC>XM45676567");
        sb.AppendLine("<ESC>Q1");
        sb.AppendLine("<ESC>Z<ETX>")
String output = sb.ToString().Replace("<ESC>", ((char)27).ToString());
        output.Replace("<STX>",((char)2).ToString());
        output.Replace("<ETX>", ((char)3).ToString());
if (result == DialogResult.OK)
        {
            RawPrinterHelper.SendStringToPrinter(printDia.PrinterSettings.PrinterName, output);
        }

My string output:

output

3

There are 3 answers

0
Magnus Wibeck On

String.Replace returns a new instance, it does not modify the original string.

((char)3).ToString() is "3", you need "\x3".

So, try this:

String output = sb.ToString().Replace("<ESC>", "\x1b").Replace("<STX>","\x2").Replace("<ETX>", "\x3");
0
TreHoffman On

I use CL4NX, CL408e, and GL408e label printers except I print labels that are in Non-Standard SBPL (but it's not that much different than standard).

Since nothing is happening, the first thing I would check is that the printer is online and connected properly. You can use the SATO All-In-One Tool to help you with this. Is the printer connected directly to the machine you're trying to print from or is it a network share?

I would also look at your code, as I'm not sure you need the STX and ETX with SBPL by default. Try printing without them and see if it makes a difference.

Lastly, I would check your Dipswitch settings (LM408e Manual). I've had problems like yours before where it took me a while to realize that the Dipswitch settings weren't as they should be.

0
Gubbaset On

You cannot send ESC (hex 1B) or STX (hex 02) in plain text. SBPL uses binary data. Try this:

sb.AppendLine("\02\1bA");

... and so on.