dmk99 / react-pdf-table

Storybook Available
https://dmk99.github.io/react-pdf-table
MIT License
152 stars 62 forks source link

Override width for a specific Row. #34

Closed joelybahh closed 3 years ago

joelybahh commented 3 years ago

I'm currently using this to generate an invoice, and it works great, however, the table rows are all evenly sized by default, is there a way I can override the width for a certain row?

We have a GST row that will never have more than 3 characters in the header item/cell item, so the size it is by default is quite large. image

I would love to reduce just that section to allow for text in the first row to be larger. Similar to how react row/col allows md={4} for example. Overriding the width via custom style doesn't seem to work.

dmk99 commented 3 years ago

Hi,

Sorry for such a late reply. If it’s still relevant have you tried using the weighting Prop on the table cell? You can see weighting being used here: https://github.com/dmk99/react-pdf-table#formatting-example---aligning-text-and-weightings-for-columns

The weighting should be a number between 0...1, if you set the GST table cell as 0.1 weighting this will make that column a fixed width.

Right now this is the only way fixed widths are supported in this library.