[SOLVED] getting the list of printers

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
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

getting the list of printers

Post by pelegk2 »

how can i getthe list of printers on the server?
i it possible?
thnaks in advance
peleg
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

I'm guessing if it were possible then how you do it would be very much related to the type and version of server...

Mac
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Are you talking about Windoze server?
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

nope i mean the apache is installed on windows and i wan the list of installed printers
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

http://www.php.net/manual/en/function.printer-list.php ?
That requires PECL printer extension though (which is only available from cvs).
On the other hand you may use some WinAPI wrapper to call EnumPrinters directly
Last edited by Weirdan on Thu Oct 14, 2004 8:10 am, edited 1 time in total.
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

can u tell me please where do i get the extension and how

Post by pelegk2 »

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

Post by twigletmac »

Google (RTFM & STFW).

Mac
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

i did the search Google (RTFM & STFW). and didnt find anything releavent to this :(
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

http://www.php.net/manual/en/ref.printer.php
PHP Manual wrote:Installation

This PECL extension is not bundled with PHP. Additional information such as new releases, downloads, source files, maintainer information, and a CHANGELOG, can be located here: http://pecl.php.net/package/printer.

Windows users will enable php_printer.dll inside of php.ini in order to use these functions. In PHP 4 this DLL resides in the extensions/ directory within the PHP Windows binaries download. You may download this PECL extensions DLL from the PHP Downloads page or at http://snaps.php.net/.
Mac
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

well i have the php_printer.dll and its un marked in the php.ini and still isnt working
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

twigletmac wrote:http://www.php.net/manual/en/ref.printer.php
PHP Manual wrote:Installation

This PECL extension is not bundled with PHP. Additional information such as new releases, downloads, source files, maintainer information, and a CHANGELOG, can be located here: http://pecl.php.net/package/printer.

Windows users will enable php_printer.dll inside of php.ini in order to use these functions. In PHP 4 this DLL resides in the extensions/ directory within the PHP Windows binaries download. You may download this PECL extensions DLL from the PHP Downloads page or at http://snaps.php.net/.
Mac
The PHP manual would be the first port of call.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

i'm using php5.0.2 on winxp pro (php_printer.dll is in %php%/ext)

around line 582 in php.ini i added

Code: Select all

extension=php_printer.dll
restarted apache and it works

Code: Select all

<?php
/* detect locally shared printer */
var_dump(printer_list(PRINTER_ENUM_LOCAL | PRINTER_ENUM_SHARED));
?>
array(1) { [0]=> array(3) { ["NAME"]=> string(16) "HP OfficeJet V45" ["DESCRIPTION"]=> string(34) "HP OfficeJet V45,HP OfficeJet V45," ["COMMENT"]=> string(0) "" } }
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

i have the same
maybe the diffrence in the php version?
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

well it worked on another computer but not on my - dont know why :(
but the intresting thing that it didnt get the share name only the original name as its defined!
any idea?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

I believe you'll be able to get share name if you pass the name of your local machine as second argument:

Code: Select all

var_dump(printer_list(PRINTER_ENUM_NAME, '\\\\\\\'' . $_ENV['COMPUTERNAME']));
Post Reply