Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Printing to a specific port

Posted on 2003-12-01
13
Medium Priority
?
279 Views
Last Modified: 2013-12-12
Does anyone know how to print text to a printer port?

Here is what I am trying to get out of the program.

<?php

$variable = "This is a test";

print $variable to lpt1:

?>

Thanks,

Jeremys
0
Comment
Question by:jmsloan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
13 Comments
 
LVL 13

Expert Comment

by:lozloz
ID: 9854167
well here are the functions for using a printer in php on windows: http://www.php.net/manual/en/ref.printer.php

using printer_open (http://www.php.net/manual/en/function.printer-open.php), if for some reason you always want it on lpt1, i guess you should set it as default and just use the printer_open function without an argument

loz
0
 
LVL 3

Author Comment

by:jmsloan
ID: 9858194
Actually lpt1 is set up as a reciept printer, and I only want to browser to print to this device when they run this certain php script
0
 
LVL 13

Expert Comment

by:lozloz
ID: 9858224
how do you mean? if you only want to print when a certain page is accessed then only use these functions on that page

loz
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Author Comment

by:jmsloan
ID: 9858270
I currently have this code

<?php
$handle = printer_open("\\chnt5\pos2100");
$handle = printer_open();
printer_write($handle, "This is a test");
printer_close($handle);

?>

and it gives me a

Fatal error: Call to undefined function: printer_open()

error
0
 
LVL 13

Expert Comment

by:lozloz
ID: 9858293
you need to add the line extension=php_printer.dll to your php.ini file and you need to be running windows on the server

loz
0
 
LVL 3

Author Comment

by:jmsloan
ID: 9858323
I have the php server running on linux.  I was wanting who ever accessed the web page (from windows machine) to be able to print from lpt1.  Is that possible?  
0
 
LVL 13

Expert Comment

by:lozloz
ID: 9858405
i don't know if we're trying to achieve the same thing here - are you wanting a printer attached to the server to print or for the user's printer to? you can't control the user's printer in php as it's a server-side language and this would be quite a big security issue.. you'd need to use javascript and have the user's agreement through a dialog box to print a page to their printer. if you're talking about a printer on the server machine, you need windows installed there. there might be a library to allow printing in linux but i haven't seen one personally

loz
0
 
LVL 3

Author Comment

by:jmsloan
ID: 9858452
I am talking about using the users printer to print the data.
0
 
LVL 13

Expert Comment

by:lozloz
ID: 9858520
as i said, it'd be a huge security problem if you could create web pages which automatically printed from the user's printer.. have a look at this for using javascript to create a link allowing the users to print: http://developer.irt.org/script/49.htm

loz
0
 
LVL 3

Author Comment

by:jmsloan
ID: 9858613
What if I want to print a variable and not the window?  What is the security risk with web pages that automatically print to the users printer?
0
 
LVL 13

Expert Comment

by:lozloz
ID: 9858863
hi,

well being able to control part of a user's computer from a webpage means people can just create scripts to loop printing over again, possibly cause errors in the printer and crash machines i suppose, other than it'd be a pest to have adverts that automatically printed, wasting your ink and paper

to print a var you'll need to modify this javascript:

http://developer.irt.org/script/1497.htm

loz
0
 
LVL 3

Author Comment

by:jmsloan
ID: 9858901
So are you saying it is possible to do it still.  The page I am creating is for a corporate intanet and will only be used by stores in our company.  So there will be no malicious code involved.  
0
 
LVL 13

Accepted Solution

by:
lozloz earned 75 total points
ID: 9859556
it's possible to have a link to print a page yes - it's just automatic printing which isn't possible. the best i can think of is having a javascript function which is executed when the page loads by using onload with the body tag

loz
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question