Print a document from PHP in Linux. Printer PECL extension works on Windows only, this is the solution for Unix.
#What it is?
This is a PHP native extension. That means that you need to load it via "extension=php_print.so" in php.ini, or via function call "dl('php_print.so')" in runtime.
It can send documents (as txt files, pdf and others) to printer. Formats are not fully tested yet, but basic plain text files and PDFs work.
This extension is just a thin wrapper for CUPS library.
-
Install PHP-CPP
http://www.php-cpp.com/documentation/install
-
Install cups libraries
Fedora:
sudo yum install cups-devel
Ubuntu:
sudo apt-get install libcups2-dev
-
make
-
sudo make install
-
use from php
<?php print_file('document.pdf'); ?>
Works on Fedora 21 with PHP 5.6 and any printer supported by CUPS.