Control printer from browser - Page 2

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Re: Control printer from browser

Robert Heller wrote:
Quoted text here. Click to load it

And even if he could control what the user's doing - what's going to
stop the user from printing one copy then photocopying it hundreds of times?

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: Control printer from browser

Quoted text here. Click to load it

You have pretty much hit the nail on the head. It's for a ticketing
This would be a web client for cashiers (there is a desktop app for
them already). This should be a cheap solution to open a spot to sell
tickets with just PC/internet/printer. There's no problem with a
desktop application when you can control the "ticket printer"
directly. But there's a problem when you want that to do with a
browser and just a regular printer..
We have unique barcode in place but if several people arrive with the
same ticket we would like to be sure it did not happen by using our
system. That's why we want to log the actions done via printer and
integrate that data in the system.

Re: Control printer from browser

Quoted text here. Click to load it
The browser really doesn't enter into this at all.
If I have a "regular" printer connected to my pc, I can easily set the
pc's spooler to allow printing in offline mode and then ask it to
print as many times as I like.
Or I can set my "regular" printer as say the CutePDF Writer. Once I
have printed to there, I can print as many copies as I like.
And talking of copies, as others have pointed out, since the printing
will happen on a "regular" printer on "regular" paper, there will be
no appreciable difference between the first print of a ticket and any
photocopies that I may make.

I have to say that if you didn't realise any of the above, then you
really did not do the analysis and design part of this project at all

Quoted text here. Click to load it

See above comments!

Re: Control printer from browser

At Mon, 7 Jun 2010 03:20:16 -0700 (PDT) Captain Paralytic

Quoted text here. Click to load it

And given the popularity of multi-function printers (printer, copier,
fax, scanner, all-in-one), it is possible to: print to the fax (fax a
copy to a friend(?) and/or scan and/or copy right on the same machine as
the original was 'printed' on.

Quoted text here. Click to load it

Right.  The OP's only sane solution is:

Key the bar code to an identity and have the ticket taker / box office
demand an ID.  The bar code pops up a name (+ address, etc.) and the
ticket taker checks the name against the ID.  You can also print the
*name* on the ticket, along with the words "Positive / Photo ID might
be required for admission -- tickets are not transferable" (or text to
that effect).  Trying to 'control' the end-user's printer is just
*never* going to work.  Take it as a given.

Quoted text here. Click to load it

Robert Heller             -- Get the Deepwoods Software FireFox Toolbar!
Deepwoods Software        -- Linux Installation and Administration -- Web Hosting, with CGI and Database       -- Contract Programming: C/C++, Tcl/Tk


Re: Control printer from browser

Quoted text here. Click to load it> wrote:
Quoted text here. Click to load it

It's threads like these that make me sad when I'm not quick enough to
join in.

All I'll add is that it would be a good idea to generate a watermark
that encompasses the name and address area so that it cannot be edited
with someone else's details and copied anyway.

Re: Control printer from browser

Quoted text here. Click to load it

Unfortunately we are not the ones doing the analysis. When I saw
requirements first thing I said this feature is going to be close to
impossible to implement.

