so I am printing to a networked thermal printer in the office from our webserver (also in the office) so clients can place orders on the website and they pop out on the sales dept desk. Here is the code I use and it works very well. However when it comes to printing the items on the slip I want the item text align center and the price text align right, but it wont let me do it (cos its the same line I think) so how can I say new line (\n) but then reverse it. I tried \033F and \F already but no luck. any advise?
$texttoprint = "";
//center,bold,underline - close underline, close bold
$texttoprint .= "\x1b\x61\x01\x1b\x45\x01\x1b\x2d\x02\x1b\x21\x10\x1b\x21\x20 Company name \x1b\x2d\x00\x1b\x45\x00";
$texttoprint .= "\n";
//normal text
$texttoprint .= "\x1b\x21\x00 Address";
$texttoprint .= "\n";
//normal text
$texttoprint .= "\x1b\x21\x00 Adress2";
$texttoprint .= "\n";
//normal text
$texttoprint .= "\x1b\x21\x00 Tel : ...";
$texttoprint .= "\n";
$texttoprint .= "\n";
//normal text
$texttoprint .= "\x1b\x21\x00 Website order";
$texttoprint .= "\n";
$texttoprint .= "\n";
//center,bold,underline - close underline, close bold
$texttoprint .= "\x1b\x61\x01\x1b\x45\x01\x1b\x2d\x02\x1b\x21\x10\x1b\x21\x20 Tax Invoice \x1b\x2d\x00\x1b\x45\x00";
$texttoprint .= "\n";
$texttoprint .= "\n";
//align center, normal text
$texttoprint .= "\x1b\x61\x01\x1b\x21\x00 1x product";
//align right, normal text
$texttoprint .= "\x1b\x61\x02\x1b\x21\x00 $200";
...
As you can see here the last 2 are on the same line and I am trying to justify the product center and price right. they both end up center, if I put a /n between then they justify correctly just on the wrong lines.
$texttoprint = stripslashes($texttoprint);
$fp = fsockopen("192.168.0.168", 9100, $errno, $errstr, 10);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
fwrite($fp, "\033\100");
$out = $texttoprint . "\r\n";
fwrite($fp, $out);
fwrite($fp, "\012\012\012\012\012\012\012\012\012\033\151\010\004\001");
fclose($fp);
}