-2

i want to display barcode with epson tm-t82 thermal printer.im using php to create receipt.

but until now it has always failed.

below is the php script that I use to print the contents of the receipt details.

<?php

$mprint .= chr(27).chr(97).chr(49); // align center

$mprint .= "Proof of Handover of Dirty Linen\r\n";

$mprint .= " \r\n";

$mprint .= "Thank You\r\n"; 

$mprint .= chr(27).chr(100).chr(5); // enter 5 lines

exec('echo "'.$mprint.'" > /tmp/linenshrmstruk.tmpctk');

exec('lpr -H 127.0.0.0' -P printername -l /tmp/linenshrmstruk.tmpctk');

?>

what I want is, to show the barcode at the end of the line before print it out.but I still didn't find exactly how to do it.It would be of great help if some one could assist me with a solution with those script above. please help.

Rafee
  • 3,975
  • 8
  • 58
  • 88

1 Answers1

0

This line is broken with an extra apostrophe:

exec('lpr -H 127.0.0.0' -P printername -l /tmp/linenshrmstruk.tmpctk');

Should likely be:

exec('lpr -H 127.0.0.0 -P printername -l /tmp/linenshrmstruk.tmpctk');
Patrick Moore
  • 13,251
  • 5
  • 38
  • 63
  • Yes sir. Thank you for the advice. but, can you tell me, which php script to display the barcode in the above script? – Piere Risnayadi Nov 12 '20 at 04:40
  • @PiereRisnayadi most barcodes are generated as image format. I don't know for your exact printer, what is the control codes to send image data, but you would need to know this first. Then, use some PHP to generate barcode image. Then, wrap this image with the correct printer control codes by concatenating this into your $mprint variable. Here is one example to generate the barcode image: https://github.com/kreativekorp/barcode – Patrick Moore Nov 13 '20 at 04:29