-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathindex.html
More file actions
42 lines (40 loc) · 1.32 KB
/
Copy pathindex.html
File metadata and controls
42 lines (40 loc) · 1.32 KB
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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Page Flip Vanilla JS</title>
<style>
#app { width: 800px; height: 600px; border: 1px solid #ccc; margin-bottom: 10px; }
button { margin-right: 5px; }
</style>
</head>
<body>
<div id="app"></div>
<button id="prev">Prev</button>
<button id="next">Next</button>
<button id="zoom">Zoom</button>
<!-- Load the built files -->
<script src="dist/pdf.worker.js"></script>
<script src="dist/flipbook-viewer.js"></script>
<script src="dist/book.pdf.js"></script>
<script>
// Apply to Vanilla JS
const opts = { width: 800, height: 600 };
const app = document.getElementById('app');
const next = document.getElementById('next');
const prev = document.getElementById('prev');
const zoom = document.getElementById('zoom');
// using book.init from book.pdf.js
book.init('sample-local-pdf.pdf', function(err, bookObj) {
if (err) return console.error(err);
flipbook.init(bookObj, app, opts, function(err, viewer) {
if (err) return console.error(err);
viewer.on('seen', n => console.log('page number: ' + n));
next.onclick = () => viewer.flip_forward();
prev.onclick = () => viewer.flip_back();
zoom.onclick = () => viewer.zoom();
});
});
</script>
</body>
</html>