I see many comments how user can always simply make a copy - this
doesn't concern us. We just need to control the enviroment of cashier
(there's a different system for people buying tickets online). We can
control cashier's computer thus not allowing any other applications
than needed for work.

And I realise this goes way beyond PHP since it's probably will be
only used to generate ticket and maybe communicate with some other

Something like Internet Printing Protocol would be great but seems
like a total overkill.

Re: Control printer from browser

Audrius Kosys wrote:

Quoted text here. Click to load it

Are you implying that the people you are trying to police are actually
working for you? They are the cachiers selling the tickets to the public?

And it is these poeple you are trying to stop from cheating by printing
duplicate copies of tickets?

You have far bigger issues to hand than how many tickets you have printed.
Fire the bastards, or report them the the authorites if you can prove they
have done something like this.

Then hire some honest people.

Re: Control printer from browser

Audrius Kosys wrote:
Quoted text here. Click to load it

Please read what everyone has told you.  YOU CAN'T DO IT!

And if you can't trust your own employees, you have much bigger problems.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: Control printer from browser

Quoted text here. Click to load it

The thing I have been trying to get through to you is that these are
precisely the same thing! The "environment" of the cashier extends to
more than just the computer. You say that " [a] user can always simply
make a copy - this doesn't concern us." and I say that you are simply
not thinking this through.

The cashier IS a USER. If the "environment" of the cashier (i.e. the
office) contains a photocopier, than that cashier can print on their
"regular" printer and make a copy on their photocopier. And as I also
said, they can tell their printer to print offline and then tell it to
not delete the spooled output once printed.

Once the output is in the spool, it is in a file on the machine. Once
it is in a file on the machine, it can be printed as many times as one

It really makes no difference whether your application sends it only
once. You are looking at the wrong problem.

Have you thought of requiring a credit card to purchase the ticket and
printing the last 4 digits of the card on the ticket? As with airline
tickets, the printed one would not be valid unless produced with the
associated credit card.

Quoted text here. Click to load it

Re: Control printer from browser

Captain Paralytic wrote:
Quoted text here. Click to load it

Indeed they can, but the fact of multiple tickets when only one print
file was sent, at least narrows the fraud down somewhat.

In particular, it removes the blame from the server  and associated
teams and software.

The cashier cant scream 'computer bug' 'it wasn't me' when you have a
time and date stamped request of the printing of a single ticket...

Fraud prevention is as much about knowing its happening, and more or
less where, as stopping it.

That way you get to sack the right people.

I recall a shop once, that installed a stock control/POS system. And
discovered a very high loss rate on cans of tuna fish stacked right by
the door. The cans were moved in where they could be seen, and the
losses stopped.

In this case, you could prevent photocopying by using special
watermarked paper.

You could monitor paper used to tickets issued, to see if more paper was
being printed than tickets sold..

there are ways..

The more I understand the context, the more sense the original
specification makes.

Its basic accounting. so that bean counters can pick over the residue of
a fraud is suspected.

And that also biasses me towards server side printing to remote
printers: logs will be kept of print requests on the server. Which is
dine by software that is not part of the PHP coding, so cant be blamed
or so easily subverted.

The overall architecture is clear now.

Each office is internet equipped on a static IP address. If NAT routing
is used, each office has a static IP networked printer, and port
forwarding to it from  the external IP address of the office's 'printer

The local office firewalls permit incoming print requests ONLY from the
server IP address(es).

As each remote office comes on stream, a print queue is set up for it on
the server, with a unique name like 'PARIS-IV' associated with its
internet IP address and port.

Every cashier logs in to a database type set-up where the actual
cashier, his location and print name are catalogued. So 'Jean Sans
Cullottes' 'PARIS-IV' are associated with a unique record ID, carried
probably as a session variable.

When time comes to print, the server assembles the data, and simply
sends to to the queue called 'PARIS-IV' which it looks up in its data
base as being associated with cashier no #6623467, as described in the
session variable, or whatever..

The queue opens a connection direct to the printer in {PARIS-IV, and
dumps the data to it, recording it in the system logs.

If smart the PHP can check the print status and tell the cashier that
the queue was successfully flushed. Or report problems 'printer out of
paper/offline/showing paper jam' etc..

standardised printers/routers highly desirable, and standardised
browsers too.

I've done similar through domestic broadband setups: it works. Slow mind
you. Proper links would be much faster.

Gave my colleague the fright of his life when the printer by his
computer some 100 miles way from me, woke up and printed a graphic he
hadn't sent to it :-)

Re: Control printer from browser

Audrius Kosys wrote:
Quoted text here. Click to load it

Then tell the product customer, what we have told you, that even if it
was implemented, it would make no difference to overall security, and if
they still have their heads stick up their arses, find another customer.

Quoted text here. Click to load it

Well is cashier's computer local to the server?

if so, print from the SERVER. Or open up a firewall port to internet
print from the server direct to the printer.

Quoted text here. Click to load it

No need for that. If the printer runs e.g. standard net print protocols,
(port 931 IIRC) simply set up a print queue on the server to print to
that printer. That's a firewall issue and a setup issue for the print
management on the server. No need to do more than that.

It will be a bit slow, but it will be reliable. All the checks and
balances you need are in the print queue system already. And invoking a
print queue from PHP is hardly rocket science.

Because PHP CAN directly interface with the underlying operating system
of the server it runs on and its facilities. In a way no browser can.

Is the server your own server? or is it shared and hosted? If the former
and you have/will have full administrative control then its really not
that hard. Even I managed it ;-)

This is all it takes, for example., to make a linux machine print to any
printer it knows about anywhere in the world that it has access to.

function print_pdf_file($printer)
    global $pdf;
    $buf = PDF_get_buffer($pdf);    
    $handle=popen("/usr/bin/lp -o sides=one-sided -d ".$printer." -- -", 'w');

when the data to be written is in the global variable $PDF, the print
queue name is $printer, and the rest is down to making sure it comes out
on the right paper from the right tray one sided etc etc.

The harder part is setting up the print queue to the networked printer:
but that's no different whether its in the same room or the other side
of the world really. As long as the target IP address:port can be
accessed from the server machine, its good to go.

Its entirely possible that if - say - the cashiers machine is Linux
(probably windows also, but I know fuck all about windows printing) that
you can, if that machine is on a fixed IP address, connect a printer to
it, and 'share' it via some standard method (CUPSD?) and 'tell' the
server to print to it. i.e. pass the printer queue name  up to the
server in a post variable, session variable  or cookie or the like.

Provided the server has a print queue set up to print to it.

You need but three things to be so for this to be possible

1/. You must have the ability to set up print queues on the server.

2/. You must have the ability to control any firewalls between the
cashiers machine and the server.

3/. You need a fixed IP address policy to allow the cashiers machine or
printer at least, to be an identifiable target for print queue requests.

There are a couple of other issues you may need to sort out, and that
revolves around exception handling: you may need to provide some web
interface to the print queue on the server to identify when printing is
screwed up because the printer is offline, out of paper or jammed etc.

But if you use linux, the CUPS system already has a web interface. Which
is half the battle., I've restarted remote print queues and done
diagnostics on them to remote staff.

Additionally you can examine the output of lpq and lpstat on a server
and parse them into HTML format for quick diagnostics if the expected
page fails to emerge from the printer.

Finally, don't even try to parse HTML for printer output: write a
special page that formats the data using a PDF library or similar, and
send that.

I am cheapskate, I used PDFlib lite - the free one, and managed to get
it to almost print an entire brochure., I had a lot of nasty formatting
to work out, so its not perfect. It does spit out 100% correct invoices
and the like, however.

So apart from the networking issues above, write some PHP that assembles
the data you want into PDF format, and sends that to the selected print
queue. You an do what you like then: Its all under server and PHP control.

I would advise, subject to my  prejudice, that Linux should be on the
cashiers machine, if for no other reason than you can strip it down to
do just the jobs in hand, without them being able to make it do anything
else. Its also runs printers well in a network sense, if you decide to
plug a USB printer into its ports. Network printing between machines has
been part of *nix as long as networking has. It works. Microsoft is less
network capable at this sort of level.

Re: Control printer from browser

Quoted text here. Click to load it

If several people arrive with the same ticket, clearly at most one of those
duplicate tickets is legitimate and the others fraudulent. Why do you imagine
that it makes any difference at all *how* the fraudulent duplicates were
created? Your action is the same regardless: disallow their use.

Re: Control printer from browser

Doug Miller wrote:
Quoted text here. Click to load it

I think the problem is described completely here.

Make YOUR system have its won set of barcodes, and if people have copied
them, well shucks, its their problem not yours.

Since they alone could have done the copying, if they onsell copies, its
not your problem is it?

first in who has correct ID gets to get in, the rest get turned away.

Normally you would email a PDF. if they dont know the email address,
they get turned away. If someone else presents the same e-mail address:
Tough. Call the cops.

Re: Control printer from browser

Audrius Kosys wrote:
Quoted text here. Click to load it

Indeed. Unless the printer is inside your own bedroom then you cannot
control it, and perhaps not even then. You do have to go to the bathroom on

However, how does that help you? You sell a ticket from a totally guarded
locked up printer and I simply walk across the rode to the newsagent and
have it photcopied.

Quoted text here. Click to load it

Now you are talking. Why did you not mention this Right Up Front? This
single fact changes entirely the whole argument. Forget totally about the

Quoted text here. Click to load it

So what if they did? So what if they photocopied the ticket, printed it
twice, or whatever. They are fraudulant copies and you simply call the
authorities in, probably the police. Somebody paid for *one* ticket number
and several people turn up with that ticket number? Fraud. Clear and simple.

We buy online tickets here in Australia all the time. Pay your money online
for a, say, rock concert and they emial you a ticket that you can print. I
usually print a couple or three just in case I loose one. The operative
thing here though is that the ticket is *emailed* to me. Then I print it on
*my* printer. A controlled environment.

You however should be able to simulate this. The page containing the
"ticket" can only be viewed by whoever is actually making the transaction to
pay the money to obtain the ticket. Nobody else, say the next block in the
queue to use the ticket machine, can access that ticket.

Now, who would be stupid enough to give a copy of such a ticket to someone
else?. The fact that there is a big friendly bar-code on the front fairly
screams out the fact that somebody at the door is going to scan and validate
it. At worst someone else gets charged with attempted fraud, as that ticket
number is already inside. At worst YOU get charged with attempted fraud as
somebody else is inside watching the concert with a ticket number you paid

Quoted text here. Click to load it

You are attempting to solve the most totally wrong part of the problem. A
problem which (see above) is not really one anyway. Let them
print/photocopy/forge-with-brush-and-india-ink hundreds of tickets. You sold
one unique ticket number. One ticketholder gets in. The rest help the
authorities with their investigations.

Re: Control printer from browser

rf wrote:
Quoted text here. Click to load it

Whilst I agree at the security level, if the customer thinks he wants it
thisaway, then if you can make it thisaway, that's good, because you
have done what he asked, and any security issues are not your problem,
but his.

The key piece of information that the OP has revealed, is that it is not
some random user on the net that he wants to print to, but a cashier
using a machine/environment supplied by him.

This makes it all possible, because other software than a browser can be
installed to accept print requests from the server. Either on the
operators machine, or implicit in a  standalone networked printer.

At this point we are not concerned with the security and vagaries of
browsers, but a simple exercise in getting a web server to print
directly to as networked printer. The broswer is no longer in the loop
at all.

The fact that its probably a relatively useless way to achieve security
is sidelined. That's what the customer wants: That's what he will get.

And its actually a very effective way to get much better printouts from
a server side program. When I compared 'printing the web page' to
sending a properly formatted PDF to a printer, it was chalk and cheese time.

Quoted text here. Click to load it

Re: Control printer from browser

The Natural Philosopher wrote:
Quoted text here. Click to load it

And it'd be a pretty poor developer who gives the customer what the customer
wants, knowing quite well the the issues, security or otherwise, go way
beyond what the customer wants, or needs, or even knows about.

Re: Control printer from browser

rf wrote:
Quoted text here. Click to load it
well see my later posts. As to why its not totally useless. Also, get
off your high horse and into the real world: you may advise customers,
but customers who are contradicted and who have their intelligence
insulted, even with due cause, do not remain customers for long.

Now the context is clear, its also clear its actually a good way to do
things and will produce better print results anyway.

I've actually had to sole this exact problem: my way was to email PDFs
to random customers, but the main sales office gets the server to print
direct to printers. I was going to extend it to one remote site, but we
couldn't get broadband in, so he has to download via dialup and print
PDFS as well.

I am the other remote site, and I never bothered to give the server
direct access to my local printer, since I have little need for printed
output..I act as support mainly and its all on-screen stuff..

but it would be the work of only an hour or two to set up.

the real problem for it being asked about on a PHP group, is that it has
little to do with PHP, and everything to do with setting up and maintain
secure network links over the biggest WAN in the world.

Which is where my real experience is - PHP is just a noddy tool for
making web sites work. The world is a lot bigger than that. I know
enough PHP to make sites work. I know a lot more about how to make WANS

Re: Control printer from browser

Quoted text here. Click to load it

Thank you for your input. It has been very refreshing posts to read.
Seems like you exactly got our motives behind such implementation. We
and our customers perfectly understand that it's not perfect but it's
better than nothing :)

