I'm new to php and made a code that takes some information from a database and converts it into code128 barcode. Echoing it to the page is no problem:
$finalvar = '<p>'.bar128(stripcslashes($row['Flowers'])).'</p>';
echo $finalvar;
So far so good. I now want to print this barcode on a network printer and use this:
$port = "9100";
$host = "10.64.33.33";
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket === false) {
echo "socket_create() failed, reason: " . socket_strerror(socket_last_error ()) . "
";
} else {
echo "OK.
";
}
$result = socket_connect($socket, $host, $port);
if ($result === false) {
echo "socket_connect() failed.
Reason: ($result) " . socket_strerror (socket_last_error($socket)) . "
";
} else {
echo "OK.
";
}
socket_write($socket, $finalvar);
socket_close($socket);
The printing works perfectly but instead of printing the barcode like in the picture, the paper looks like this:
<p><table cellpadding=0 cellspacing=0><tr><td><div class="128"
style"border-"
I think this is probably more of a formatting thing, but I didn't find anything that worked.
How can I print $finalvar
like in the picture shown above?