<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS82bVR6ei5wbmcifQ==” alt =“在此处输入图像说明”>“ >>
<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS92M242QS5wbmcifQ==” alt =“在此处输入图像描述”>“ >>
我想在具有2个单元格的表中添加垂直线分隔符。希望使行在内容中心对齐(2个文本单元格)
添加实际和预期的图像。
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; }
我想在具有2个单元格的表中添加垂直线分隔符。希望使行在内容中心对齐(2个文本单元格)。添加实际和预期的图像。私人PdfPTable ...
尝试添加边框宽度为0的单元格吗?像这样吗?
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");