pdfmake icon indicating copy to clipboard operation
pdfmake copied to clipboard

Table top line being put on both previous and current page.

Open jmarks-joshua opened this issue 7 years ago • 8 comments

// 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
		}
	}
}

pdfmake issue

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.

jmarks-joshua avatar May 16 '17 10:05 jmarks-joshua

I am having the same issue and i've even commented here :- https://github.com/bpampuch/pdfmake/issues/385#issuecomment-310605661

varunsharma27 avatar Jun 24 '17 21:06 varunsharma27

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.

varunsharma27 avatar Jun 25 '17 12:06 varunsharma27

any work around for this?

adamnator92 avatar Oct 10 '19 07:10 adamnator92

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

Thomaswaldick avatar Oct 19 '19 15:10 Thomaswaldick

am to getting this issue, is there any solution for this ?

Anand-Paul avatar Aug 06 '20 05:08 Anand-Paul

Not resolved yet. It has passed more than 4 years, will this bug be fixed? Or at least a workaround would be fine

Ripper346 avatar Nov 03 '21 22:11 Ripper346

Shorten the padding and the issue may solve.

WasilIslam avatar Oct 07 '22 06:10 WasilIslam

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'; }

kmeis002 avatar Oct 06 '23 20:10 kmeis002