• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Print invoice - JSP

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67670
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Print on the server or the client?
 
Kavita Shivani
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
on the client side.
 
Sheriff
Posts: 9697
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ...
 
Kavita Shivani
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks everyone for the response.

Kavitha.
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Kavita Shivani
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
An elephant? An actual elephant. Into the apartment. How is the floor still here. Hold this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic