php printer_draw_text function position measurement unit

262 Views Asked by At

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.

0

There are 0 best solutions below