getTextDimensions expects text-parameter to be of type String or type Number or an Array of Strings.
See original GitHub issueI’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:
- Created 3 years ago
- Comments:6
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You have a typo in your code snippet 😉
This results in an
undefined
text for a cell.Thanks. I had a trailing white space in one of the header columns.