Page 1 of 1

Printing images/PDF and Print to File (.PRN file) with PHP

Posted: Wed Mar 12, 2008 5:58 am
by paryankkansara
PHP provides built in printer functions like printer_open() and printer_write() for printing text to installed printer. But printer_write() treats each content as plain text. It cannot understand PDF, JPEG, PNG etc formats. If I want to print images or PDF files, what should I do?

Another thing,
In windows, when we print any file, a printer dialog box opens which displays an option for selecting a printer to print. There is also a checkbox for "Print to File". Selecting this checkbox will not send printing commands to printer, instead it will ask for a file location. At the given location a .prn file will be stored. This file contains Printer Commands.

I want to do this with PHP. By printer_open() function, I can select my desired printer. I am not finding a way to give option for "Print to file". Not even in printer_set_option() function.

In short, my application needs to print PDF and image files to a .prn format (We can consider it as PCL - Printer Command Language file). How it can be possible in PHP? Please guide me to a proper way.

Thanks,
Paryank