bpampuch / pdfmake

Client/server side PDF printing in pure JavaScript
http://pdfmake.org
Other
11.53k stars 2.03k forks source link

Help needed: how can i forcefully prevent my table cell from wrapping onto the next page? #2749

Closed man-shar closed 2 weeks ago

man-shar commented 4 weeks ago

I am trying to contruct a pdf where i'm putting text inside a table cell because I want to control the width and height of the text. I"m using the solution suggested here and putting all text inside tables.

But in some cases, my table cells are wrapping onto the next page like so:

  1. I wonder why it's doing this?
  2. Any way I can prevent this?

Note the table with the black border in the below screenshot:

image
kandjar commented 3 weeks ago

Hi, you can try this :

table: {
    dontBreakRows: true, 
}

A row cannot be split in half across pages

man-shar commented 3 weeks ago

hmmm, yes but then it will take the whole row to the next page hehe.

image

Fwiw, there is an easier solution for me which is just increasing the page height to prevent it from hitting whatever threshold it's hitting for pagebreak. But i'm curious if there's a cleaner solution possible?

I'm only using table cells for my text because i need to give them width and height. I suppose there's no other way for me to get fixed-sized text?

liborm85 commented 2 weeks ago

Table is the correct solution. If you don't want to wrap cells use dontBreakRows: true as mentioned above of course it wraps whole row.