Pdfmake: How to divide table cell to multiple rows based on Underscore

Created on 18 Aug 2020  路  2Comments  路  Source: bpampuch/pdfmake

"http://pdfmake.org/playground.html"

Playground Code:
printPageMargins = [25, 40, 25, 40], printFontSize = 9, title = '',
printBody = [[{text: 'Phone', bold: true}, {text: 'Other', bold: true}, {text: 'Col One', bold: true},
{text: 'Start Time', bold: true},{text: 'Week Day', bold: true}, {text: 'Dur', bold: true},
{text: 'Type', bold: true}, {text: 'Numberone', bold: true}, {text: 'Numbertwo', bold: true},
{text: 'Base Number ID', bold: true}, {text: 'Teaming', bold: true},{text: 'Col Two', bold: true},
{text: 'No1', bold: true}, {text: 'No2', bold: true}, {text: 'BEN', bold: true},
{text: 'Super', bold: true}, {text: 'Othe1', bold: true}, {text: 'Margin1', bold: true},
{text: 'Dist (kms)', bold: true}],
['1234567890', '1234567890', 'Yes_Yes_No_Yesnonono_No_Noyesye_Noyesyes', '2033-03-23 01:03:44', 'Sat', '0',
'Out', '123456789012345', '123456789012345','12345', '-,Bean_Bean',
'Yes No Yes NO Yes No Yes NO Yes No Yes NO Yes No Yes NO, Yes No Yes NO, Yes No Yes NO', '12.12121',
'1212.120', '240', 'Hower Board', 'Ben_8T', 'Base_Begin', '1.45']],
printWidths = [51, 51, 'auto', 46, 24, 15, 20, 76, 76, 'auto', 'auto', '*', 38, 38, 'auto', 'auto',
'auto', 'auto', 24],
printPadding = 2;

var docDefinition = {
pageSize: 'legal',
pageOrientation: 'landscape',
pageMargins: printPageMargins,
defaultStyle: {
fontSize: printFontSize,
lineHeight: 1.2
},
content: [
{ text: title, bold: true, fontSize: 12 },

{
table: {
headerRows: 1,
widths: printWidths,
body: printBody,
dontBreakRows: true
},
layout: {
fillColor: function (rowIndex, node, columnIndex) {
return (rowIndex === 0) ? '#CCCCCC' : null;
},
hLineWidth: function (i, node) {
return 1;
},
vLineWidth: function (i, node) {
return 1;
},
hLineColor: function (i, node) {
return 'black';
},
vLineColor: function (i, node) {
return (i === 0 || i === node.table.widths.length) ? 'black' : 'gray';
},
paddingLeft: function(i, node) { return printPadding; },
paddingRight: function(i, node) { return printPadding; },
}
}
]
};

pdfMake.createPdf(docDefinition).download();

My Problem is, if you observe Columns "Col One" and "Col Two",
"Col Two" is getting adjusted in little width, because "Col One" has taken more width, even though it could have got adjusted in 2 lines comfortably by separating from _(underscore)

Kindly help to divide table cell on _underscore base too

Most helpful comment

For wrap text on custom places, you can use Unicode Character 'ZERO WIDTH SPACE' (U+200B), example: 'Text\u200BText'

All 2 comments

For wrap text on custom places, you can use Unicode Character 'ZERO WIDTH SPACE' (U+200B), example: 'Text\u200BText'

Thank you very @liborm85 , Great help 馃憤 馃挴 馃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

einfallstoll picture einfallstoll  路  3Comments

m-brudi picture m-brudi  路  3Comments

qgliu picture qgliu  路  3Comments

jkd003 picture jkd003  路  3Comments

davidyeiser picture davidyeiser  路  3Comments