如何用php打印图像

时间:2014-05-13 09:29:16

标签: php

你好我把这段代码放在那里:

$handle = printer_open ("HP Photosmart 5520 series"); 
printer_write ($handle, "jo.png"); 
printer_close ($handle);

但不是打印一个打印文本jo.png的图像。

1 个答案:

答案 0 :(得分:1)

试试这个printer-draw-bmp你在本手册的评论中有很好的例子。

$im = imagecreatefrompng('kitten.png');
$randomName = uniqid() . '.bmp';
imagewbmp($im, $randomName);

$handle = printer_open("HP Photosmart 5520 series");
printer_start_doc($handle, "My Document");
printer_start_page($handle);

printer_draw_bmp($handle, $randomName, 0, 0);

printer_end_page($handle);
printer_end_doc($handle);
printer_close ($handle);

unlink($randomName);