At the time of writing the jsPDF JavaScript library didn't have an underline option for text. This is the code I wrote.
For my project the underline distance of 0.3 always worked. I set it as an optional parameter with 0.3 as default value.
The two functions: underline & underlineCenter: