'jsPDF splitTextToSize is not wrapping text, just adding commas to string
I am using an npm installed, latest version of jsPDF (1.4.1) in an Angular 6 application.
Here is the code.
const doc = new jsPDF();
const xOffset = 10;
const notes = doc.splitTextToSize('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi', 80, {});
doc.text(xOffset, 235, 'Notes: ' + notes);
The result is just the lorem ipsum on one line with a comma every 80mm. How do I get this string to wrap?
Solution 1:[1]
I believe I figured out what the issue was. In my instantiation of the new jsPDF(), I was not passing any size attributes. Now I am setting the document size and the the code works.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | maxsands1503 |
