RamyTalal / Label-Printer

Easily print labels with a Brother label printer.
MIT License
65 stars 22 forks source link

I can't print barcode with QL810W #29

Open IvanPagan opened 2 years ago

IvanPagan commented 2 years ago

Hi, I'm trying to print barcodes but allways have the same, a commands string, For example I got "itrhwzBCA04220007510\" trying to print CA04220007510 barcode with code128.

        $stream = stream_socket_client('tcp://'.$printer_ip.':9100', $errorNumber, $errorString);

        $printer = new Printer(new Template(2, $stream));

        $printer->addCommand(new Command\Barcode($product->reference, 29, Command\Barcode::WIDTH_MEDIUM, 'CODE39', true, 2.5));

        $printer->printLabel();

        fclose($stream);

Whats happend? Ineed to do something more?

Thanks

ntaylor-86 commented 2 years ago

Hi @IvanPagan,

When using templates. You add the object you want to manipulate in your template and give it a unique Object Name in the P-touch Editor software.

Then you can use the ObjectCommand interface like so to change the values in your template,

$printer = new Printer(new Template(5, $stream)); // Template #5 stored on the printer

$printer->addCommand(new Command\ObjectCommand('barcode', "123456"));

$printer->addCommand(new Command\ObjectCommand('text', "IvanPagan"));

$printer->printLabel();

label_printer_issue_29