Skip to content

Table header aligns always left #3028

@mojtaba-khallash

Description

@mojtaba-khallash

Executing the following code snippet in live demo is expected to create a table that all its rows including the header center align.

var headers = [
  {name: "id", align: "center", width: 100},
  {name: "name", align: "center", width: 100}
];

var data = [
  {id: "0", name: "Test 1"},
  {id: "1", name: "Test 2"}
];

var doc = new jsPDF({ orientation: "landscape" });
doc.table(1, 1, data, headers);

But contrary to expectations, the header has been left align!

image

The problem seems to be from the bottom line:

https://github.com/MrRio/jsPDF/blob/704f5a9bbf30421a81f2cf33803904e0db0227f1/src/modules/cell.js#L429

Should be use headers instead of headerNames

headerAligns = headers.map(function(header) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions