Home  >  Article  >  Backend Development  >  printer扩张的一些使用疑问

printer扩张的一些使用疑问

WBOY
WBOYOriginal
2016-06-13 12:49:231107browse

printer扩展的一些使用疑问

<br />
//phpinfo();exit;<br />
//打印机的名字,并初始化<br />
$handle = printer_open("EPSON LQ-735K ESC/P2");<br />
$name = "麻花藤";<br />
$address = "上海市虹梅路1801号";<br />
<br />
//转换格式,UTF8打出来乱码<br />
$name = iconv("UTF-8", "GBK", $name);<br />
$address = iconv("UTF-8", "GBK", $address);<br />
<br />
//手动设置纸张的长宽,但这步没启作用,纸张还是按照A4的大小在进行打印<br />
printer_set_option($handle,PRINTER_PAPER_FORMAT,PRINTER_FORMAT_CUSTOM);<br />
printer_set_option($handle,PRINTER_PAPER_WIDTH,320);<br />
printer_set_option($handle,PRINTER_PAPER_LENGTH,250);<br />
<br />
//开启文档<br />
printer_start_doc($handle, "Print"); // Name Document<br />
//打印次数,其实上面printer_set_option也有参数,但也没起作用<br />
for($i=1;$i<=2;$i++)<br />
{<br />
	printer_start_page($handle);<br />
	printer_draw_text($handle, $name.$i.$i.$i,150,150);<br />
	printer_draw_text($handle, $address.$i.$i.$i,250,250);<br />
	printer_end_page($handle);  //<br />
<br />
	//打印图片<br />
	//printer_start_page($handle); // Start Logo<br />
	//printer_draw_bmp($handle, "c:\\logo.bmp", 60, 0);  // Logo Dir, lenght H , With V<br />
	//printer_end_page($handle);  // End Logo<br />
}<br />
printer_end_doc($handle);   // Close document <br />
<br />
<br />
printer_close($handle);     // Close Pritner<br />

printer_set_option这步并没有起作用,还是按照A4的规格在打印,我想自己自定义规格。不知道哪位大神用过这个扩展,指教一下。(控制面板里的打印机默认的规格我也已经改成自定义的规格了,但还是按照A4的规格在打印)


------解决方案--------------------
你看看你的打印机程序员手册,所有的打印机控制指令都是 Esc 引导的一个字符串
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn