Page 1 of 1

Print files using php

Posted: Tue Jan 27, 2004 3:47 am
by doggy
i found this at http://www.php.net

Code: Select all

<?php
$handle = printer_open();
printer_write($handle, "Text to print");
printer_close($handle);
?>
but it gives me this error

Fatal error: Call to undefined function: printer_open() in C:\FoxServ\www\base.php on line 2


all i want to do is print files using php . any one know how

Posted: Tue Jan 27, 2004 3:51 am
by JayBird
are you running on a windows machine?

The printer functions are windows ONLY.

Mark

Posted: Tue Jan 27, 2004 3:58 am
by twigletmac
Note this page:
http://php.net/manual/en/function.printer-open.php
(no version information, might be only in CVS)
Also requires an extension to be enabled in the php.ini (have a read of the user comments).

Mac

Posted: Tue Jan 27, 2004 3:59 am
by doggy
yes it is a windows

Posted: Tue Jan 27, 2004 4:08 am
by doggy
i still don`t anderstand why its not working

Posted: Tue Jan 27, 2004 4:33 am
by twigletmac
Have you enabled the extension mentioned in the user comments on the page I linked above?

Mac

Posted: Tue Jan 27, 2004 4:40 am
by doggy
yes i have

---
[Printer]
;printer.default_printer = ""
;extension=php_printer.dll

Posted: Tue Jan 27, 2004 4:58 am
by JayBird
have you

Added the line extension=php_printer.dll to your php.ini file.

If it is already there does it have a ; infront of it? If so then remove the ;

Have you restarted the webserver after removing the ;?

Does the php_printer.dll file exist in your extensions folder?

Is the extensions folder path in your PHP ini file correct?

When you run phpInfo() does it show a section for the printer extension?

Mark

Posted: Tue Jan 27, 2004 5:05 am
by doggy
printer
Printer Support enabled
Default printing device
Module state working
RCS Version $Id: printer.c,v 1.23 2002/05/17 18:49:42 fmk Exp $

Posted: Tue Jan 27, 2004 10:41 am
by ol4pr0

Code: Select all

$handle = printer_open("Canon BJC-85"); 
// shouldnt the printer be specified either by name or network?

Posted: Tue Jan 27, 2004 11:55 pm
by doggy
yeah i did all that but it is still not printing.

Code: Select all

<?php
$handle = printer_open("Xerox 3006");
printer_start_doc($handle, "My Document");
printer_start_page($handle);

$font = printer_create_font("Arial", 72, 48, 400, false, false, false, 0);
printer_select_font($handle, $font);
printer_draw_text($handle, "test", 10, 10);
printer_delete_font($font);

printer_end_page($handle);
printer_end_doc($handle);
printer_close($handle);
?>


the page just loads for ever