Open raquelhortab opened 1 year ago
I've seen that by setting exact widths for all columns, it works. I tried this: column_widths = 50
and it complained about it being too small. Since the error message said the exact size it needed was 523.28, calculated the widths from that. I set table.column_widths = [50, 423.28, 50]
and that worked. I don't get why it does not work by setting only the first and the last column widths.
in case someone else finds this, this seems to be the best solution: [50, pdf.bounds.width - 100, 50]
I've seen that by setting exact widths for all columns, it works.
Thank you, I can confirm this worked for me too!
For a more flexible pattern, I did this:
def column_widths
cols = {
0 => 25,
2 => 26,
3 => 35
}
# Calculate width for remaining column due to https://github.com/prawnpdf/prawn-table/issues/152
cols.merge({
1 => pdf.bounds.width - cols.values.sum
})
end
You can use the hash form to specify the column index.
In case it helps anyone I just find out this should be
cell_style = { width: pdf.bounds.width / NUM_OF_COLS }
pdf.table(table, position: :left, cell_style: cell_style)
Use width
instead of column_width
Hi! I got a table with subtables inside. I can successfully control the subtables' column widths but not the main table ones. Here's the code and below the result. If TLDR, important code is towards the end.
You can see the footer table respects the widths I've set, but the main content's columns have equal widths.
Thanks in advance!