• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Print Friendly presentation with servlets or JSP

 
J You
Greenhorn
Posts: 29
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am wondering what will be a good solution in such a sceanario:
you use Java Servlets/JSP to retrieve data from database and
present them in a table,like most applications do. The table
will contain 100 rows,and you are permitted to present the
table in one homepage like below:
Table Title
--------------------------------------------------
|----|----|----|----|-----|-----|-----|-----|-----|
|-------------------------------------------------|
......
This is a easy work.
But you boss also want to print this table,i.e,there
is a button in the page and when he press it,the table
will get printed with his printer,also,the printed
table should be in a "nice" format: 25 rows per page,
and there is a 'title' header in every page.
So,what is your opinion?
I don't think there is instant solution here,
the problems are:
1,how the client side script start the printer job?Maybe
need a standalone client application?
2,how to generate the "printer friendly" pages?
Maybe,it is better to transform the table to a .PDF file so
the client can print it with Acrobat Reader?Is there any
XXX2PDF package there?
I am just very intereted in this problem and hope to find
a way to deal with it.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17619
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To get the maximum control over the appearance of the page without having to fight Java security, it's easiest to produce the report as a PDF. I've used the "retepPDF" package quite successfully. It's now named "gnujpdf" available at http://www.sourceforge.net
One caution, though. If you write the PDF straight to the HTTP output stream, many appservers won't set the content-length header, which will cause Netscape to be fail to display the page. One way to solve that is to write the PDF to a temp file, get its length, send the header, then copy the temp file to the HTTP output stream, and finally delete the temp file.
 
Kim MacKellar
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does this PDF package use the AWT? Meaning if I'm running a servlet on a server that doesn't have XWindows or Windows will this work?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17619
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does seem to want to have a graphics environment to link to. I think it may be getting its font metrics from there, based on some recent messages I seen go across the log. They tried to base it on the Java rendering API.
There are also several commercial PDF Java packages out there.
 
Tim Lauster
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have the names of some commercial JAVA PDF packages?
Have you used any of them? Is there one that you recommend?
Thanks.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17619
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got by with the retepPDF package, so I don't have any experience with the commercial ones. I see them advertised in Java-related magazines, though. You could also search the Web.
 
Manjunath Reddy
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to look at the FOP(print formatting objects) from xml.apache.org. Its freeware and uses xsl to transform XML documents to professional pdf. one can produce amazing pdf's with tables, images and charts with the FOP objects. To get started check out the following article.
http://www.planet-source-code.com/xq/ASP/txtCodeId.2182/lngWId.2/qx/vb/scripts/ShowCode.htm
cheers,
mpr
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic