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

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
paryankkansara
Forum Newbie
Posts: 1
Joined: Thu Sep 20, 2007 3:44 am
Location: Ahmedabad

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

Post 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
Post Reply