2

I have a question about printing files using php scripting .

is there any linux printing library to be installed on the server ? i've tried the lpr command with exec , shell_exec , and system functions . but non of theme worked with me .

example 1:

$filedir = "/home/user/domains/domain.com/public_html/print/file/test.txt"  ;
echo shell_exec("lpr $filedir");

example 2:

$filedir = "/home/user/domains/domain.com/public_html/print/file/test.txt"  ;
echo shell_exec("lpr -P printername $filedir");

example 3:

$filedir = "/home/user/domains/domain.com/public_html/print/file/test.txt"  ;
echo exec("lpr $filedir");

example 4:

$filedir = "/home/user/domains/domain.com/public_html/print/file/test.txt"  ;
echo shell_exec("lpr -P printername $filedir");

example 5:

$filedir = "/home/user/domains/domain.com/public_html/print/file/test.txt"  ;
echo system("lp $filedir");

also iv'e tried this class here but it shows me a warning msg and print nothing

Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to tcp://1.1.1.1:515 (Connection timed out) in /home/user/domains/domain.com/public_html/print/PrintSendLPR.php on line 122

also i have checked a lot of examples as here , here , and here

any help please ! i have to print out a file with php code which is hosted on a Linux server , i need to connect to the user's default printer or to install a printer-library/driver into the server .

Many thanks

Community
  • 1
  • 1
aadiahg
  • 119
  • 1
  • 1
  • 9
  • Are you creating a command line script or a web application. I.e. will your user's access your script through a terminal or through a browser? – Jens Wegar May 16 '12 at 13:02
  • In that case I'm guessing you'll need to install a printer on the server, as any exec command in PHP will only have access to whatever is installed on the server. Here's a link to some more info about CLI printing in Linux http://tldp.org/HOWTO/Printing-Usage-HOWTO-2.html. Unfortunately I can't help with suggesting any drivers to install. – Jens Wegar May 16 '12 at 13:37
  • okay thanks , i'll check the links you've posted - many thanks :) – aadiahg May 16 '12 at 13:51

0 Answers0