David David - 5 months ago 100x
PHP Question

PHP adjusting font size printing to network thermal printer

I have the following code which works like a charm to print from PHP to my epson thermal printer. we use it to print customer orders in the office when they checkout on the website. I want to change the font size to make it look like a more genuine recipe.

Here is an example of the code i use:

$texttoprint = "RECIPT TEXT \n NEXT LINE \n MORE STUFF";
$texttoprint = stripslashes($texttoprint);

$fp = fsockopen("", 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");

If you can tell me how I can change the font size of a particulare line that would be amazing. thanks

From what I have read the 012/012 are ESC/p codes, here is a link to the manual -

But I dont understand how to apply this:



Just for users who may need to know here is what you need, I found the answers in a python lib (http://code.google.com/p/python-escpos/downloads/list)

here is a list of how to do the ESC codes (found it in a python lib) http://sheepy121.webhost4life.com/ESC.txt

Here is the document for all ESC codes http://files.support.epson.com/pdf/general/escp2ref.pdf

and here is the code to use PHP printing to local Thermal Printer, does not work without networkname.

Happy printing


This is more a task for you to understand the manual. Not sure how you have done the rest before.

On page C3 of the manual you get a command overview. ESC E is the command to select a bold font (details on page C110). You want to change the font size so you need ESC P, ESC M or ESC g.

ESC stands for the escape character, decimal index 27 in ASCII table or hex 1B or octal 33. Place "\033P" within your string to try out as that is the way you include a special char with octal code in PHP String manual.