'How do I insert dynamic text inside rectangle in jsPDF?

I want to add some text inside my jsPDF rectangle.

doc.rect(x, y, w, h, style)
doc.text(x+10,y+20,"Hello");
// the more doc.text() I add, the height of the rectangle should keep on increasing

I want my text to always remain inside the rectangle, no matter how much I add. How do I do that?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source