| Author |
Print invoice - JSP
|
Kavita Shivani
Ranch Hand
Joined: Aug 14, 2009
Posts: 44
|
|
Hi Everyone,
I am working on an application in which, I display an invoice and onclick of the print button, I need to print the invoice. I was suggest to use window.print(); but I am not sure if that is for printing the web page. I just want the Invoice table on my page to be printed without any other HTML things on the page.
Please suggest on how this is done generally.
thanks,
Kavitha.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56229
|
|
|
Print on the server or the client?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Kavita Shivani
Ranch Hand
Joined: Aug 14, 2009
Posts: 44
|
|
|
on the client side.
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
Once I had such a requirement, so what I did was, give an ID to the specific table to be printed, opened a new window through javascript, put the table (with the ID) as content of the new window and called the print on that new window. I think you can also do that with CSS for printing (a small tutorial here) but I've not used it so not sure. If there is any other simpler way, then I don't know about it ...
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
Kavita Shivani
Ranch Hand
Joined: Aug 14, 2009
Posts: 44
|
|
Thanks everyone for the response.
Kavitha.
|
 |
Samuel Behrman
Ranch Hand
Joined: Oct 02, 2009
Posts: 49
|
|
If you have an executing JSP script, can't you just stream the report to
a file or to a printing service like lpr? Then let the print subsystem
deal with printing or transmission over a slow link.
If you're asking for an automagic way of doing this, sorry, I don't know.
Hmm, if you print to RTF, then use a (local) JSP or Java app to remove
all the formatting, images, etc., would you have what you want? Just a
thought. Java does have an HTML/XML parser that would be useful reading
an RTF file, I think.
|
RAQ Report: Web-based Excel-like Java reporting tool.
|
 |
Kavita Shivani
Ranch Hand
Joined: Aug 14, 2009
Posts: 44
|
|
Thanks Samuel,
Yes I am thinking of something like that for my periodic reports probably I will save the reports in pdf. If I find that easy, I might as well make it same for all sorts of printings in my application.
regards,
Kavitha.
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
Guessing no one that answered so far realizes there can be different styles sheets that can be added to the document to hide info that you do not want to print/show.
Look into Print Media CSS
Eric
|
 |
 |
|
|
subject: Print invoice - JSP
|
|
|