NorCalKnockOut
NorCalKnockOut

Reputation: 878

Linebreak on jspdf and autotables cutting header name

I can't seem to figure out how to fix the header issue.

The TesterTitle Test header gets split in the middle of a word, is there a way to not split a word apart?

Or set a minimum width for a column?

https://jsfiddle.net/fdgxk60y/32/

I need to add code to this question to meet stackoverflows requirement...

startY: 20,
headerStyles: {fillColor: [51, 122, 183]},
theme: 'grid',
margin: {horizontal: 7},
styles: {overflow: 'linebreak'},
columnStyles: {text: {columnWidth: 'auto'}},

Upvotes: 0

Views: 2676

Answers (2)

I had the same issue and fixed it just by using the following headStyle:

headStyles: { cellWidth: 'wrap' },

Example:

autoTable(
  doc, {
  headStyles: { 
    cellWidth: 'wrap'
  },
  columns,
  body
})

Here are other styles that you can play with: https://github.com/simonbengtsson/jsPDF-AutoTable#styling-options

Upvotes: 0

Simon Bengtsson
Simon Bengtsson

Reputation: 8151

Although you can't specify min width, you can specify width. Does this fit your requirement?

columnStyles: {text: {columnWidth: 'auto'}, longTitle: {columnWidth: 100}}

or

columnStyles: {text: {columnWidth: 'auto'}, longTitle: {columnWidth: 'wrap'}}

or

styles: {columnWidth: 'wrap'}
columnStyles: {text: {columnWidth: 'auto'}}`

Upvotes: 1

Related Questions