boxable
boxable copied to clipboard
Change cell height
Hello Everyone,
I have created BaseTable according to example from https://github.com/dhorions/boxable/wiki
float margin = 50;
float yStartNewPage = myPage.getMediaBox().getHeight() - (2 * margin);
float tableWidth = myPage.getMediaBox().getWidth() - (2 * margin);
boolean drawContent = true;
float yStart = yStartNewPage;
float bottomMargin = 70;
float yPosition = 550;
BaseTable table = new BaseTable(yPosition, yStartNewPage, bottomMargin, tableWidth, margin, mainDocument, myPage, true, drawContent);
Row<PDPage> headerRow = table.createRow(15f);
Cell<PDPage> cell = headerRow.createCell(100, "Header");
table.addHeaderRow(headerRow);
Row<PDPage> row = table.createRow(12);
cell = row.createCell(30, "Data 1");
cell = row.createCell(70, "Some value");
table.draw();
contentStream.close();
mainDocument.addPage(myPage);
mainDocument.save("testfile.pdf");
mainDocument.close();
Table looks fine

but when I want change cell height like this
cell.setHeight(5f);
Content is not drawn in cell

I was trying with changing row height, font size change, but it didn't help.
Do You know how to fix it?
Are you sure that your text size are not bigger than your cell height? You should always ask yourself that. Thanks for the code snippet ! I take this and make quick tests ..
ohhh, it's a bug. I tried making bigger cell height where I am certain that the text would fit in but also didn't have better result.
Definetly a bug.
What I did to make cell higher
cell.setHeight(cell.getTextHeight() + 12.0f);
oh wow. That is very good. At least taking the text height and then increasing the cell height. Pretty clever :+1: When we go in other direction (making the cell height smaller), we need to reduce the font size first, possibly the cell paddings also and then setting the height lower than former cell's text height.
Hey, is there any news about this issue? I need fixed row sizes (height & width) in my project, so this issue is directly effecting me. Thanks a lot!
Hello, I also should work with lower Cell-hight or padding. Do you know a workaround to get a compact table? Thank you for helping! Joseph