print to physical printer on a mac

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
amyhughes
Forum Newbie
Posts: 14
Joined: Fri Apr 13, 2012 7:54 am

print to physical printer on a mac

Post by amyhughes »

Last week I figured out how to print to a physical printer from a PHP script on a Windows machine. This week...same question, with a Mac.

It's theoretically much simpler on a mac. The lpr command deals well with PDF files, so in theory this should work:

shell_exec('lpr ' . $filename);

But that fails (returns false). It doesn't work with a full path name, either.

Any clue? The script is able to write to the file, so those permissions are okay. Might it be a permissions problem in printing?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: print to physical printer on a mac

Post by pickle »

You may need to specify the name of the printer with -P
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply