PDA

View Full Version : Printing receipts



Yossi
4 Apr 2008, 1:03 AM
Hey,

I need a solution for printing receipts. My program needs to show a receipt in one way on the browser, and send it to the printer looking in another way.

In other words, I need to send something to the printer that's not shown on the browser. Is there a way to send an output straight to the printer?

I can export everything to PDF, excell or a word format (even though I'm not thrilled to do that).


In the final solution, I should send an XHR request to the server, and the server will send me the receipt back (it could have different data on it after the print, due to the government's request).

Thanks in advanced,
Yossi

evant
4 Apr 2008, 1:32 AM
Not directly from the browser you can't.

shane.fox
4 Apr 2008, 2:33 AM
You could investigate print stylesheets. See here:
http://www.alistapart.com/stories/goingtoprint/

I have never tried it myself though.

Good luck!

Yossi
4 Apr 2008, 4:19 AM
Not directly from the browser you can't.

What's the best solution to implant?
I prefer my that my customers bypass the "print" button every time.

I saw Saki's solution as a PDF file, it seems the best for now.

mjlecomte
4 Apr 2008, 6:54 AM
Not sure which post/link you're referring to from Saki, but I think this might be suitable for using TCPDF. There are several options for serving up the resulting pdf.

devnull
4 Apr 2008, 7:42 AM
many web sites ive seen often have a "printable version" link on receipt type data, which when invoked opens a popup window with a simple html based vew. the user is instructed to hit the print button in their browser, but i think i have seen some that prompt for printing automatically so perhaps that can be activated via javascript.
if you need more control over the look and feel than html tables provide, a pdf is the next logical step.

Yossi
4 Apr 2008, 11:44 AM
many web sites ive seen often have a "printable version" link on receipt type data, which when invoked opens a popup window with a simple html based vew. the user is instructed to hit the print button in their browser, but i think i have seen some that prompt for printing automatically so perhaps that can be activated via javascript.
if you need more control over the look and feel than html tables provide, a pdf is the next logical step.

I think that's the most logical solution.. I want it to be as automated as possible, without the print button jumping up..
Maybe an AIR application could do that, but that's beyond the scope of what I'm trying to do.

I just need it for receipts, so I could print them all at the end of the day.
A receipt in PDF is risky, because there's 1 field in there I ought to change called "original" into "replica" in the second print [The server will take care of the output..].

So what I thought of right now, is after a successful print, simply close the receipt window and send a query to the browser.
The problem is, what happens if the query wasn't sent, and the receipt was printed. That's a huge problem for my software.. (I might have IRS problems with that).

Maybe I could send a double-query.
1) Receipt was issued, but not printed. receipt.print=0
2) Request for print was sent -> Change receipt.print=1, showing receipt
3) Receipt was printed -> Print receipt + receipt.print=2

Now, if the computer fell (it could be the Internet connection that failed) while trying to print the receipt, I'll have receipt.print=1 in the database -> WITHOUT the receipt printed.
What could I do in that case, not knowing whether the receipt was printed or not.

Yossi
4 Apr 2008, 11:44 AM
Not sure which post/link you're referring to from Saki, but I think this might be suitable for using TCPDF. There are several options for serving up the resulting pdf.

I use PHP, it would be easy generating a PDF file..

devnull
4 Apr 2008, 11:52 AM
There is no way to guarantee that a reciept has actually been printed, and as such I would have a hard time believing that there is any such requirement from the IRS or other. All you know is that a receipt was sent to the client; what they do with it is out of your control.
Being this is the case, it makes sense to me to have the backend do whatever database query or whatever else is required for the transaction, then build the receipt and send it to the client. If you have a way of allowing the user to reprint a previous invoice (if that is applicable anyway), that seems like it would satisfy any possible requirements.
If you are talking about doing multi-page or multiple receipts at a time in an automated fasion, i think that would require making a multi-page pdf.

Yossi
5 Apr 2008, 3:23 PM
There is no way to guarantee that a reciept has actually been printed, and as such I would have a hard time believing that there is any such requirement from the IRS or other. All you know is that a receipt was sent to the client; what they do with it is out of your control.
Being this is the case, it makes sense to me to have the backend do whatever database query or whatever else is required for the transaction, then build the receipt and send it to the client. If you have a way of allowing the user to reprint a previous invoice (if that is applicable anyway), that seems like it would satisfy any possible requirements.
If you are talking about doing multi-page or multiple receipts at a time in an automated fasion, i think that would require making a multi-page pdf.

Yeah, that was my guess. In Israel the IRS has weird requirements that we must stand by. I need to check whether I must guarantee that the receipt was printed or not. Maybe they could approve it in a dialog window or something like that..

Wonder how other people in Israel manage with that in web services.

devnull
7 Apr 2008, 8:59 AM
You should examine the details of that requirement if you havent already, perhaps is is met simply by having a "print" button or link and verifying that the user clicked on it, regardless of what happens after that.

Steffen Hiller
7 Apr 2008, 9:20 AM
Hey Yossi,

take a look at my new extension Ext.ux.PrinterFriendly (http://extjs.com/learn/Extension:PrinterFriendly). It might be a good solution for you(, too).
More docu and version 0.2 is coming soon. See the example to get started with this extension...

Regards,
Steffen