Print files using 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
User avatar
doggy
Forum Commoner
Posts: 80
Joined: Tue Dec 09, 2003 5:01 am
Location: South Africa

Print files using php

Post 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
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

are you running on a windows machine?

The printer functions are windows ONLY.

Mark
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
doggy
Forum Commoner
Posts: 80
Joined: Tue Dec 09, 2003 5:01 am
Location: South Africa

Post by doggy »

yes it is a windows
User avatar
doggy
Forum Commoner
Posts: 80
Joined: Tue Dec 09, 2003 5:01 am
Location: South Africa

Post by doggy »

i still don`t anderstand why its not working
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Have you enabled the extension mentioned in the user comments on the page I linked above?

Mac
User avatar
doggy
Forum Commoner
Posts: 80
Joined: Tue Dec 09, 2003 5:01 am
Location: South Africa

Post by doggy »

yes i have

---
[Printer]
;printer.default_printer = ""
;extension=php_printer.dll
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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
User avatar
doggy
Forum Commoner
Posts: 80
Joined: Tue Dec 09, 2003 5:01 am
Location: South Africa

Post 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 $
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Code: Select all

$handle = printer_open("Canon BJC-85"); 
// shouldnt the printer be specified either by name or network?
User avatar
doggy
Forum Commoner
Posts: 80
Joined: Tue Dec 09, 2003 5:01 am
Location: South Africa

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