我的工作是在安装了xampp的Windows机器上打印pdf文件服务器端。 现在我已经安装了php_printer.dll并从here复制/编写了一个测试脚本:
$printer = "\\\\SERVER\\PRINTER";
$file = "test.pdf";
if ($ph = printer_open($printer)) {
// Get file contents
$fh = fopen($file, "rb");
$content = fread($fh, filesize($file));
fclose($fh);
printer_start_doc($ph, "TESTPAGE");
printer_start_page($ph);
// Set print mode to RAW and send PDF to printer
printer_set_option($ph, PRINTER_MODE, "RAW");
printer_write($ph, $content);
printer_close($ph);
echo "-> Job was sent to ".$printer;
} else {
echo "-> Couldn't connect... ".$printer;
}
但它不适用于pdf文件;纯文字是好的。如果我打印pdf文件,纸上只有不正确的字符:( 我该怎么做才能在php中打印serverside pdf? 有什么提示吗?
问候,隆隆声