Closed kevinyuliawan closed 5 years ago
What worked for me is specifying the specific size when calling make_table
inside its cell_styles: font_size
option:
make_table(cells, cell_style: {
size: @table_font_size
})
What looks like what was happening was I was generating the cells for the table before drawing them, and when I did so, it defaulted to using the document font_size
of 10 for calculating their height and width. Then, right before I actually drew the table using the cells, I specified font_size 9
, so the table then drew the cells with a smaller font size, but the cells' height and widths were already calculated with a bigger, incorrect font size, leading to the blank space.
Here is a before-and-after image illustrating my issue (red and black outlining done in Photoshop):
Note how on the left, the first row within the red outline (ending in "60") doesn't have any extra space below it.
Then on the right, when I add a single letter "M" to that same first row, a whole new unnecessary row of blank space is added, even though there is still space in that row.
In both tables, the second row (ending with "MIN") also has extra space below it, even though "MIN" fits on the first line.
I have tried making the cells have a
padding_right
of 0, but the issue is still there.Anyone have any insight as to why this is happening? It seems like Prawn isn't correctly calculating when to create a new line in the row, resulting in a blank new line. Figured I'd ask here before trying to dive into where that is being calculated. Any help as to how to avoid this would be appreciated.