I want to add a vertical line separator to a table with 2 cells . Want the line to be aligned at the center of the contents (2 text cells)
Adding images of actual & expected .
private PdfPTable createHeader() throws Exception {
PdfPTable table = new PdfPTable(2);
BaseColor headerColor = new BaseColor(235, 244, 252, 1);
table.addCell(createCell(getMemberDetails(),78,0,0,10,0,1, headerColor, ALIGN_LEFT, ALIGN_JUSTIFIED));
table.addCell(createCell(getAccountDetails(),78,0,0,10,0,1, headerColor, ALIGN_LEFT, ALIGN_JUSTIFIED));
return table;
}
private Paragraph getAccountDetails() {
Paragraph paragraph = new Paragraph();
Font labelFont = new Font(Font.FontFamily.HELVETICA, 8, Font.BOLD, new BaseColor(85, 85, 85));
Phrase phrase = new Phrase("ACCOUNT",labelFont);
paragraph.add(phrase);
paragraph.add(Chunk.NEWLINE);
labelFont = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, new BaseColor(51, 51, 51));
phrase = new Phrase("000001",labelFont);
paragraph.add(phrase);
return paragraph;
}
private Paragraph getMemberDetails() {
Paragraph paragraph = new Paragraph();
Font labelFont = new Font(Font.FontFamily.HELVETICA, 8, Font.BOLD, new BaseColor(85, 85, 85));
Phrase phrase = new Phrase("MEMBER",labelFont);
paragraph.add(phrase);
paragraph.add(Chunk.NEWLINE);
labelFont = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, new BaseColor(51, 51, 51));
phrase = new Phrase("John Doe",labelFont);
paragraph.add(phrase);
return paragraph;
}
Try adding cells with 0 width border? something like this?
PdfPCell cell = new PdfPCell(new Phrase("Cell 2", new Font(Font.HELVETICA, 8f, Font.NORMAL, Color.YELLOW)));
cell.Border = Rectangle.BOTTOM_BORDER | Rectangle.TOP_BORDER;
cell.BorderWidthBottom = 0f;
cell.BorderWidthTop = 0f;
cell.BorderWidthLeft = 10f;
cell.BorderWidthLeft = 0f;
table.AddCell(cell);
table.AddCell("Cell 3");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.