olimits7
olimits7

Reputation: 593

Backend generates pdf files (labels, packing slips, etc) - Need to automatic print to pre-selected printers from browser - Workaround?

I'm in the process of developing a web application; where in the admin backend I need to have the functionality to do automatic print jobs for different processes that run and generate a pdf (labels, packing slips) in admin that will be sent to pre-selected LAN network printers in my warehouse.

I've been doing some research on this and I know due to security issues automatic printing like this is hard to configure. However, I have some posts where people write that they were able to pull this off with active x, java, print server, client software, etc...but there isn't a clear outline on how exactly to do this.

Can someone help me figure out a workaround that I can use to be able to automatically print to different LAN network printers in my warehouse when a certain process runs and generates a pdf file?

Thank you!

Upvotes: 1

Views: 544

Answers (1)

Conor
Conor

Reputation: 409

I also manage a warehouse system that does these tasks. I will not claim that the following solutions are the best way to go, but they have been working for us. Our system is built using PHP 5.3 on a Windows server using Apache. With this setup, the user does not need to print anything from the browser, it's all handle server-side.

Requirements: Apache needs to be running with Administrator privileges. Probably not recommended for web-facing servers.

To print a PDF on Windows via PHP:

$file = "c:\\path\\to\\file.pdf";
$exec = '"C:\\Program Files\\bioPDF\\Acrobat Wrapper\\acrowrap.exe" /t ';
session_write_close(); // prevents hanging
pclose(popen($exec. $file . " \\networked\\printer",'r'));

This just launches reader, prints the file, and closes reader.

On a Linux/Mac you should be able to use (without Admin privliages):

$file = "/path/to/file.pdf";
$command = "lpr -P /printer/path " . $file;
exec($command);

Upvotes: 2

Related Questions