Is there an underline setFontType in jsPDF?

I know that there are 4 types of "setFontType" in jsPDF:

doc.setFontType("normal");
doc.setFontType("italic");
doc.setFontType("bold");
doc.setFontType("bolditalic");

I tried some things, but I can not find it, is there also an underline setFontType in jsPDF?

+6
source share
2 answers

I know this is late, but I have a solution for this, you can do this in two ways: -

First you can use the built-in "line" option to draw a line under your text: -

doc.line(x-from,y-from,x-to,y-to);

Second, you can display the text in html, and then use the option to print html in your jspdf configuration, for example: -

<div id="disptext">
    <div class="underText">Hello</div>
</div>
<br/>
<input type='button' value='download' id='downP' />

<style>
.underText { text-decoration: underline;}
</style>

<script>
$(document).ready(function() {
    $('#downP').on('click', function() {
        var pdf = new jsPDF('p', 'pt', 'a4');

        pdf.addHTML($('#disptext')[0], function() {
            pdf.save('text.pdf');
        });
    });
});
</script> 
+5
source

jsPDF Nativescript, addHTML.

Biswas, , :

const textWidth = doc.getTextWidth(text);
doc.line(x, y, x + textWidth, y)
0

Source: https://habr.com/ru/post/1658254/


All Articles