I'm using jsPDF in a Storyline 360 activity. I've been working with jsPDF and storyline for almost 2 years now, and we still use jsPDF version 1.5.3 since the newer version wouldn't work with our previously made courses.
I am having trouble getting a 'Number' variable to come into jsPDF. If the variable was instead a variable type 'Text' from storyline, it'll work fine though. It's just a number variable that breaks it. I've isolated it down to this issue, and included a code sample. I've started with a brand new storyline file, fresh variables, different variables names, the only thing that fixes it is changing my variable type to Text in storyline, which isn't a solution for me because I need to do math on these numbers in the activity, and bring those results to the generated PDF. Thank you for any guidance and help.
//Retrieve Player Variables
var player = GetPlayer();
userScore01 = player.GetVar("UserScore");
//Create PDF
var doc = new jsPDF();
doc.setFontType("bold");
doc.setFontSize(16);
doc.text(20, 28, userScore01);
//Save PDF
doc.save('Test.pdf');
I finally isolated this issue! It appears you cannot just display a numeric variable all by itself with doc.text, but need to instead add it to a text string or a text-based variable. So the following code updates worked:
OR