3 Replies
Phil Mayor

You can output to a html page and add a print button to that using javascript code.

Something like this

var myWindow = window.open("","Print","width = 900,height = 610,scrollbars = 1,resizable = 1");

var player = GetPlayer();

// Variables specified in this script. You can change these!

//Text
var H1 = "<strong>Mental Health and Wellbeing</strong>";
var H2 = "<strong>Activity Helping Yourself</strong>";
var Q1 = "<strong>Question 1</strong>";
var Q2 = "<strong>Question 2</strong>";
var Q3 = "<strong>Question 3</strong>";
var Q4 = "<strong>Question 4</strong>";
var Q5 = "<strong>Question 5</strong>";

//PRINTVAR
var printbutton = "Click to Print or Save as a PDF";
var instruction = "From the print dialog that follows, choose a printer for a physical copy, or select PDF for a digital PDF file.";
var styleanswer = "'font-size:14px;margin-top:5px;'";
var stylequestion = "'font-size:18px;font-weight:bold;margin-top:10px;'";

try {
var headline = player.GetVar("PrintTitle");
var date = player.GetVar("SystemDate");
var Q1a = player.GetVar("TextEntry1");
var Q2a = player.GetVar("TextEntry2");
var Q3a = player.GetVar("TextEntry3");
var Q4a = player.GetVar("TextEntry4");
var Q5a = player.GetVar("TextEntry5");
} catch(err) {
//not doing anything here
}


// Build the print view as an HTML page
var contents = "";
contents += "<html>";
contents += "<head><title>"+headline+"</title></head>";
contents += "<body style='width:650px;padding:20px;font-family:sans-serif;'>";
contents += "<div style='height:20px;text-align:center;'>";
contents += "<button onclick='window.document.close();window.focus();window.print();window.close();'>"+printbutton+"</button>";
//contents += "<button onclick = 'javascript:window.print();'>"+printbutton+"</button>";
contents += "</div>";
contents += "<div style='font-size:16px;text-align:center;padding:20px;'>";
contents += instruction;
contents += "</div>";
contents += "<div style='font-size:22px;font-weight:bold;margin-top:20px;margin-bottom:20px;'>";
contents += headline;
contents += "</div>";
contents += "<div style='font-size:16px;'>";
contents += date;
contents += "</div>";
contents += "<div style="+stylequestion+">";
contents += H2;
contents += "</div>";
contents += "</div>";

contents += "<div style="+stylequestion+">";
contents += Q1;
contents += "</div>";
contents += "<div style="+styleanswer+">";
contents += Q1a;
contents += "</div>";
contents += "<div style="+stylequestion+">";
contents += Q2;
contents += "</div>";
contents += "<div style="+styleanswer+">";
contents += Q2a;
contents += "</div>";
contents += "<div style="+stylequestion+">";
contents += Q3;
contents += "</div>";
contents += "<div style="+styleanswer+">";
contents += Q3a;
contents += "</div>";
contents += "<div style="+stylequestion+">";
contents += Q4;
contents += "</div>";
contents += "<div style="+styleanswer+">";
contents += Q4a;
contents += "</div>";
contents += "<div style="+stylequestion+">";
contents += Q5;
contents += "</div>";
contents += "<div style="+styleanswer+">";
contents += Q5a;
contents += "</div>";
contents += "</body></html>";

//myWindow.document.write("[LOG] content drafted, ready to display:<br>");

myWindow.document.write(contents);