Printing data to printer using PHP

后端 未结 2 633
日久生厌
日久生厌 2020-12-25 08:56

I have a question that has been troubling me for at least 3 weeks now. I need to print some data to a printer using php. I have data saved into a $print_output

2条回答
  •  一整个雨季
    2020-12-25 09:39

    You have several options to print with PHP on Windows:

    1. Extension "php_printer"

    Because PHP 5.2.0 is outdated, it's quite hard to find compiled extension. You might try to drop in the php_printer extension for 5.2.8:

    http://downloads.php.net/pierre/php_printer-cvs-20081215-5.2.8-nts-Win32.zip

    Add to your php.ini:

    extension=php_printer.dll
    

    Recent version might be found at Pierre's download site: http://downloads.php.net/pierre/

    2. Execute the windows CLI command "print" via PHP

    An alternative solution is to use the windows command "print".

    See http://technet.microsoft.com/en-us/library/cc772773%28v=ws.10%29.aspx

    exec("print /d:\\192.168.1.33_4\\Printer_Office c:\accounting\report.txt); 
    

    3. Use Sockets

    $fp=pfsockopen("192.168.1.201",9100);
    fputs($fp,$print_data);
    fclose($fp);
    

    4. Output to HTML, open in browser and trigger window.print()

提交回复
热议问题