question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getTextDimensions expects text-parameter to be of type String or type Number or an Array of Strings.

See original GitHub issue

I’m using Typescript in a React project and I follow the example for creating a table on the Live Demo site but I get the following error: getTextDimensions expects text-parameter to be of type String or type Number or an Array of Strings.

I check the type of the arguments for .table() and the headers argument is string[] which is unexpected because the demo is using object[]. I change to the type asked for by the argument but I still get the same error.

Below is an MCVE in node:

const { jsPDF } = require('jspdf')

function test() {
  const test = new jsPDF('landscape')
  const headers = [
    'Name',
    'Student_Date_Of_Birth',
    'Student_ID_No_Course',
    'Course',
    'Course_Total_Tuition_Fee',
    'Course_Intake',
    'Course_Year',
    'Course_Start_Month',
    'Commission_Rate',
    'Commission_Payable'
  ]
  const invoiceObjectTableRows = [
    {
      Name: 'testing',
      Student_Date_Of_Birth: 'testing',
      Student_ID_No_Course: 'testing',
      Course: 'testing',
      Course_Total_Tuition_Fee: 'testing',
      Course_Intake: 'testing',
      Course_Year: 'testing',
      Course_Start_Month: 'testing',
      Commission_Rate: 'testing',
      Commission_Payabl: 'testing'
    }
  ]
  test.table(5, 105, invoiceObjectTableRows, headers, { autoSize: true })
}

test()

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

8reactions
HackbrettXXXcommented, Jan 11, 2021

You have a typo in your code snippet 😉

Commission_Payabl: 'testing'

This results in an undefined text for a cell.

0reactions
mgeorgeecommented, Aug 10, 2022

Thanks. I had a trailing white space in one of the header columns.

Read more comments on GitHub >

github_iconTop Results From Across the Web

getTextDimensions expects text-parameter to be of type String ...
I'm using Typescript in a React project and I follow the example for creating a table on the Live Demo site but I...
Read more >
getTextDimensions expects text-parameter to be of type String ...
... site but I get the following error: getTextDimensions expects text-parameter to be of type String or type Number or an Array of...
Read more >
modules/cell.js - Documentation - GitHub Pages
getTextDimensions = function (text, options) {; var fontSize = this.table_font_size ... expects text-parameter to be of type String or an Array of Strings....
Read more >
Creating a dynamically PDF with jSPDF - Stack Overflow
It gives me this error: getTextDimensions expects text-parameter to be of type String or type Number or an Array of Strings. angular ...
Read more >
Lightning LWC - Copy List with Limited fields [closed]
Looking at the Array.prototype.map it looks like I can modify the data. I'm trying to only copy certain fields. As an example, If...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found