Jspdf: How to get the height of a block text.

Created on 28 Sep 2018  路  1Comment  路  Source: MrRio/jsPDF

I am trying to print a variable that contains HTML. My problem is that the html is dinamic... for example...

    // the number of <p> is dinamic... this value comes from a text editor.. 
so the number of <p> can change...

   var text: "<div><p>Line 1</p><p> Line 2</p></div>"

So if in the bottom of this text i want to add something... i need to know the last position it typed or the height of this block...

there is any method to know what is the total height of this block? or .... what is the last coordinate typed or the number of lines...?

I am printing this like...

var text = "<div><p>Line 1</p><p>Line 2</p></div>" 
doc.fromHTML(text,38,10).

Most helpful comment

i found the solution here. https://stackoverflow.com/questions/16858954/how-to-properly-use-jspdf-library

doc.fromHTML(text, 38, 10, {}, function (callback)
{
console.log(callback)
})

The callback contains the x and y coords.

Problem solved.

>All comments

i found the solution here. https://stackoverflow.com/questions/16858954/how-to-properly-use-jspdf-library

doc.fromHTML(text, 38, 10, {}, function (callback)
{
console.log(callback)
})

The callback contains the x and y coords.

Problem solved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arulmb0136 picture arulmb0136  路  4Comments

MaxCodeDE picture MaxCodeDE  路  4Comments

allenksun picture allenksun  路  3Comments

0721Betty picture 0721Betty  路  4Comments

baluMallisetty picture baluMallisetty  路  4Comments