-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpdf_viewer.html
141 lines (128 loc) · 5.17 KB
/
pdf_viewer.html
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Document Viewer</title>
<style>
body {
padding-top: 3.5rem;
}
.pdfobject-container {
/*width: 100%;*/
/*max-width: 700px;*/
height: 800px;
margin: 0em 0;
}
.pdfobject { border: solid 1px #666; }
#results { padding: 0rem; }
.hidden { display: none; }
.success { color: #4F8A10; background-color: #DFF2BF; }
.fail { color: #D8000C; background-color: #FFBABA; }
.overlay{
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
z-index: 999999;
background: rgba(0,0,0,0.01);
}
</style>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<a class="navbar-brand" href="#">Document Viewer</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</nav>
<main role="main">
<div class="overlay">
<div style="text-align: center;padding: 10px;">
<button class="previous">Previous</button>
<button class="next">Next</button>
</div>
</div>
<div id="results" class="hidden"></div>
<div id="pdf"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfobject/2.0.201604172/pdfobject.min.js"></script>
<script>
if(PDFObject.supportsPDFs){
document.addEventListener('contextmenu', event => event.preventDefault());
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};
var options = {
pdfOpenParams: {
pagemode: "thumbs",
navpanes: 0,
toolbar: 0,
statusbar: 0,
view: "FitV"
}
};
var pdfURL = getUrlParameter('url');
window.myPDF = PDFObject.embed(pdfURL, "#pdf", options);
} else {
alert("Your browser does not support PDFs. Please use the latest version of Chrome/Edge to view this page.");
}
</script>
</main>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script>
window.pageNumber = 1;
$(".overlay").on("contextmenu",function(e){
return false;
});
$(".previous").on('click', function(){
if(window.pageNumber!=1){
window.pageNumber--;
}
var options = {
pdfOpenParams: {
pagemode: "thumbs",
navpanes: 0,
toolbar: 0,
statusbar: 0,
view: "FitV",
page: window.pageNumber
}
};
var pdfURL = getUrlParameter('url');
window.myPDF = PDFObject.embed(pdfURL, "#pdf", options);
});
$(".next").on('click', function(){
window.pageNumber++;
var options = {
pdfOpenParams: {
pagemode: "thumbs",
navpanes: 0,
toolbar: 0,
statusbar: 0,
view: "FitV",
page: window.pageNumber
}
};
var pdfURL = getUrlParameter('url');
window.myPDF = PDFObject.embed(pdfURL, "#pdf", options);
})
</script>
</body>
</html>