Forum Discussion
Certificates in Rise
I spent some time playing with this, as well as digging in the developer tools and chrome on Phils solution and figured this out.
This can be done in rise by adding a storyline slide into rise. The storyline file just triggers Javascript as a trigger.
Here is the Javascript from Phils example https://codepen.io/khausauer/pen/JjPZKZa I used this as a base to recreate the functionality, changing the code slightly just to clean up and make it easier to read for this example.
To create a PDF you'll need to add the MakePDF CDN to your HTML generated files, You want to add this in the story_html5.html file from your published file. If you added the slide to a rise file this file will be in COURSENAME.zip\content\assets\bt151019uRhOQ0X4\ (The BT151... part is likely different for each slide you add to a rise course.
The the <head> and </head> will already be in there you just need to the the two script lines, just above the </head<
<head>
...
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.59/pdfmake.min.js" integrity="sha256-bX4TPrIvSJ7o/8O7HiB8WLSA6xz/45oHBHww/ErxGpc=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.59/vfs_fonts.js" integrity="sha256-UsYCHdwExTu9cZB+QgcOkNzUCTweXr5cNfRlAAtIlPY=" crossorigin="anonymous"></script>
</head>
There is one more issue you will run into, which is adding images to your PDF. the MakePDF documentation says images need to be base64 encoded, which essentially turns an image into a series of 1000s of characters. it looks something like this:
data:image/jpeg;base64,/9j/4RGJRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAAAkAAAAcgEyAAIAAAAUAAAAlodpAAQAAAABAAAArAAAANgALcbAAAAnEAAtxsA...
the problem here, is that storyline has a maximum character allowance in the JS panel. so to get around this you need to manually insert your encoded images into the JS file generated after publishing. this file can be found at Storyline output\story_content\user.js or if its a rise output COURSENAME.zip\content\assets\bt151019uRhOQ0X4\story_content\user.js
This file will look something like this:
function ExecuteScript(strId)
{
switch (strId)
{
case "6GIzzLQR94K":
Script1();
break;
}
}
function Script1()
{
// Retrieve storyline player object from parent window
var player = window.parent.GetPlayer();
// Retrieve the learners name from the learnerName variable
var name = player.GetVar("learnerName");
// Retrieve the title of the project from projectTitle variable.
var title = player.GetVar("projectTitle");
var results = player.GetVar("results");
var cpd = player.GetVar("cpd");
var certNo = player.GetVar("vCertificate_text");
// Get todays date in format dd/mm/yyyy
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth() + 1; //January is 0!
var yyyy = today.getFullYear();
if (dd < 10) {
dd = '0' + dd
}
if (mm < 10) {
mm = '0' + mm
}
date = dd + '/' + mm + '/' + yyyy;
// Define PDF output - See http://pdfmake.org/#/gettingstarted for information on creating a PDF document with pdfmake.
var docDefinition = {
// Set page size
pageSize: 'A4',
// Set document orientation
pageOrientation: 'portrait',
// Set page margins
pageMargins: [0, 0, 0, 0],
// Define main body of document
content: [
// Include logo image (image is encoded as base64 string)
// Include certificate text
{
text: 'THIS CERTIFICATE IS PRESENTED TO:',
fontSize: 16,
alignment: 'center',
margin: [0, 320, 0, 15]
},
... (continued on)
You'll need to add your images and background into here.
you'll want to find the line that Says var docDefinition = { And add in your background images right below so it looks like:
var docDefinition = {
// Define document background
background: [
{
image: 'data:image/jpeg;base64,/9j/4RGJRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABA ...... (Cut off because it's long)
width: 595.28,
height: 841.89
}
],
After you save the files you should be good to go, just upload to host, or LMS and give it a test. If you are running into issues, use the Dev tools in chrome (F12) and look at the bottom right for Javascript errors, this will give you an idea of where the problem is.
You can see a live demo of my storyline file here: http://kylehausauer.com/pdftest/story_html5.html
I have also attached the .story i used when testing. If i haven't described something clear enough, let me know i'll try to clarify!
Thanks very much for this explanation, Emiliano.
I've been asked by a client to get a certificate which used this PDFMake technique in Storyline, into Rise.
From your explanation I can see where and how to add the necessary Javascript. I've exported my client's first attempt at the Storyline module from Rise and got access to the HTML and Javascript files I need.
I just don't know how to get it back into Rise once I've made the changes. (I'm not very familiar with Rise). Is there any Import or similar functionality?
- Crystal-Horn5 years agoStaff
Hi there, Norman. Was your client's Storyline project already in a Rise 360 course? When you export a Rise 360 course for web or LMS, the Storyline assets are included in the packaged output.
While we can't provide support for modified published output, it sounds like you needed to make changes to the Storyline assets in the Rise export and then save them. There isn't a way to manually add Storyline output back into a Rise 360 course. Any changes you make in the output files would need to be saved in the output files.
I hope that helps answer your question!
- gerryMayer-e37a5 years agoCommunity Member
External files will have to go on a web server. They can not be put into rise.