Skip to content
PHP Logo

Are there specific functions in PHP for interacting with LPR on Linux for printing?

To interact with LPR on Linux for printing in PHP, you can use the shell_exec function to execute the lp command, which is used to send files to a printer. You can pass the file path and printer name as arguments to the lp command to print the file.

php
$file_path = "/path/to/file.pdf";
$printer_name = "printer_name";

$command = "lp -d $printer_name $file_path";
$output = shell_exec($command);

echo "File sent to printer.";