1

Im using jsPDF to create a pdf from a webpage. However, the text within <p>-tags end up on the same row, which means that some text gets outside the view. How can I add new rows when the text gets long?

Here is the code:

function printPDF() {
    var doc = new jsPDF()
    var myDiv = document.getElementById("my-div");

    doc.fromHTML(myDiv, 10, 10)
    doc.save('a4.pdf')
}

and here is the result: enter image description here

marylee
  • 71
  • 8
  • I was hoping to only have to use the fromHTML() function and not break it down into smaller parts. But I guess this could be a solution yes! – marylee Mar 09 '20 at 13:27
  • You must add the width, something like that: pdf.fromHTML(YourData, 15, 15, { width: 180, }); – Mohcin Bounouara Apr 10 '20 at 13:48

0 Answers0