Thread: printing
View Single Post
  #2 (permalink)  
Old 2003-05-26, 12:16 AM
wjensen wjensen is offline
Junior Member
 
Join Date: Mar 2003
Location: UT
Posts: 16
wjensen
Default

That depends on what exactly it is you're trying to do. You can just write a standard PHP script that is accessed through a web browser and use your browser's print feature. One problem with this method is that it is difficult to predict where page breaks will be, since there is no page break in HTML.

If you're running on a Windows system with PHP >=4.0.4 you can use the printer library.

Code:
<?
$handle = printer_open();
printer_write($handle, "Text to print");
printer_close($handle);
?>
The downside to this method is that it might get complicated if you're printing anything but plain text. I don't really know because I've never tried.

If you're on a Unix/Linux/etc. system you can write the data to a file and use

Code:
<?
system("lp $filename");
?>
I'm a Linux newbie, so I don't know a lot about other ways of doing this in Linux. I know you can do it with postscript somehow.

If you're on a Windows system with MS Office and want to use HTML to format the output, but still want the process automated (and don't mind not having page breaks), try this:

Code:
<?
system("C:\Program Files\Microsoft Office\Office10\msohtmed.exe /p $filename");
?>
You would still have to write your output to a file first.

For more details check out www.php.net/printer
__________________
Wayne Jensen
Reply With Quote