PHP打印机不在新行上打印

时间:2018-01-15 00:55:48

标签: php printing thermal-printer

我正在将 80 mm热敏打印机附加到我的Windows服务器上,它工作得很好但是当文本长度超过页面宽度时,文本的其余部分会消失而不是移动到下一个文本自动排队。这是我的代码

$handle = printer_open("POS"); 
printer_set_option($handle, PRINTER_PAPER_FORMAT, PRINTER_FORMAT_CUSTOM);
printer_set_option($handle, PRINTER_PAPER_WIDTH, "80");
printer_set_option($handle, PRINTER_MODE, "RAW");
printer_start_doc($handle, "My Document");
printer_start_page($handle);
$font = printer_create_font("Arial", 40, 30, 400, false, false, false, 0);
printer_select_font($handle, $font);
printer_draw_text($handle, $lipsum, 10, 10);
printer_delete_font($font);
printer_end_page($handle);
printer_end_doc($handle);
printer_close($handle);

1 个答案:

答案 0 :(得分:0)

try this: 

$handle = printer_open("POS"); 
printer_set_option($handle, PRINTER_PAPER_FORMAT, PRINTER_FORMAT_CUSTOM);
printer_set_option($handle, PRINTER_PAPER_WIDTH, "80");
printer_set_option($handle, PRINTER_MODE, "RAW");
printer_start_doc($handle, "My Document");
printer_start_page($handle);
$font = printer_create_font("Arial", 40, 30, 400, false, false, false, 0);
printer_select_font($handle, $font);



printer_draw_text($handle, 'TEST 1', 10, 10);
printer_draw_text($handle, 'TEST 2', 10, 40);
printer_draw_text($handle, 'TEST 3', 10, 70);



printer_delete_font($font);
printer_end_page($handle);
printer_end_doc($handle);
printer_close($handle);