Forum Discussion
Exporting Text Entry into a PDF
Hello Stephanie,
Sorry, I don't know why it doesn't work in the lms.
To make the text wrap, use the splitTextToSize function.
var date = new Date();
var dd = String(date.getDate()).padStart(2, '0');
var mm = String(date.getMonth() + 1).padStart(2, '0');
var yyyy = date.getFullYear();
date = mm + '/' + dd + '/' + yyyy;
var player = GetPlayer();
var q1 = player.GetVar("question1");
var q2 = player.GetVar("question2");
var q3 = player.GetVar("question3");
var doc = new jsPDF({ });
q1 = doc.splitTextToSize(q1, 134);
q2 = doc.splitTextToSize(q2, 134);
q3 = doc.splitTextToSize(q3, 134);
var img = new Image;
img.onload = function() {
    doc.addImage(this, 0, 0, 216, 279);
    doc.setFontSize(14);
    doc.setTextColor(0, 0, 0);
    doc.setFont('Helvetica');
    doc.text(q1, 61, 70, null, null, 'left');
    doc.text(q2, 61, 133, null, null, 'left');
    doc.text(q3, 61, 196, null, null, 'left');
    doc.text(date, 170, 42, null, null, 'center');
    doc.save("Learning Plan.pdf");
};
img.crossOrigin = "";
img.src = "fillablepdf.png";
Related Content
- 6 months ago
- 10 years ago
- 6 months ago