Domanda

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("192.168.192.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);
}

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 - http://files.support.epson.com/pdf/general/escp2ref.pdf

But I dont understand how to apply this:

ESC E - SELECT BOLD FONT - C110

Answer:

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

È stato utile?

Soluzione

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.

Altri suggerimenti

use php print option. you can change font size and font family also..

here the sample php code...

header('Content-Type: text/plain; charset=UTF-8');

$printer = "\\\\BALA\\EPSON TM-T88IV Receipt"; 

$handle = printer_open($printer);
printer_start_doc($handle,"Testpage");
printer_start_page($handle);
$font = printer_create_font("Arial", 20, 10, 700, false, false, false, 0);
$pen = printer_create_pen(PRINTER_PEN_DOT, 1, "000000");
printer_select_pen($handle, $pen);
printer_select_font($handle, $font);
printer_draw_text($handle, "welcome", 10, 10);

printer_delete_font($font);
printer_delete_pen($pen);
printer_end_page($handle);
printer_end_doc($handle);
printer_close($handle);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top