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:
Hi John,
This thread is a bit older so I'm not certain that folks are still subscribed to reply - you could message them using the "contact me" feature on their profiles.
- KristenBjorkCommunity Member
This is really great, but I can't for the life of me get it to work. I *think* that I followed all of the steps -- I added the JavaScript files to the story_content folder and added the script files to the HTML of the story.html file. However, nothing happens when I hit the button in the Storyline. Does anyone have any thoughts about what I might have missed? Thanks!
Hi Kristen,
I'm not well versed in Javascript, but you will want to make sure that you're testing the published output within the intended environment as described here.
- KristenBjorkCommunity Member
I'm wondering if I'm running into trouble because I'm working in Storyline 2. Does anyone know the answer to this question?
- RoryFlynnCommunity Member
Hi there, we added this function to our Storyline 2 course with a very customised output PDF with multiple variable fields so it is possible. We outsourced the development of this function to a fantastic developer. Because its such a dark art I can't tell you how its done but I will contact him and ask if he can contribute to this thread.
Javascript still works in Storyline 2, but if you're not testing it within the intended publish environment it could be encountering security restrictions locally and won't execute the Javascript as detailed here.
- KristenBjorkCommunity Member
Hi Rory,
I would SO appreciate any help that you could provide. Thanks so much!
- RoryFlynnCommunity Member
Cool, I've emailed him. He was really easy to deal with and nailed it exactly as i had briefed.
Thanks Rory for the assist here - and hopefully he'll be able to assist Kristen with the "dark arts" :-)
Always good news Jedidiah - thanks for sharing here!
- KristenBjorkCommunity Member
Thanks so much, Jedidiah. However, I don't have all those other .js files (the ones that are called in the plug-ins folder). Where could I get them?
- JedidiahEspositCommunity Member
Most of those are actually included in the zip the OP included. If any are
missing they're likely available on github. Just do a search for jsPDF to
start. If there's a specific one you can't find let me know and I'll see if
I can find a direct link.
Just a reminder Jedidiah that replying via email includes your signature here so you are welcome to edit that if you'd like to remove the information.