Warm tip: This article is reproduced from serverfault.com, please click

printing from php to real printer

发布于 2020-11-30 20:05:31

I have been using the following script for some time now in a batch file to print PDF files to a printer:

c:\path\to\PDFtoPrinter.exe c:\path\to\file.pdf "\\ip\printer"

I had hoped to simply add this to a PHP script using exec() and all would work, but no.

exec('c:\\path\\to\\PDFtoPrinter.exe c:\\path\\to\\file.pdf "\\\ip\\printer"');

My other idea was to write the commands to a bat file and execute that file from my PHP script, but also no success.

Any suggestions?

exec("\\path\\to\\PDFtoPrinter.exe \\path\\to\\file.pdf '\\ip\printer'");
Questioner
vespino
Viewed
0
vespino 2020-12-02 16:10:23

The following works for me:

exec("c:\\path\\to\\PDFtoPrinter.exe c:\\path\\to\\pdf.file \"printer-name\"");