473,597 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Table problem with iText.

dmjpro
2,476 Top Contributor
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
  1.  
  2.  
  3. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  4.    "http://www.w3.org/TR/html4/loose.dtd">
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  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>
  19.  
  20.     <body>
  21.  
  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>
  29.  
  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>
  40.  
  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>
  54.  
  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>
  67.  
  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>
  81.  
  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>
  97.  
  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>
  111.  
  112.     </table>
  113.  
  114.     </body>
  115. </html>
  116.  
Jul 10 '09 #1
3 6666
Dököll
2,364 Recognized Expert Top Contributor
@dmjpro
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:

http://www.devx.com/Java/Article/29309/1954

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:

http://www.cise.ufl.edu/~otopsaka/CI...omServlet.html

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!

Dököll
Jul 13 '09 #2
dmjpro
2,476 Top Contributor
@Dököll
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
Dököll
2,364 Recognized Expert Top Contributor
@dmjpro
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

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

Similar topics

4
2666
by: Daryl Middleton | last post by:
Can python be used to merge pdf documents into a single pdf file so that I do not have to manually insert each one. Thanks
1
2136
by: Ruchi Dayal | last post by:
Hi, I am using XSL-FO/FOP to generate PDF documents from XSLT. The resultant PDF can run into thousands of pages and this is where the whole problem is. FOP cannot handle such large outputs. Our initial solution was to manually feed limited records to FOP so that it wouldn't "bomb out". However, this is getting messier as the number of records themselves, increase. Due to previous architectural decisions, it is also not possible to
2
2169
by: Ivo | last post by:
I have this code to add a row to a table: var r=document.createElement('tr'); var c=document.createElement('td'); var cn=c.cloneNode(false); cn.className='tdname'; cn.appendChild(document.createTextNode(p)); var c2=c.cloneNode(false); var i=document.createElement('input'); i.type='text'; i.size=8; i.className='itext'; var i2=i.cloneNode(true); i.name=p+'pas'; i2.name=p+'fun';
4
2346
by: Mateo | last post by:
Hi! I have labels on my page (some are web forms controls, and some are plain HTML labels), and I need Mozilla compatibile way for reading label value. For example, in IE I can use this: value = document.form1.lblMyLabelControl.innerText; but, innerText property is not compatibile with W3 DOM, so mozilla doesn't support this.
4
2928
by: Elhanan | last post by:
hi.. i'm looking into ways for generating pdf's from xml, at first i thought fo / fop looks nice enough i mean it's standard, it's free and sperates concers, but i'm worried about fop from apache. is fo still viable?
1
1512
by: gaya3 | last post by:
Hi all, Please any one say me.. how to download the iText? Thanks in advance... -Hamsa
0
901
by: pkombli | last post by:
hi to every one . . i m using itext to create pdf files but m not getting how to connect database to create pdf using itext. .so plz help me
2
3067
by: Toni Pohl | last post by:
Hi, some years ago I´ve implemented an classic ASP form which fills in data from a database into a PD-form. I used the free FDF Toolkit which worked very well. After submitting the PDF the asp-form reads the data of the datafields and write them into the database again. Now I want to implement an improved ASP.NET version with VB.NET and I found iText.net. - FDF seems to be completly outdated?
2
2211
m6s
by: m6s | last post by:
Good morning. I have a major issue with iText. Major but most of all ridiculous. After the cration of a table like that tbl = new Table(7, dataTbl.Rows.Count); tbl.setBorderColor(System.Drawing.Color.LightGray); tbl.setDefaultCellBorderColor(System.Drawing.Color.LightGray); tbl.setAlignment(Element.__Value.ALIGN_CENTER); tbl.setPadding(2); tbl.setWidth(( w - 495 ));
0
7965
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7885
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8031
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6686
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5847
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5426
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3881
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3923
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.