Forum Discussion
DonTino
1 month agoCommunity Member
Export text with custom Blocks
Hey there,
I use A LOT of custom HTML blocks in my E-Learnings so if i want to export it to PDF there is no chance I get a good result back.
Is there a way to fix this or any workarounds? Is the...
Chris-Hurst
1 month agoCommunity Member
I had the same issue with Rise, my workaround is to embed a Storyline, which allows Word and/or PDF downloads - here's an example of my JavaScript which allows user text input to be downloaded as a Word file.
// === STORYLINE: DOWNLOAD COMBINED NOTES FROM ALL BLOCKS ===
var KEY = "RiseCombinedNotes__parts";
// Read everything that’s been saved by all Storyline blocks
var parts = [];
try { parts = JSON.parse(localStorage.getItem(KEY) || "[]"); } catch(e){ parts = []; }
// Sort by part id (optional)
parts.sort(function(a,b){ return (a.id||"").localeCompare(b.id||""); });
// Build HTML -> Word
function esc(s){
return String(s||"")
.replace(/&/g,"&").replace(/</g,"<")
.replace(/>/g,">").replace(/"/g,""")
.replace(/'/g,"'");
}
var courseTitle = document.title || "Course";
var now = new Date();
function pad(n){ return n<10?"0"+n:n; }
var stamp = now.getFullYear()+"-"+pad(now.getMonth()+1)+"-"+pad(now.getDate())+"_"+pad(now.getHours())+pad(now.getMinutes());
var filename = courseTitle.replace(/[^\w\-]+/g,"_") + "_All_Notes_" + stamp + ".doc";
var sectionsHTML = parts.map(function(part){
var header = `<h2>${esc(part.title || part.id || "Section")}</h2>`;
var qas = (part.fields||[]).map(function(f){
return `
<div class="qa">
<div class="prompt"><strong>${esc(f.label||"")}</strong></div>
<div class="answer block">${esc(f.value||" ")}</div>
</div>
`;
}).join('<div class="sep"></div>');
return header + qas + '<div class="big-sep"></div>';
}).join("");
var html = `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>${esc(courseTitle)} – Combined Learner Notes</title>
<style>
body { font-family: Calibri, Arial, sans-serif; line-height: 1.45; margin: 28pt; }
h1 { font-size: 20pt; margin: 0 0 8pt 0; }
h2 { font-size: 15pt; margin: 16pt 0 8pt; border-bottom: 1pt solid #ddd; padding-bottom: 4pt; }
.meta { color: #555; font-size: 10pt; margin-bottom: 16pt; }
.prompt { margin: 10pt 0 4pt; }
.block { white-space: pre-wrap; border: 1pt solid #ddd; padding: 10pt; border-radius: 6pt; }
.sep { border-top: 1pt solid #eee; margin: 12pt 0; }
.big-sep { border-top: 2pt solid #ccc; margin: 18pt 0; }
.footer { margin-top: 18pt; font-size: 9pt; color: #666; }
</style>
</head>
<body>
<h1>Combined Learner Notes</h1>
<div class="meta">
Course: <strong>${esc(courseTitle)}</strong><br>
Exported: ${now.toLocaleString()}
</div>
${sectionsHTML || "<p><em>No saved notes found yet.</em></p>"}
<div class="footer">Generated from multiple Articulate Storyline blocks in Rise.</div>
</body>
</html>
`;
// Download as .doc (Word opens HTML nicely)
var blob = new Blob(["\ufeff", html], { type: "application/msword;charset=utf-8" });
// Legacy IE / old Edge fallback
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
window.navigator.msSaveOrOpenBlob(blob, filename);
} else {
var a = document.createElement("a");
a.href = URL.createObjectURL(blob);
a.download = filename;
document.body.appendChild(a);
a.click();
setTimeout(function(){
URL.revokeObjectURL(a.href);
document.body.removeChild(a);
}, 0);
}
Related Content
- 6 months ago
- 6 months ago
- 6 months ago
- 6 months ago