//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
printer_set_option这步并没有起作用,还是按照A4的规格在打印,我想自己自定义规格。不知道哪位大神用过这个扩展,指教一下。(控制面板里的打印机默认的规格我也已经改成自定义的规格了,但还是按照A4的规格在打印)
------解决方案--------------------
你看看你的打印机程序员手册,所有的打印机控制指令都是 Esc 引导的一个字符串