日期:2014-05-17 浏览次数:20740 次
//phpinfo();exit;
//打印机的名字,并初始化
$handle = printer_open("EPSON LQ-735K ESC/P2");
$name = "麻花藤";
$address = "上海市虹梅路1801号";
//转换格式,UTF8打出来乱码
$name = iconv("UTF-8", "GBK", $name);
$address = iconv("UTF-8", "GBK", $address);
//手动设置纸张的长宽,但这步没启作用,纸张还是按照A4的大小在进行打印
printer_set_option($handle,PRINTER_PAPER_FORMAT,PRINTER_FORMAT_CUSTOM);
printer_set_option($handle,PRINTER_PAPER_WIDTH,320);
printer_set_option($handle,PRINTER_PAPER_LENGTH,250);
//开启文档
printer_start_doc($handle, "Print"); // Name Document
//打印次数,其实上面printer_set_option也有参数,但也没起作用
for($i=1;$i<=2;$i++)
{
printer_start_page($handle);
printer_draw_text($handle, $name.$i.$i.$i,150,150);
printer_draw_text($handle, $address.$i.$i.$i,250,250);
printer_end_page($handle); //
//打印图片
//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_end_doc($handle); // Close document
printer_close($handle); // Close Pritner