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:
- EmilseRivoltaCommunity Member
I forgot to copy the links to the .html5 too! :)
- EmilseRivoltaCommunity Member
One more thing. I have been struggling with this a while... Is there an easy way to add images and center text?
Hi Emilse,
I'm not certain if Kristen is still subscribed to this thread to weigh in on what she ended up doing, but you could also reach out to anyone in this thread directly using the "contact me" button on their profile to see if they are able to share specifics.
- JedidiahEspositCommunity Member
Thanks Jedidiah for sharing those with Emilse
- EmilseRivoltaCommunity Member
Thanks so much for the links Jedidiah.
I tried to insert images using that code from the instructions, but dataimg are too long (like 5 .pptx pages). I couldn’t insert them into the storyline box (the javascript box). I think there is a restriction in how much code you can insert in Storyline?… That’s why, I needed an alternative way of doing this. I have done research, but unfortunately I am not a coder and this things are very hard for me.
The other thing I was trying is to center texts. But this library doesn’t include this possibility. You only can adjust x/y parameters. L
- JedidiahEspositCommunity Member
Actually, if you're willing to open the user.js file after publishing you
can edit the script there. When you enter script into the storyline trigger
box it creates a function with a crazy name and inserts it into user.js
(under the story_content folder) in the published output.
Hi Emilse,
Just as an FYI, each JavaScript trigger can have up to 32,767 characters of code.
- EmilseRivoltaCommunity Member
Thanks Jedidiah for sharing, I didn't know that. I will try to make it work :)
And thanks Ashley for the comment, is good to know.
- KristenBjorkCommunity Member
Hi Emilse,
I haven't been actively pursuing a solution to my problems, as bigger issues have cropped up. However, I never did get my PDF working.
Hi Kristen,
Thanks for chiming back in here and sharing that update. If there is anything else we can assist with please feel free to let us know here or connect with our Support Engineers here.