ukphoto Posted January 8, 2009 Share Posted January 8, 2009 I have come across a script from which I just wanted to use the ability to print pdfs but whatever I do I can not get it to work. <?php function print_file($filename) { // path to your adobe executable $adobe_path='"C:/Program Files/Adobe/Acrobat 7.0/Reader/AcroRd32.exe"'; $ext=''; $ext=strrchr($filename,'.'); $ext=substr($ext,1); $ext_xl=substr($ext,0,2); if ($ext=='pdf') { shell_exec ($adobe_path.' /t '.$filename); } else if ($ext=='doc'||$ext=='rtf'||$ext=='txt') { $word = new COM("Word.Application"); $word->visible = true; $word->Documents->Open($filename); $word->ActiveDocument->PrintOut(); $word->ActiveDocument->Close(); $word->Quit(); } else if ($ext_xl=='xl') { $excel = new COM("Excel.Application"); $excel->visible = true; $excel->Workbooks->Open($filename); $excel->ActiveWorkBook->PrintOut(); $excel->ActiveWorkBook->Close(); $excel->Quit(); } } // example of printing a PDF print_file("C:/photo_gallery.pdf"); ?> I have been told about user priviledges but have not been succesful. The documents to be printed are pdf and it would be difficult to change so have to find some method of auto print. help appreciated. Quote Link to comment Share on other sites More sharing options...
Brian W Posted January 8, 2009 Share Posted January 8, 2009 Like force client to print the pdf? Can not force the clients browser to print the PDF. You have two choices with the file output: either execute the PDF in the browser or push the file so the Client can download it. Quote Link to comment Share on other sites More sharing options...
ukphoto Posted January 8, 2009 Author Share Posted January 8, 2009 Brian, the pdfs are generated on the server and printed on a printer connected to the server. Quote Link to comment Share on other sites More sharing options...
Brian W Posted January 8, 2009 Share Posted January 8, 2009 Oh, I see. Sorry, but still think you can't do that. Maybe could do it with PERL. Than again, I don't know that you can't with PHP, I just have never heard of any such ability or seen anything that would suggest it. Maybe some one else has. I know this can be done in c++, but not sure how you could tell the c++ application what file to print. PERL in a .cgi should be able to do it and it excepts query strings and can be executed from a browser, so that is probably your best bet. I'll help you look online for the best solution though. Is your server windows or linux? Quote Link to comment Share on other sites More sharing options...
ukphoto Posted January 8, 2009 Author Share Posted January 8, 2009 I am using WAMPserver 2.0f running on windows XP pro. Quote Link to comment Share on other sites More sharing options...
Prismatic Posted January 8, 2009 Share Posted January 8, 2009 Take a look at this ukphoto, http://www.phpclasses.org/browse/package/2540.html Also, http://support.adobe.com/devsup/devsup.nsf/docs/52080.htm Quote Link to comment Share on other sites More sharing options...
Brian W Posted January 8, 2009 Share Posted January 8, 2009 working off of that Adobe line... <?php $pdf = $_GET['PDF']; $pdf = escapeshellcmd($pdf); $pdf = "C:\dir\file\in\".$pdf; if(!is_file($pdf)){ die('No such file'); } exec('AcroRd32.exe /t "'.$pdf.'" "\\servername\printername"'); //Confirmation message or whatever ?> I didn't test that, but it looks like a decent start. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.