At the end of a Storyline module I’m making, I wanted to create an easily printable page that contained all the freetext field entries the learner had made during the course.
I tried doing the basic old ‘window.print()’ – but since Storyline on desktop runs through flash, the print function was being a bit weird. Plus that requires a random storyline screen that looks nice for printing, and it gets centered and best-case it’s just an image (unselectable) and so on. So not ideal.
Instead I found this. You can, in your JS code, open a popup with dynamically written HTML which includes your variables and then print it. So it’s a basic HTML page, but there’s no HTML page that is separate or needs hosting or anything. Perfect.
window.open('data:text/html,<title>Hello Data URL</title><p>File-less HTML page!</p><p><a onClick="window.print()">Print Page</a>', 'Hello World', 'width=400,height=200');
Note: in my requirement, I just wanted to print out the text entry variables in my storyline document if the learner wrote anything. Here’s my code (with some comments):
Additional note (April 2016): changed the function to not do it via the URI so it’ll work in IE11 properly.
);return false;'>Click here to print the document</a> or select 'right-click > print' if you have problems." // closing the font style/body pageContent+="</div>"; // open the window, and populate it.
myPrintPop=window.open('', 'myPopup', 'width=500, height=600');
myPrintPop.title="Welcome to the Business thoughts";