-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs.js
46 lines (42 loc) · 1.19 KB
/
js.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const qs = Qs.parse(location.search.slice(1));
document.addEventListener('DOMContentLoaded', function () {
if ('photo' in qs) {
document.getElementById('photo').src = qs.photo;
}
if ('name' in qs) {
document.getElementById('name').innerText = qs.name;
}
if ('subject' in qs) {
document.getElementById('subject').innerText = qs.subject;
}
console.log('ready', qs)
});
function save () {
console.log('save');
const div = document.getElementById('main');
printToFile(div);
}
function printToFile (div) {
html2canvas(div, {
logging: true,
allowTaint: true,
useCORS: true,
})
.then(function (canvas) {
console.log('canvas');
const myImage = canvas.toDataURL("image/png");
downloadURI("data:" + myImage, "intro.png");
})
.catch(function (err) {
console.log('error', err);
});
}
function downloadURI (uri, name) {
console.log('download')
const link = document.createElement("a");
link.download = name;
link.href = uri;
link.click();
//after creating link you should delete dynamic link
//clearDynamicLink(link);
}