pdfmake
pdfmake copied to clipboard
Table top line being put on both previous and current page.
// playground requires you to assign document definition to a variable called dd
pdfMake.tableLayouts = {
outerBorder: {
hLineWidth: function (i, node) {
if (i === 0 || i === node.table.body.length) {
return 2;
}
return 0;
},
vLineWidth: function (i, node) {
if (i === 0 || i === node.table.body[0].length) {
return 2;
}
return 0
},
hLineColor: function (i) {
return 'black';
},
paddingLeft: function () {
return 8;
},
paddingRight: function () {
return 8;
},
paddingBottom: function () {
return 5
}
},
borderless: {
hLineWidth: function () {
return 0;
},
vLineWidth: function () {
return 0;
},
hLineColor: function () {
return 0;
},
paddingLeft: function () {
return 0;
},
paddingRight: function () {
return 0;
}
},
};
var dd = {
"pageOrientation":"landscape",
"content":
[
{
"layout": "borderless",
"table": {
"headerRows": 0,
"widths": [140],
"body":
[
[
{
"text": "blah",
"style": "field"
}
],
[
{
"text": "blah",
"style": "field"
}
],
[
{
"text": "blah",
"style": "field"
}
],
[
{
"text": "blah",
"style": "field"
}
],
[
{
"text": "blah",
"style": "field"
}
],
[
{
"text": "blah",
"style": "field"
}
],
[
{
"text": "blah",
"style": "field"
}
],
[ {
"text": "blah",
"style": "field"
}
],
[
{
"text": "blah",
"style": "field"
},
],
[
{
"text": "blah",
"style": "field"
}
],
[ {
"text": "blah",
"style": "field"
},
]
]
},
"margin": [0, 0, 0, 20]
}, {"text": "Blah","bold": true, "fontSize": 16}, {
"layout": "borderless",
"table": {
"headerRows": 0,
"widths": [200, "*"],
"body": [[{"text": "Blah"}]]
},
"margin": [0, 0, 0, 20]
}, {"text": "Blah", "bold": true, "fontSize": 16}, {
"layout": "borderless",
"table": {
"headerRows": 0,
"widths": [200, "*"],
"body": [[{"text": "Blah"}]]
},
"margin": [0, 0, 0, 20]
}, {"text": "Blah", "bold": true, "fontSize": 16}, {
"layout": "borderless",
"table": {
"headerRows": 0,
"widths": [200, "*"],
"body": [[{"text": "Blah"}]]
},
"margin": [0, 0, 0, 20]
}, {"text": "Blah", "bold": true, "fontSize": 16}, {
"layout": "borderless",
"table": {
"headerRows": 0,
"widths": [200, "*"],
"body": [[{"text": "Blah"}]]
},
"margin": [0, 0, 0, 20]
}, {
"layout": "outerBorder",
"table": {
dontBreakRows: true,
"headerRows": 0,
"widths": ["*", "*"],
"body": [[{"text": "This makes a line on the previous page", "style": {"fontSize": 20, alignment: 'right'}}, {
"text": "it goes away if i add more padding",
"style": {"fontSize": 20}
}]]
},
"margin": [0, 40, 0, 0]
}],
"styles":
{
"header":
{
"fontSize":22,
"bold":true,
"alignment":"center",
"margin":[0, 0, 0, 10]
},
"subheader":{
"fontSize":18,
"bold":false
},
"field" :{
"bold":true
},
"name":{
"bold":true,
"fontSize":18
}
}
}
When i add enough padding the line disappears, but the content above is generated dynamically so the amount of padding needed will change and that box should be just under the above content when it can fit so I don't really want to add a page break.
I am having the same issue and i've even commented here :- https://github.com/bpampuch/pdfmake/issues/385#issuecomment-310605661
In this line of code :- https://github.com/bpampuch/pdfmake/blob/74be98b6dace6b6274ba03d62e1b66e846db2dfd/src/tableProcessor.js#L176
It would be better if they consider the height of row if the topBorder is true. At least for dontBreakRows: true.
any work around for this?
Also wondering a work around, getting a similar issue where this line is appearing at the bottom of my table making the bottom border partially thicker in one part
am to getting this issue, is there any solution for this ?
Not resolved yet. It has passed more than 4 years, will this bug be fixed? Or at least a workaround would be fine
Shorten the padding and the issue may solve.
YMMV, but the node object accessible for DynamicLayout carries information to selectively change the border color for these dangling cells. Assuming your background is white, the following property added to a custom table layout solved my problem for simple tables. You may need to find other conditions that match your table if its more complicated?
hLineColor: function(i, node) { return node.positions.length === 0 ? 'white' : 'black'; }