• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

getting a html page in printable form

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
can any body tell me is there any java api or other open source code available so that i can have a print option on the html pages i generate through servlet.

actually some pages are divided into frames and i want to give a print button or clickable image on each frame so that when user click that the page get set in printable format.

is this thing possible and if yes pls guide me how.
thanks and regards
khushi
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you are asking for is client side code - which would be awkward. You'd need to write an applet which used the Java Print Service to find a printer (if the user has any set up), which used the static(?) HTML page to build a printable object and then print it. You could do it this way, but a far easier way of doing it would be to popup just the frame your user wants to print and let them print this as they would any other web page. And you could do that with a little bit of JavaScript.
 
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

Use Javascript code

<script language="java">
window.print(1);
</script>

This will print the output of page where you will write this code

Regards
Rohit
 
khushi paul
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi rohit,i used this code on click event of a button,i get my frame printed but complete frame is not printed.
actually it is a scrollable frame and only the contents that are visible on the screen at a time are printed.
what might be the problem?
regards
khushi
 
Rohit Bhagwat
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I never faced such problem,as I didnt had any scrollable frame.

I dont know the solution but will have to think on it..

Will get back to you later

Regards
Rohit
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The typical solution would be for you to have an alternate 'view' of the page which is printer friendly (reduced graphics, no frames, etc. etc.)

If your app is not database driven this could be a pain to develop alternate versions of all your pages.

Then again what is in the top/side frame that needs to printed? Usually these are used for menus while the content is stored in the center frame.

Is there a reason why a roundtrip to the server to generate a printable page is unacceptable to the user? It would save you the headache of fooling with javascript.

Tom
 
khushi paul
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks thomas,
yes i am developing a database oriented application but it is not possibel for me to rewrite all the pages.

actually there are two frames row wise.the upper frame contains alot of information which is fetched from 2-3 database tables and presented in a tabular form,moreover various links are also present on that page.
when any link is clicked the related information(page) appears in the lower frame.

i hope i am clear to you.
any other suggestion pls....

regards
khushi
 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I feel print this page is the same page without frames ideally in a pop up window.

You may need to convert the scollable frame to a html page.

You can get the complete html source of the frame if utilise a java.net.URLConnection class and display the same for printing in a new html page.

Regards
 
khushi paul
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks sarath,
can you give a code snippet for that?
regards
khushi
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic