We help IT Professionals succeed at work.

How do I print from a remote webserver using a PHP script directly to a local network printer?

ErDrRon
ErDrRon asked
on
246 Views
Last Modified: 2012-05-05
I have a web-based PHP script used for referring patients to an Emergency Department.  The script is hosted on a remote server and the hospitals access it via a URL.  I need the script to be able to print out info on a referred patient onto the hospital's local network printer.  How do I go about adding this functionality to the script?  The script is running on a linux server/Apache using PHP and MySQL.  Is there a printer class somewhere that I can include in the script?  I do not need a code snippet/class that merely makes a page "printer-friendly."  I need a class that sends the data directly to the printer for printing without having a pop-up printer window.
Comment
Watch Question

I think you will have to look at a Java Applet to get this done... Javascript can only pop up the printer dialog and requires interaction from the user.
Though if that works for you... calling

window.print();


will do it then...

Author

Commented:
Is there a Java applet out there that already does this?  I'm afraid I'm not Java-savvy.

Ron

Author

Commented:
I am trying to avoid forcing the user to interact with a pop-up Windows printer properties dialogue box.  i want the print to happen seamlessly and transparently in the background.

Ron
Developer | Solutions Architect | CTO
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Don't know about a free or specific applet but the Library one might use to write the applet would probably be JPrint http://www.nevaobject.com/_docs/_jprint/JPrint.htm

it would allow Java to interface with a print, so you might try searching google for something using this API that prints the current web page... or loads a web page and prints it... Basically speaking you need some sort of client side activex control, Java applet, maybe flash app to do this... javascript itself can't do it because of the security problems.
Graham N.Group MD
CERTIFIED EXPERT

Commented:
The ScriptX control from Mead&Co is an activeX control that handles exactly what you want to do - but its not free and obviously only runs on Windows and IE.

http://www.meadco.com/scriptx/index.asp

If you do not want to use an ActiveX control (or pay for it) then there is no other way to print from a web page other than by using the Javascript "window.print()" command.

Using a Java applet will have similar downsides to an ActiveX control in that not everybody has Java installed on their PC.

We spent considerable time a couple of years ago trying to handle the very same thing - we ended up going with ScriptX!

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.