使用php自动打印

I have pdf files coming in a folder after some duration. I want to print them using php automatically by default printer and after printing those files move to other folder. How can I do this? I am using the code given below but it's not printing anything..Please help..

$printer = "\\\\server\printer";

if($ph = printer_open($printer))
{  
   $fh = file_get_contents('455.pdf');

   printer_set_option($ph, PRINTER_MODE, "RAW"); 
   printer_write($ph, $fh); 
   printer_close($ph); 
} 

else 
   echo "Can't connect to printer"; 

Here https://www.daniweb.com/web-development/php/threads/449709/php-print-pdf-directly-to-a-printer i found the solution of this issue . i hope it will work for you and use rename('foo/test.php', 'bar/test.php'); for the transfer of all files from one folder to another after printing .