0

I am trying to directly print in thermal print paper, using PHP. Its printing. But I am not able to set position of the text..

In the manual http://docs.php.net/manual/da/function.printer-draw-text.php, they have mentioned

 void printer_draw_text ( resource $printer_handle , string $text , int $x , int $y )

where

  • x is the x coordinate of the position.
  • y is the y coordinate of the position.

I have tried to provide the position in mm (not success), pixel (not success).

I am not able to know, what is the measurement unit used here.

My code

$printer = printer_open($printerName);
printer_set_option($printer, PRINTER_PAPER_FORMAT, PRINTER_FORMAT_CUSTOM);
printer_set_option($printer, PRINTER_PAPER_WIDTH,   151);
printer_set_option($printer, PRINTER_PAPER_LENGTH,  75);
printer_set_option($printer, PRINTER_MODE,          "RAW");
printer_set_option($printer, PRINTER_ORIENTATION,   PRINTER_ORIENTATION_PORTRAIT );
printer_set_option($printer, PRINTER_TEXT_COLOR,   "000000" );
printer_set_option($handle, PRINTER_TEXT_ALIGN, PRINTER_TA_LEFT);  
printer_start_doc($printer, "My Document");    
printer_start_page($printer);
printer_draw_text($printer, "Text", 234, 75); // I need to print in (x,y) = (62mm , 20mm ) position
printer_end_page($printer); 
printer_end_doc($printer);
printer_close($printer);

Please help. Thank you in advance.

Dinesh Patra
  • 1,125
  • 12
  • 23
  • I have never used this, but why not try to set the `PRINTER_RESOLUTION_X` and `PRINTER_RESOLUTION_Y` and use that as the unit? From what I can see you might need to use much higher numbers for (x,y) coordinates than you think. – KIKO Software Jan 27 '18 at 10:50
  • I tried with printer_set_option($printer, PRINTER_RESOLUTION_X, 1); printer_set_option($printer, PRINTER_RESOLUTION_Y, 1); . But still same position. – Dinesh Patra Jan 27 '18 at 11:04

0 Answers0