pdfmake icon indicating copy to clipboard operation
pdfmake copied to clipboard

Is it possible to style table borders?

Open nstolpe opened this issue 8 years ago • 6 comments

Can table borders have styles (dashed, dotted, etc) like those assignable through CSS border-style? I've looked through the docs and the source without success, but I could be missing something.

nstolpe avatar Oct 12 '16 23:10 nstolpe

Border styles implemented by commit https://github.com/bpampuch/pdfmake/commit/00722698b1a99c0f3379d74e3956d16ace5b5dc9.

Example of usage:

var dd = {
	content: [
		{
			table: {
				headerRows: 1,
				body: [
					['Header 1', 'Header 2', 'Header 3'],
					['Sample value 1', 'Sample value 2', 'Sample value 3'],
					['Sample value 1', 'Sample value 2', 'Sample value 3'],
					['Sample value 1', 'Sample value 2', 'Sample value 3'],
					['Sample value 1', 'Sample value 2', 'Sample value 3'],
					['Sample value 1', 'Sample value 2', 'Sample value 3'],
				]
			},
			layout: {
				hLineStyle: function (i, node) {
					if (i === 0 || i === node.table.body.length) {
						return null;
					}
					return {dash: {length: 10, space: 4}};
				},
				vLineStyle: function (i, node) {
					if (i === 0 || i === node.table.widths.length) {
						return null;
					}
					return {dash: {length: 4}};
				},
			}
		}
	]
}

liborm85 avatar Sep 01 '18 11:09 liborm85

Is this available at playground? I've tried the definition below but the result has no dashed line. Out of curiosity, Is it possible to draw lines in any other way (ie, a single line without any table)?

var dd = {
	content: [
		{
			table: {
				headerRows: 1,
				body: [
					['Header 1', 'Header 2', 'Header 3'],
					['Sample value 1', 'Sample value 2', 'Sample value 3'],
					['Sample value 1', 'Sample value 2', 'Sample value 3'],
					['Sample value 1', 'Sample value 2', 'Sample value 3'],
					['Sample value 1', 'Sample value 2', 'Sample value 3'],
					['Sample value 1', 'Sample value 2', 'Sample value 3'],
				]
			},
			layout: {
				hLineStyle: function (i, node) {
					return {dash: {length: 10, space: 4}};
				},
				vLineStyle: function (i, node) {
					return {dash: {length: 4}};
				},
			}
		}
	]
}

ericchaves avatar Sep 19 '18 15:09 ericchaves

With the current version of pdfmake on npm dashed borders do not work. If you manually replace the src/tableProcessor.js file with the file that exists on master, it will work. Seems the most up to date tableProcessor didn't make it into the 0.1.38 build.

Auenc avatar Oct 22 '18 13:10 Auenc

Is it planned to implement rounded borders?

DaJoBro avatar Jan 23 '19 11:01 DaJoBro

It would be great to have double borders as well.

gboysko avatar Jan 22 '24 22:01 gboysko

Awesome, looks like this has been released now.

boycce avatar Aug 22 '24 09:08 boycce