Skip to content

Error using jsPDF cell table() method #2223

Closed
@tmmsmoreira

Description

@tmmsmoreira

Hello,

First, I want to say, what an amazing framework!
I was testing it to implement in a current project that I am working on and I am having some issues creating tables on the document. Based on your documentation, I am doing everything correctly. Here is a piece of code so you can check the problem that I am having:

JS File

var data = [
  {
    coin: "100",
    game_group: "GameGroup",
    game_name: "XPTO1",
    game_version: "25",
    machine: "20485861",
    vlt: "0"
  },
  {
    coin: "100",
    game_group: "GameGroup",
    game_name: "XPTO2",
    game_version: "25",
    machine: "20485861",
    vlt: "0"
  }
];

var header = ["coin", "game_group", "game_name", "game_version", "machine", "vlt"]

function save() {
  var doc = new jsPDF()
  doc.text(20, 20, 'Hello world!')
  doc.table(1, 1, data, header)
  doc.save()
}

HTML File

<button onclick="save()">Save</button>

The error that I am having is this:

jspdf.min.js:29 Uncaught Error: Invalid arguments passed to jsPDF.rect
    at Object.l.__private__.rect.l.rect (jspdf.min.js:29)
    at Object._.cell (jspdf.min.js:88)
    at Object._.printHeaderRow (jspdf.min.js:88)
    at Object._.table (jspdf.min.js:88)
    at save (pen.js:25)
    at HTMLButtonElement.onclick (index.html?editors=1111:6)

Here is the codepen link so you can check the problem on your console:
https://codepen.io/anon/pen/EGQzNr

Thank you for your attention and support, and keep up the good work!

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