Jump to content

PHP Socket to print to networked printer


Andy-H

Recommended Posts

Hi, I have been searching all day but can't find a solution to this using PHP.

 

 

Basically were developing a CRM at work and wish to be able to print letters remotely using PHP.

 

 

We have a printer equipped with a network card and I want to be able to fire requests to a socket listener port and have it print template documents depending on the request.

 

 

So far all I've found is something called Line Printing Terminal which apparently can be called from command line as far as I understand.

 

 

My boss has currently had me code a VB.NET script with two browser windows and it refreshes every 30 seconds, gets a url from a div element in the page and prints the webpage but I don't like this way, I think it's a sloppy hack and wastes bandwidth.

 

 

Like I say, ideally I would like to fire requests at a port via the printservers IP address but we could have the printer set as default on the server on which the printing script would run.

 

 

Any help/advice or resources would be greatly appreciated.

Link to comment
Share on other sites

LPT is a completely different mechanism from networking. It won't work in your situation.

 

There is a PHP extension that may work for you. It's mostly dead, but you can find a somewhat recent version of it on this page (search for "printer").

Otherwise your best bet would be to make the server open up whatever file to print in whatever application and make the application print it, though you'd have to determine what that program is. Some allow for printing right from a command line (eg, app.exe /print filename) and some (notably Office) can be scripted through COM.

Link to comment
Share on other sites

Thanks, never used COM but it looks really easy so could be on to a winner there, think I'll look for a command line solution like you suggested in  work tomorrow and failing that fall back on COM. Thanks for the help, much appreciated :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.