This repository has been archived by the owner on Nov 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpdf-viewer-setup.js
48 lines (42 loc) · 2.21 KB
/
pdf-viewer-setup.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
47
48
$(function() {
$('body').append(`
<script>
function closeModal() {
document.getElementById('pgpPDFViewer').style.display = 'none';
}
function printCanvas() {
var dataUrl = document.getElementById('the-canvas').toDataURL(); //attempt to save base64 string to server using this var
var windowContent = '<!DOCTYPE html>';
windowContent += '<html>'
windowContent += '<head><title>Print canvas</title></head>';
windowContent += '<body>'
windowContent += '<img src="' + dataUrl + '">';
windowContent += '</body>';
windowContent += '</html>';
var printWin = window.open('','','width=340,height=260');
printWin.document.open();
printWin.document.write(windowContent);
printWin.document.close();
printWin.focus();
setTimeout(function() {
printWin.print();
printWin.close();
}, 1000);
}
</script>
<div id="pgpPDFViewer" style="position: fixed;width: 100%;height: 100%; display: none; background: rgba(223,223,223,0.3);">
<div id="pdfSheet" style="width: 800px; height: 90%; margin-left: auto; margin-right: auto; background: white; box-shadow: 3px 3px 3px 0px rgba(0,0,0,0.75); margin-top: 30px; margin-bottom: 30px;">
<button id="prev">Previous</button>
<button id="next">Next</button>
<span>Page: <span id="page_num"></span> / <span id="page_count"></span></span>
<button id="zoomout">-</button>
<button id="zoomin">+</button>
<button onclick="printCanvas()" style="margin-left: 20px;">Print</button>
<button onclick="closeModal()" style="float: right;">Close</button>
<div id="wrapperDiv" style="width: 700px; max-height: 90%; overflow:scroll; ">
<canvas id="the-canvas"></canvas>
</div>
</div>
</div>
`);
});