Commit bfa143c0 authored by Hamza Chahed's avatar Hamza Chahed

Add a first download as pdf Option without Header/Footer or Table of content

parent de8a0635
......@@ -512,6 +512,30 @@
};
}
///P
function download() {
//remove the default margin
var style = document.createElement('style');
style.setAttribute("type", "text/css");
style.setAttribute("media", "print");
var multiStr = [
"@page{",
"size: auto;",
"margin: 0mm;",
"margin-right: 3%;",
"margin-left:3%;}"
].join("\n");
style.innerHTML = multiStr;
document.head.appendChild(style);
// remove-insert download-button
var button = document.createElement('botton');
button = document.body.firstChild;
document.body.removeChild(button);
window.print();
document.body.insertBefore(button, document.body.firstChild);
}
///P
document.addEventListener('DOMContentLoaded', function () {
......@@ -525,6 +549,22 @@
queue.push(deferCellExecution(cell_list[i]));
}
return queue
///P
.push(function () {
var button = document.createElement('botton');
button.innerHTML = "Download As PDF";
button.setAttribute("type", "button");
document.body.insertBefore(button, document.body.firstChild);
document.querySelector('[type="button"]').addEventListener("click", download);
//
var script = document.createElement('script');
script.setAttribute("src", "https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js");
document.head.appendChild(script);
script.setAttribute("src", "https://html2canvas.hertzen.com/dist/html2canvas.min.js");
document.head.appendChild(script);
//
})
///P
.push(function () {
console.info('JSMD executed.');
}, function (error) {
......
......@@ -62,7 +62,7 @@
.push(function (evt) {
*/
// XXX Insecure
iframe.setAttribute("sandbox", "allow-scripts allow-same-origin");
iframe.setAttribute("sandbox", "allow-scripts allow-same-origin allow-modals");///P
// iframe.setAttribute("csp", "default-src *; script-src * 'unsafe-inline';");
// iframe.setAttribute("src", evt.target.result);
iframe.setAttribute("srcdoc", doc.documentElement.outerHTML);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment