Skip to content

splitTextToSize method crashes if cell value is not a string #2849

@skchawala

Description

@skchawala

`API.splitTextToSize = function(text, maxlen, options) {
"use strict";

 .......

// first we split on end-of-line chars
var paragraphs;
if (Array.isArray(text)) {
  paragraphs = text;
} else {
  paragraphs = text.split(/\r?\n/);
}

.....
})(jsPDF.API)`

this method crashes at this line paragraphs = text.split(/\r?\n/)
if "text" is not a string.
in my case cell value/text can be number also
so 34.split() method causes error.

TypeError: t.split is not a function at Object.xt.splitTextToSize (split_text_to_size.js:360) at Object.<anonymous> (cell.js:567) at Array.map (<anonymous>) at Object.s (cell.js:564) ....

this case should be handled by converting this number to string I think

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions