Forum Discussion
Creating a pdf file from Storyline running under an LMS
Hi John and Matt. I've used the Base64 method for background images but haven't tried the server method. What would that code look like? Apologies if this is super basic JavaScript.
- JohnCooper-be3c3 years agoCommunity Member
Hi Mark
My code now looks like this:
//Create pdf
var doc = new jsPDF();
var img = new Image;
img.onload = function() {
doc.addImage(this, 'PNG', 0, 0, 210, 297);
doc.setFontSize(12);then I add all the text to the document
doc.save('Inventory.pdf');
}
img.onerror = function(e) {
console.log("Error code",e);
}
img.crossOrigin = "";
img.src = "Inventory.png";So "Inventory.png" is the name of my background image for my pdf and needs to be in the storyline output root folder. I am creating an A4 document in portrait. If you want to create a landscape form just swap the "210" and "297" parameters to load your png image and add 'landscape' to the new jsPDF line:
var doc = new jsPDF('landscape');
should do it