0

对不起,我的英语不好

我的问题是,如何使用printer_draw_textFunction 打印出长字符串?(见示例)在爱普生计费打印机上。

所有示例都有效(来源:http ://www.php.net/manual/en/book.printer.php )

但是当我想结合一个 Logo.bmp + 一行长文本时,它只会打印出徽标和 1 行刺痛:

例子:

<?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

?>

输出示例:

徽标.bmp

测试.... // 但只有 1 行 :(

printer_write($handle, "要打印的文本"); 工作!它打印出孔字符串 + \r\n 但它在新纸上打印出徽标:(

需要的例子

标志 <-- 这里

1 x 产品 <-- 长字符串 1 x 产品 \r\n (工作的 printer_write 函数) 2 x 产品 ecr。

printer_draw_text($handle, $text,1,1);仅打印 1 x 产品 2 x

4

1 回答 1

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


?>
于 2012-06-17T09:57:04.920 回答