Forum Discussion
Saving Storyline Variables to a PDF
I was asked about an example I created for saving variables from Storyline into a PDF file for download. Rather than fill the ELHChallenge thread with the information I decided to write up a thread on what I did. If you have any questions feel free to reach out.
The course executes JavaScript from within a Storyline (trigger) with the use of a client-side JavaScript PDF generator, jsPDF. This will not work locally, however, I have had successes with it functioning in IE11 without being hosted. It is easiest to design the PDF prior to inputting this into the course as you cannot preview. Thankfully, the jsPDF package contains an editor with their examples to design in.
Script & Demo Files for jsPDF:
Parallax: http://parall.ax/products/jspdf (contains an editor as well)
or via
GitHub: https://github.com/MrRio/jsPDF
1. Add Variables(score)/Text Entry fields
2. Add Trigger to execute JavaScript when user clicks (for downloading the PDF)
3. Retrieve the Player Variables within the .js field of the trigger and attach jsPDF settings per desired result look and feel.
**Notice an additional variable is created to transitioning the Storyline variable for the "Notes" in order to use ".splitTextToSize" for text wrapping within the PDF file. By default text wrapping does not occur.
4. Publish the course and add the applicable JavaScript files needed for your package (I placed mine within the "story_content" directory)
5. Add script files to the HTML <head></head>(story.html)
6. The result: Articulate Storyline Variables pushed to a downloadable PDF.
Storyline:
PDF Output:
Live Version:
https://googledrive.com/host/0B9kY09mQf_iqV3dTQ0Q4cUFvTlU/
Source & Published Files:
- PhilMayorSuper Hero
works great in safari
- jeffCommunity Member
Your alternative sounds great Steve, could you build a working example based on Josh's file? I, and many other, tend to find playing with Javascript a little intimidating.... :(
- notusingCommunity Member
Oh nice call on the object load, Steve, did not even think of the carry-on method for loading the scripts.
There are additional scripts and files provided from the jsPDF site that are supposed help the cross browser support including IE6-8, however, I have not tested it out. filesaver.js is unsupported below IE9 and the workaround refers to using downloadify, a flash/js combo.
What happened to be the alternative method used?
- StephanieSuper Hero
This is great code Josh, thanks. It works on Windows 8 in IE 11, FireFox 31.0 and Chrome 36.0 for me.
- JohnPieterse2Community Member
Josh, Steve,
Thank you very much!
- JenniferBryan1Community Member
Wow! THis is excellent!! Thank you so much for posting this information and sharing the source.
- DonNeeds1Community Member
Hello All,
I am looking at purchasing Storyline 2; however this method of saving variables to PDF does not work in Storyline 2. Does anybody have any ideas as to why it will not work? Everything works perfect in Storyline 1.
PS - Thanks so much for this info & source! It is great!
Thanks
Don
- notusingCommunity Member
I have not looked into this too much, however, quickly upgrading the file from SL1 to 2 and publishing it did not work locally, but did work when hosted. This happened to be similar behavior in SL1, though.
- MandyGalleyCommunity Member
This is great and just what I am looking for, but like Jackson I cannot get it to work. Any news on this?
Hi Jackson and welcome to E-Learning Heroes!
Hi Mandy!
You can see Josh's post above where he had to host the content for his shared example to work. Not sure if this is applicable to you.
Hopefully someone in the community will be able to assist you