Jump to content

Printing from PHP - send data to network printer


yklxmas

Recommended Posts

Hi all,I need to come up with a script that allows me to read contents from text files and print them out of a network printer. I've tried printer_open function just to try connection to the printer. No luck at all. I made sure the name is correct. The webserver and printer server are 2 different machines. I've also tried add \\printerserver\printername or \\\printerserver\printername. also the ip address of the printer. Still no luck.Has anyone got any ideas? Thanks for the help in advance.

Link to comment
Share on other sites

Hi.. Have you got any errors..? or have you tried to debug the code..? what are you getting in resulting var..? May I have your peace of code so I can get the things..Regards,Vijay

Link to comment
Share on other sites

\\printerserver\printername or \\\printerserver\printername
You haven't escaped the backslashes properly.If the location of the printer is \\printerserver\printername , you have to write
printer_open("\\\\printserver\\printername");

Link to comment
Share on other sites

Hello,I've just tried 2 versions.1,<?php$handle = printer_open("\\\\ILF-SRV\\Ilf-Inf43rpcs"); var_dump($handle);?> The output is NULL.ILF-SRV = name of printer server.Inf43rpcs = name of the printer.The printer is connected using ethernet.2, <?php$handle = printer_open("\\\\DOMAIN1\\Ilf-Inf43rpcs");var_dump($handle);?> DOMAIN1 = Name of the domain.OutputWarning: printer_open() [function.printer-open]: couldn't connect to the printer [\\DOMAIN1\Ilf-Inf43rpcs] in c:\Inetpub\wwwroot\printer1.php on line 3bool(false)

Link to comment
Share on other sites

The printer functions are only available on Windows, so this may not work if you are using Apache (not sure about that), and it definately won't work if you are using Linux. The null return value indicates that the connection failed, but you should probably be getting an error message. First, just turn on errors and see if you get anything:ini_set("display_errors", 1);error_reporting(E_ALL);If you still see nothing, since it sounds like you have control of the webserver, check php.ini to see where the errors are going (an error log or database maybe) and look up the errors. Also, since you didn't specify in your post, make sure that both the web server and print server are on the same network, the web server needs to be able to communicate with the print server. This does not work if you are trying to use a printer attached to the machine where the web browser is, it must be the server's printer.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...