471,893 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,893 software developers and data experts.

Table problem with iText.

2,476 2GB
I think iText commonly used to create or manipulate PDF document in Java.
So finally i decided to throw a question over here. For two days i am struggling.

I encountered two types of table ..
1>Table: table can be easily created with row span or col span but still has a problem with vertical alignment of cell content.
2>PdfPTable: table can be easily created by col span but having a bit complex with row span. But it offers well vertical alignment of cell content.

Finally i decided to design the table with Table Class. Because what i am having the cells(with row span and col span), it's quite tough to draw the table with PdfPTable. With Table class it's easy to draw. But still struggling with vertcal alignment.
I think who already familiar to iText can solve my problem.

If you can, you can have a look at my HTML.
Run this stand-alone you will get the HTML view of which i am trying to design in PDF.
My code goes here...

Expand|Select|Wrap|Line Numbers
  3. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  4.    "http://www.w3.org/TR/html4/loose.dtd">
  13. <html>
  14.     <head>
  15.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  16.         <title>Time Table View</title>
  17.         <link rel="Stylesheet" href="./style1.css"/>
  18.     </head>
  20.     <body>
  22.                 <table border="1" cellpadding="5" cellspacing="5" style="background-color:#CCCCCC">
  23.                     <tr><td class=tableheader>Day Name</td>
  24.             <TD class=tableheader>7:30:AM-8:25:AM</TD>
  25. <TD class=tableheader>8:30:AM-9:25:AM</TD>
  26. <TD class=tableheader>9:30:AM-10:25:AM</TD>
  27. <TD class=tableheader>10:30:AM-11:25:AM</TD>
  28. <TD class=tableheader>11:30:AM-0:25:PM</TD>
  30. <TD class=tableheader>1:30:PM-2:25:PM</TD>
  31. <TD class=tableheader>2:30:PM-3:25:PM</TD>
  32. <TD class=tableheader>3:30:PM-4:25:PM</TD>
  33. <TD class=tableheader>4:30:PM-5:25:PM</TD>
  34. </TR>
  35. <TR>
  36. <TD style='background-color:#0FAA8B' rowspan=5 colspan=1 >Monday</TD>
  37. <TD rowspan=1 colspan=1 style='background-color:#66CCFF' >IM21003/C4</TD>
  38. <TD rowspan=5 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  39. <TD rowspan=5 colspan=1 style='background-color:#66CCFF' >ME30604/C3</TD>
  41. <TD rowspan=5 colspan=1 style='background-color:#66CCFF' >ME30604/F127</TD>
  42. <TD rowspan=5 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  43. <TD rowspan=5 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  44. <TD rowspan=5 colspan=1 style='background-color:#66CCFF' >IM41008/F116</TD>
  45. <TD rowspan=5 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  46. <TD rowspan=5 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  47. </TR>
  48. <TR>
  49. <TD rowspan=1 colspan=1 style='background-color:#66CCFF' >IM57002/C3</TD>
  50. </TR>
  51. <TR>
  52. <TD rowspan=1 colspan=1 style='background-color:#66CCFF' >ME30604/C3</TD>
  53. </TR>
  55. <TR>
  56. <TD rowspan=1 colspan=1 style='background-color:#66CCFF' >IM57002/C3</TD>
  57. </TR>
  58. <TR>
  59. <TD rowspan=1 colspan=2 style='background-color:#66CCFF' >IM57002/C3</TD>
  60. </TR>
  61. <TR>
  62. <TD style='background-color:#0FAA8B' rowspan=2 colspan=1 >Tuesday</TD>
  63. <TD rowspan=2 colspan=1 style='background-color:#66CCFF' >ME30604/F127</TD>
  64. <TD rowspan=2 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  65. <TD rowspan=2 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  66. <TD rowspan=2 colspan=1 style='background-color:#66CCFF' >IM31006/Computer Lab</TD>
  68. <TD rowspan=2 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  69. <TD rowspan=1 colspan=1 style='background-color:#66CCFF' >IM21003/C8</TD>
  70. <TD rowspan=2 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  71. <TD rowspan=2 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  72. <TD rowspan=2 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  73. </TR>
  74. <TR>
  75. <TD rowspan=1 colspan=2 style='background-color:#66CCFF' >IM57002/C3</TD>
  76. </TR>
  77. <TR>
  78. <TD style='background-color:#0FAA8B' rowspan=1 colspan=1 >Wednesday</TD>
  79. <TD rowspan=1 colspan=5 style='background-color:#66CCFF' >ME30604/N</TD>
  80. <TD rowspan=1 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  82. <TD rowspan=1 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  83. <TD rowspan=1 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  84. <TD rowspan=1 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  85. </TR>
  86. <TR>
  87. <TD style='background-color:#0FAA8B' rowspan=1 colspan=1 >Thurshday</TD>
  88. <TD rowspan=1 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  89. <TD rowspan=1 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  90. <TD rowspan=1 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  91. <TD rowspan=1 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  92. <TD rowspan=1 colspan=1 style='background-color:#66CCFF' >ME30604/N</TD>
  93. <TD rowspan=1 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  94. <TD rowspan=1 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  95. <TD rowspan=1 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  96. <TD rowspan=1 colspan=1 style='background-color:#CCCCCC' >&nbsp;</TD>
  98. </TR>
  99. <TR>
  100. <TD style='background-color:#0FAA8B'>Friday</TD>
  101. <TD>&nbsp;</TD>
  102. <TD>&nbsp;</TD>
  103. <TD>&nbsp;</TD>
  104. <TD>&nbsp;</TD>
  105. <TD>&nbsp;</TD>
  106. <TD>&nbsp;</TD>
  107. <TD>&nbsp;</TD>
  108. <TD>&nbsp;</TD>
  109. <TD>&nbsp;</TD>
  110. </TR>
  112.     </table>
  114.     </body>
  115. </html>
Jul 10 '09 #1
3 6514
2,364 Expert 2GB
Hey dmjpro!

I am probably not giving what you needed here but I reckon you are trying to print to pdf. I suspect you will be happy with jasper report...

You can do a lot of manipulation with iReport. Here are a couple of links I pulled up that I think may help you further your pdf prints. You will need the iReport software to build your pdf document:


Again, I am not sure if you'll take the bait, but I am convinced you will like this. You simply need to get it to load through your html pages. You can use a servlet to do that:


You will still need to do some work, but this should get you on your way.

View source on the HTML to fire servlet used to load your report.

By the way, iReport includes iText technology. Have a great week!

Jul 13 '09 #2
2,476 2GB
Ah! .... ;)
I forgot to mention that i tried iReport. But iReport takes one query, but my query gives each class details in one row. Then how it is possible?
Jul 13 '09 #3
2,364 Expert 2GB
You need to use Frames then, if I am getting what you are asking. With Frames you can have different queries adding to the same report. There's a fancy video out there on that.

Give that a go!
Jul 15 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Daryl Middleton | last post: by
2 posts views Thread by Ivo | last post: by
4 posts views Thread by Mateo | last post: by
4 posts views Thread by Elhanan | last post: by
1 post views Thread by gaya3 | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.