I am filling a table content dynamically.. my problem is when the last row's content is much long it takes a part from the previous page and a part from the next page... what i want is a page break so i can have the row's content in the next page.. here the document definition (the issue appears at the last page):
var dd = {
pageSize: 'A4',
pageOrientation:'landscape',
pageMargins: [20, 20, 20, 30],
content: [],
footer: function(page, pages){ return page + ' / ' + pages;},
styles: {
header: {
fontSize: 18,
color:'black',
fillColor:'#ffffff'
},
subheader: {
fontSize: 16,
margin: [0, 10, 0, 5]
},
tableExample: {
margin: [0, 10, 0,10]
},
tableHeader: {
fontSize: 14,
color: 'black',
fillColor: '#E2E2E2'
}
},
defaultStyle: {
alignment:'center'
}
};
// TABLE
var headerTable = [{text:'HEADER MAIN',colSpan: 5,style:'header'},{},{},{},{}];
var minHeaderTable = [{text:'COL1',style:'tableHeader'},
{text:'COL2',style:'tableHeader'},
{text:'COL3',style:'tableHeader'},
{text:'COL2',style:'tableHeader'},
{text:"COL4",style:'tableHeader'}
];
var pdfTable ={columns:[
{width: '*', text: ''},
{style: 'tableExample',width:'auto',
table: {widths:[150,260,90,90,150],
headerRows: 2,
keepWithHeaderRows: 1,
body: [ headerTable,minHeaderTable]}
,layout:{defaultBorder: false}
},
{ width: '*', text: '' },
]};
for(var i=0;i<10;i++){
var pdfData = [
{text: 'TOTO'},
{text: 'BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLAL BAHLALe'},
{text: 'BAHLAL'},
{text: 'BAHLAL'},
{text: '09:31:44'}];
pdfTable.columns[1].table.body.push(pdfData);
}
dd.content.push(pdfTable);
Try use option:
dontBreakRows: true
Most helpful comment
Try use option:
dontBreakRows: true