gpt4 book ai didi

php - 使用 php_printer.dll 打印 pdf 文件

转载 作者:可可西里 更新时间:2023-10-31 23:47:14 27 4
gpt4 key购买 nike

我想使用 php 将 pdf 文件打印到默认打印机,但它不打印文件并给出空白页作为输出。

$handle = printer_open("\\\\192.168.1.30\Brother MFC-J430W Printer");

printer_start_doc($handle, "PET PASS");

printer_start_page($handle);

$filename = "test.txt";

$fhandle=fopen($filename, 'r');
$contents = fread($fhandle, filesize($filename));
fclose($fhandle);

printer_set_option($handle, PRINTER_MODE, "RAW");
printer_write($handle,$contents);

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

谢谢。

最佳答案

这样试试:

<?php 
$printer = "\\\\Pserver.php.net\\printername");
if($ph = printer_open($printer))
{
// Get file contents
$fh = fopen("filename.ext", "rb");
$content = fread($fh, filesize("filename.ext"));
fclose($fh);

// Set print mode to RAW and send PDF to printer
printer_set_option($ph, PRINTER_MODE, "RAW");
printer_write($ph, $content);
printer_close($ph);
}
else "Couldn't connect...";
?>

关于php - 使用 php_printer.dll 打印 pdf 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30476842/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com