pdfmake
pdfmake copied to clipboard
Is it possible to style table borders?
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.
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}};
},
}
}
]
}
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}};
},
}
}
]
}
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.
Is it planned to implement rounded borders?
It would be great to have double borders as well.
Awesome, looks like this has been released now.