抱歉我的BAD英语
我的问题是,如何使用printer_draw_text
函数打印出长字符串? (参见示例) Epson Billing Printer 。
所有示例都有效(来源:http://www.php.net/manual/en/book.printer.php)
但是当我想要组合一个Logo.bmp +一长串文字时,它只打印出徽标和一行刺痛:
示例:
<?php
# DEMO PRINTER
//http://fr.php.net/manual/en/function.printer-write.php
/*
$_SESSION['PrintBuffer']=''; //printer buffer
print_sub_1();
print_sub_2();
print_sub_3();
$_SESSION['PrintBuffer']
*/
$Printer_name = $_GET['Printer'];
$text = $_GET['value'];
$text = str_replace( '/r/n',PHP_EOL, $text);
$handle = printer_open($Printer_name); // Open Pritner by Name
printer_set_option($handle, PRINTER_MODE, "raw");
//printer_set_option($handle, PRINTER_TEXT_ALIGN, PRINTER_TA_LEFT);
printer_start_doc($handle, "Print"); // Name Document
printer_start_page($handle); // Start Logo
printer_draw_bmp($handle, "c:\\logo.bmp", 60, 0); // Logo Dir, lenght H , With V
printer_end_page($handle); // End Logo
printer_start_page($handle);
printer_draw_text($handle, $text,1,1);
printer_end_page($handle); //
printer_end_doc($handle); // Close document
printer_close($handle); // Close Pritner
?>
输出示例:
Logo.bmp
测试.... //但只有一行:(
printer_write($ handle,“要打印的文本”);工作!!!它打印出来的字符串+ \ r \ n但是它在新纸上打印出徽标:(
需要的例子
Logo&lt; - here
1 x product&lt; - Long String 1 x product \ r \ n(工作printer_write函数) 2 x产品 ECR。
printer_draw_text($handle, $text,1,1);
仅打印1 x产品2 x
答案 0 :(得分:1)
这里通过工作实例 (* + Print.Dll和Win 7 OS)
<?php
# DEMO PRINTER
//http://fr.php.net/manual/en/function.printer-write.php
/*
$_SESSION['PrintBuffer']=''; //printer buffer
print_sub_1();
print_sub_2();
print_sub_3();
$_SESSION['PrintBuffer']
*/
$Printer_name = $_GET['Printer'];
$text = $_GET['value'];
$text = str_replace( "-"," ", $text);
$text = str_replace( "/r/n"," \r\n , ", $text); // replace and make string Array
$lineofText = explode(',',$text); // Array to stand to for
# Examples
// testing font
//echo printer_logical_fontheight($printer, 72);
//printer_set_option($printer, PRINTER_MODE, "RAW");
$handle = printer_open($Printer_name); // Open Pritner by Name
printer_set_option($handle, PRINTER_MODE, "raw");
//printer_set_option($handle, PRINTER_TEXT_ALIGN, PRINTER_TA_LEFT);
printer_start_doc($handle, " Print"); // Name Document
printer_start_page($handle); // Start Logo
printer_draw_bmp($handle, "c:\\logo.bmp", 60, 0); // Logo Dir, lenght H , With V
printer_end_page($handle); // End Logo
printer_start_page($handle); // Text
$asize=sizeof($lineofText); // Make NewLine per Array
for($i=0; $i<$asize; $i++) {
printer_draw_text($handle, $lineofText[$i],1,1);
}
printer_end_page($handle); // End Text
//printer_start_page($handle); // Start Logo QR
//printer_draw_bmp($handle, "c:\\QR.bmp", 60, 0); // Logo Dir, lenght H , With V
//printer_end_page($handle); // End Logo QR
printer_end_doc($handle); // Close document
printer_close($handle); // Close Pritner
?>