1

I want to print data on a label.

I created a ZPL template file and in my application i read that template file, look up a specific string, replace that string with data from my application and then send it to the printer.

When I trigger the printer over the webserver to print the template, everything is fine.

But when i trigger the print with my application, i get the desired label first AND then he prints a second label right after that, that only contains a few equally sized black bars on it and i dont know why.

Printing result when triggered from application

This is the code that connects to my printer, interprets the label template and sends the commands for printing to the printer:

public void PrintLabel(string TemplateFile, LabelContent cont)
{
    logger.Info("Trying to print label at printer " + set.IP + " ...");

    string content;

    // read template
    content = File.ReadAllText(TemplateFile);

    // loop over all attributes 
    foreach (var prop in cont.GetType().GetProperties())
    {
        var srch = "*" + prop.Name + "*";
        var rplc = prop.GetValue(cont, null).ToString();          // simple datatype 

        logger.Trace("Trying to find/replace [" + srch + "] with [" + rplc + "]");

        content = content.Replace(srch, rplc);
    }

    var lines = content.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

    // print it

    var eth = new TSCSDK.ethernet();
    if (eth.openport(set.IP, set.Port))
    {
        foreach (var l in lines)
        {
            logger.Debug("[" + set.IP + "]: prn.line: " + l);
            eth.sendcommand(l);
        }
        eth.printlabel("1", "1");
        eth.closeport();
        logger.Info("[" + set.IP + "]: Done. Label printed");
    }
    else
    {
        throw new Exception("[" + set.IP + "]: Error opening tcp connection to printer");
    }
}
2
  • Please post the actual zpl being sent to the printer. It is the only way to debug the issue. Commented 2 days ago
  • @MarkWarren, I resolved it by rewriting the template file in TSCs own language TSPL instead of using ZPL. Commented yesterday

1 Answer 1

0

I resolved the issue by rewriting the ZPL template file in TSCs own language TSPL. The code for the printing sequence has not been adapted.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.