Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add header background color in table header ? #51

Open
DynMatrix opened this issue Aug 17, 2023 · 2 comments
Open

How to add header background color in table header ? #51

DynMatrix opened this issue Aug 17, 2023 · 2 comments

Comments

@DynMatrix
Copy link

.onHeaderAdd(tb => {
// set header color
console.log('tb');
console.log(tb);
tb.pdf.fillColor('#000000')
tb.pdf.font('font/static/Inter-Medium.ttf')
})

unable to add header background color.

@DynMatrix
Copy link
Author

addCellBackground = function (self, column, row, pos, index, isHeader) {
self.emitter.emit('cell-background-add', self, column, row, index, isHeader);

    self.pdf
        .rect(pos.x, pos.y, column.width, row._renderedContent.height)
        .fill("#FBF1FB").fillColor('#000000');

    self.emitter.emit('cell-background-added', self, column, row, index, isHeader);
},

Did some editing fill color

@tafel
Copy link
Contributor

tafel commented Aug 17, 2023

You should be able to set header fill color with headerFill property in your column definition and onCellBackgroundAdd/ed events.

.addColumns([{
  id: 'col',
  header: 'My header',
  headerFill: true // needed so we know we need to fill header cells
}])
.onCellBackgroundAdd(t => t.pdf.fill('#eeeeee')) // set fill color
.onCellBackgroundAdded(t => t.pdf.fill('black')) // reset fill color

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants