is there any way to set the table width in percentage, in order to avoid the overflow.
Here below you can see the code. The table content actually overflows. Any way to fit the table into the pdf.
// playground requires you to assign document definition to a variable called dd
var data = {'title':'MachineHoursReport','author':'Hyva','headerMargin':[40,15,0,0],'headerImage':'/images/bull_machines_logo.png','headerText':'Machine Hours Report','footerText':'Copyright 2017 Bullindia.com','footerMargin':[40,0,0,0],'contentHeaderRows':1,'contentWidth':[],'contentBody':{'tableData':[[{'text':'Machine Name','style':'tableHeaders'},{'text':'Total Machine Life','style':'tableHeaders'},{'text':'Machine Hours','style':'tableHeaders'},{'text':'Last Received Status','style':'tableHeaders'},{'text':'Last Engine Run','style':'tableHeaders'},{'text':'Last Reported','style':'tableHeaders'},{'text':'Location','style':'tableHeaders'},{'text':'Dealer Name','style':'tableHeaders'}],[{'text':'HAR3DXSSK01896684HAR3DXSSK01896684','style':'bodyStyle'},{'text':1152,'style':'bodyStyle'},{'text':123,'style':'bodyStyle'},{'text':'ON','style':'bodyStyle'},{'text':'09/07/2018','style':'bodyStyle'},{'text':'09/07/2018','style':'bodyStyle'},{'text':'TRR Automative','style':'bodyStyle'}]]},'isDatePresent':{'flag':false,'date':''}};
var dd = {
content: [
{text: 'Tables', style: 'header'},
{
style: 'tableExample',
table: {
body: [
['Col1', 'Col2', 'Col3'],
['HAR3DXSSK01896684HAR3DXSSK01896684', 'HAR3DXSSK01896684HAR3DXSSK01896684', 'HAR3DXSSK01896684HAR3DXSSK01896684'],
['1', '2', '3']
]
}
}
],
styles: {
header: {
fontSize: 18,
bold: true,
margin: [0, 0, 0, 10]
},
subheader: {
fontSize: 16,
bold: true,
margin: [0, 10, 0, 5]
},
tableExample: {
margin: [0, 5, 0, 15],
widths: '*'
},
tableHeader: {
bold: true,
fontSize: 13,
color: 'black'
}
},
defaultStyle: {
// alignment: 'justify'
}
}

You can try setting something likewidths: ['16.6%', '16.6%', '16.6%', '16.6%', '16.6%', '16.6%'] inside table
hows does that above code works? setting width for the table column ? I have tried widths some time back, but it was not working as expected.
Long words do not wraps, its known problem: https://github.com/bpampuch/pdfmake/issues/204
@Cactucs Thank you Bro
You can try setting something like
widths: ['16.6%', '16.6%', '16.6%', '16.6%', '16.6%', '16.6%']inside table
you saved my day buddy