printing with php
Moderator: General Moderators
printing with php
basically i need to print a document using php print functions. But i juz wonder anyone out there can suggest a better way to do it.
I searched on the web for php printing class (something like pdf class). but i got nothing.
Can anyone tell me if i can juz read a file and print the content in the exact format to the printer.
I searched on the web for php printing class (something like pdf class). but i got nothing.
Can anyone tell me if i can juz read a file and print the content in the exact format to the printer.
the builtin PHP printer functions only works on windows, there was an article about how to use this in PHP|Architect a couple of months ago, go to their web site and purchase this issue it gives you a good start..
If you are using a sane system (Not windows) you can use pretty much any layout format, like Latex or PDF, and then use some shell commands (like lpr or similar) with some Unix print service, the easiest one to set up is likely CUPS..
If you are using a sane system (Not windows) you can use pretty much any layout format, like Latex or PDF, and then use some shell commands (like lpr or similar) with some Unix print service, the easiest one to set up is likely CUPS..
Perl is a very good tool for text processing...aquila125 wrote:PHP isn't build for this kind of operations... better take a look at perl or c++ (c)
"Better have a look at C++" does not make any sense to me, its not something you learn overnight and throw something together the next day, although it may compile and do your stuff its very likely not to be protected in any way (overflows etc) and in my opinion C/C++ is far from a good text and layout processing tool..
PHP can do the job just fine, Perl can do it better
It's pretty simple.
Make a new page that is seperate from your layout, with only the text you would like to print (the php parsing part).
In a regular page you would most likely color, stylize, and format this text but with the print page, avoid doing that. Most people I've seen make this a seperate popup, and use just black/white text and throw in a site logo for good measure.
Then use the [google]javascript print[/google] features to send the Print dialog to the users.
If you want a class or function that can do this for you, try searching around some major open source sites and code libraries. PHPBuilder, HotScripts, etc.
Make a new page that is seperate from your layout, with only the text you would like to print (the php parsing part).
In a regular page you would most likely color, stylize, and format this text but with the print page, avoid doing that. Most people I've seen make this a seperate popup, and use just black/white text and throw in a site logo for good measure.
Then use the [google]javascript print[/google] features to send the Print dialog to the users.
If you want a class or function that can do this for you, try searching around some major open source sites and code libraries. PHPBuilder, HotScripts, etc.
Thanks for advice...i know there is way to use browser with javascript to print out the content..in fact i have done few projects with this kinda printing. but now i'm looking for using php functions to spool the print job to the selected printer instead of using browser printing. Because by using browser printing, it seems to be a bit slow and the page format is control by the browser itself.
Sami wrote:It's pretty simple.
Make a new page that is seperate from your layout, with only the text you would like to print (the php parsing part).
In a regular page you would most likely color, stylize, and format this text but with the print page, avoid doing that. Most people I've seen make this a seperate popup, and use just black/white text and throw in a site logo for good measure.
Then use the [google]javascript print[/google] features to send the Print dialog to the users.
If you want a class or function that can do this for you, try searching around some major open source sites and code libraries. PHPBuilder, HotScripts, etc.
Well the page formatting is controlled by you, the browser only interprets your instructions. So if you format it in a way that it's acceptable to print, a simply js print() call shall do the trick. And it's the only option since php doesn't really do that. Printing is a clientside thing, PHP works on the serverside.