I want to create two columns of data, where regardless of the height of the
left column, the data in the right column lines up with it.
FIELD: data might be many lines FIELD: only one line here
long, but that's okay, because we
want this to line up.
The code that I am trying to beat into submission does it this way:
PdfPCell cell2 = new PdfPCell(this.getFormattedString("DOCKET NO: ",
12, true));
cell2.setBorder(PdfPCell.NO_BORDER);
cell2.setColspan(1);
leftCol.addCell(cell2);
PdfPCell cell2Data = new
PdfPCell(this.getFormattedString(myVO.getCrtCaseNum(), 12, false));
cell2Data.setBorder(PdfPCell.NO_BORDER);
cell2Data.setColspan(1);
leftCol.addCell(cell2Data);
ArrayList<CourtCase> courtCaseList =
processor1.loadCourtCaseList("I",
0, null, myVO.getIntrCaseNum());
CourtCase vo = courtCaseList.get(0);
PdfPCell cell3 = new PdfPCell(this.getFormattedString("COUNTY: ",
12,
true));
cell3.setBorder(PdfPCell.NO_BORDER);
cell3.setColspan(1);
rightCol.addCell(cell3);
PdfPCell cell3Data = new
PdfPCell(this.getFormattedString(vo.getCourtLocation(), 12, false));
cell3Data.setBorder(PdfPCell.NO_BORDER);
cell3Data.setColspan(1);
rightCol.addCell(cell3Data);
PdfPCell cell4 = new PdfPCell(this.getFormattedString("TYPE: ", 12,
true));
cell4.setBorder(PdfPCell.NO_BORDER);
cell4.setColspan(1);
leftCol.addCell(cell4);
PdfPCell cell4Data = new
PdfPCell(this.getFormattedString(myVO.getCrimeDegreeDesc(), 12, false));
cell4Data.setBorder(PdfPCell.NO_BORDER);
cell4Data.setColspan(1);
leftCol.addCell(cell4Data);
PdfPCell cell5 = new PdfPCell(this.getFormattedString("NUMBER OF
COUNTS: ", 12, true));
cell5.setBorder(PdfPCell.NO_BORDER);
cell5.setColspan(1);
rightCol.addCell(cell5);
PdfPCell cell5Data = new
PdfPCell(this.getFormattedString(myVO.getOffenseCountNum() + "", 12,
false));
cell5Data.setBorder(PdfPCell.NO_BORDER);
cell5Data.setColspan(1);
rightCol.addCell(cell5Data);
PdfPCell cell6 = new PdfPCell(this.getFormattedString("CRIME: ", 12,
true));
cell6.setBorder(PdfPCell.NO_BORDER);
cell6.setColspan(1);
PdfPCell cell6Data = new
PdfPCell(this.getFormattedString(myVO.getOffenseDesc(), 12, false));
cell6Data.setBorder(PdfPCell.NO_BORDER);
cell6Data.setColspan(1);
leftCol.addCell(cell6);
leftCol.addCell(cell6Data);
PdfPCell cell9 = new PdfPCell(this.getFormattedString("PLEA: ", 12,
true));
cell9.setBorder(PdfPCell.NO_BORDER);
cell9.setColspan(1);
cell9.setMinimumHeight(12);
PdfPCell cell9Data = new
PdfPCell(this.getFormattedString(myVO.getPleaAgreement(), 12, false));
cell9Data.setBorder(PdfPCell.NO_BORDER);
cell9Data.setColspan(1);
rightCol.addCell(cell9);
rightCol.addCell(cell9Data);
String coDefendants =
processor1.loadCoDefendantNames(myVO.getIntrCaseNum(),
offender.getOffenderNum());
if (coDefendants == null ||
coDefendants.trim().equalsIgnoreCase(""))
coDefendants = "None";
PdfPCell cell7 = new
PdfPCell(this.getFormattedString("CO-DEFENDANTS:
", 12, true));
cell7.setBorder(PdfPCell.NO_BORDER);
cell7.setColspan(1);
PdfPCell cell7Data = new
PdfPCell(this.getFormattedString(coDefendants,
12, false));
cell7Data.setBorder(PdfPCell.NO_BORDER);
cell7Data.setColspan(1);
float oldHeight = leftCol.getRow(leftCol.size()-1).getMaxHeights();
leftCol.addCell(cell7);
//float cellHeight = cell7.getMaxHeight();
leftCol.addCell(cell7Data);
PdfPCell cellBlank = new PdfPCell(this.getFormattedString("", 12,
true));
cellBlank.setBorder(PdfPCell.NO_BORDER);
cellBlank.setColspan(1);
leftCol.calculateHeightsFast();
float newHeight = leftCol.getRow(leftCol.size()-1).getMaxHeights();
cellBlank.setMinimumHeight(newHeight - oldHeight);
rightCol.addCell(cellBlank);
rightCol.addCell(cellBlank);
The problem is that the last cell in the left column has enough data that it
takes up several lines--but the cells in the right column are squeezed down
to just the height required for the text that they have. What I need is
some way to make the cells in the left column and the cells in the right
column line up.
--
View this message in context:
http://itext-general.2136553.n4.nabble.com/vertical-cell-alignment-tp3577258p3577258.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Discover what all the cheering's about.
Get your free trial download today.
http://p.sf.net/sfu/quest-dev2dev2
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php