Forum Discussion
JohnCooper-be3c
3 years agoCommunity Member
Creating a pdf file from Storyline running under an LMS
I know there are many excellent examples of how to create a pdf file in Storyline using javascript libraries such as jspdf and I have done this successfully in projects compiled for the web...
......
JohnCooper-be3c
3 years agoCommunity Member
Hi Matthew
Can I be really cheeky and ask another question? I have the pdf creation working great - thanks to you! But I'm now experimenting with adding a background image to the pdf using doc.addimage in the javascript.I have the necessary jspdf libraries loaded (I think) but I'm running into a CORS problem - I've checked other examples (like Devlin Peck's tutorial) and have included a img.crossOrigin statement just before declaring the image source (the image is in the output folder):
img.crossOrigin = "";
img.src = "Inventory.png";
BUT - I still get an error when I try and load the image, The error triggers the img.onerror = function {.......... code I have added
var doc = new jsPDF();
var img = new Image;
img.onload = function() {.........
....
img.onerror = function(e) {....
The error message I get in the debug console is:
Access to image at 'file:///C:/Users/John/Documents/CURRENT/xxxxxxxxxxx/xxxxxxxxxxx%20-%20Storyline%20output/Inventory.png'' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, edge, https, chrome-untrusted.
I'm using jspdf v1.5.3 and have tried loading the .debug version exactly as in Devlin's example)
Any ideas would be appreciated
Thanks, John