Word wrap in generated PDF (using jsPDF)?

后端 未结 6 2035
梦毁少年i
梦毁少年i 2020-12-01 06:06

what I\'m doing is using jsPDF to create a PDF of the graph I generated. However, I am not sure how to wrap the title (added by using the text() function). The length of the

6条回答
  •  眼角桃花
    2020-12-01 06:31

    Okay I've solved this. I used the jsPDF function, splitTextToSize(text, maxlen, options). This function returns an array of strings. Fortunately, the jsPDF text() function, which is used to write to the document, accepts both strings and arrays of strings.

    var splitTitle = doc.splitTextToSize(reportTitle, 180);
    doc.text(15, 20, splitTitle);
    

提交回复
热议问题