Re: Control printer from browser

Audrius Kosys wrote:
Quoted text here. Click to load it

Well if you are controlling cashiers machines and the server, consider
linux for both, and consider proper networked laser printers in the
offices. I swear by the larger HP machines, that are globally available,
built to last, and make first rate workhorses, and whose network
protocol is fully supported by the Linux print systems. If they are
networked on the standard HP port, talk postscript, and are locally
supportable, they are almost easy to get working.

the default port I have is 9100 for jet direct printing: its a raw TCP
interface to the printers, and CUPS just 'understands it', and its
bidirectional: errors come back from it to the server.

All I would have to do to make it remotely accessible here is to set up
a port redirect for that port, and open a hole in my firewall. And set
up a queue for it on a remote machine.

then the server doesn't really know or care where the printer is: its
just something at the end of a network.

Re: Control printer from browser

Quoted text here. Click to load it

Fandango and do this already.  You select the movie you
want to see, theater, date, and time.  The application displays a ticket
on the computer screen the buyer must use _their_ printer.  All this can
be controlled by php.  

At best, you can put a button on the browser page that executes a
javascript print() function.  You can only control the printer to the
degree that a browser has functions or features to do that.  Javascript
can send page to the default printer.  

If you write a java applet that the user runs from within the browser
and talks to the printer through an existing java servlet running on
each user's system, that might be able to do the lower level printer
stuff you need from the browser.  But php, running on the server, just

DeeDee, don't press that button!  DeeDee!  NO!  Dee...
[I filter all Goggle Groups posts, so any reply may be automatically ignored]

Site Timeline