LittleTreeX
LittleTreeX

Reputation: 1239

How to print to a printer installed on the server via php (Windows 2008)

Through an "intranet" application I need to be able to print precisely formatted pages to a printer that will be installed on the "web server".

For example, the user will access the application via their browser and when they complete a transaction a contract should print. The contract prints dynamic content on a pre-printed form (hence the precisely formatted requirement). This contract should print on a printer that is installed on a Windows Server 2008 machine, which is the same machine running the application.

I am using php as it is, so it would seem that it would be the best way to pull this off since both the printer and the php are running off the same box. Unfortunately, I haven't had much luck finding a good lpr (or other) print package.

Additionally, I need to print labels in the same manner (to a Zebra TLP 2844-z). However, I am fairly sure that if I can print to a printer using LPR it won't matter what type of printer it is.

Upvotes: 0

Views: 1004

Answers (1)

romaninsh
romaninsh

Reputation: 10664

Take a look at LPD, CUPS. Most likely you would need to convert your script output into PostScript then send it over to the printer.

http://php.net/manual/en/book.ps.php

If you can generate PDF (you can convert HTML into PDF)

exec cat generated.pdf | acroread -toPostScript | lpr -P $printer

Try also looking for help on serverfault.com

Upvotes: 1

Related Questions