-
Notifications
You must be signed in to change notification settings - Fork 0
/
unknownazzwipe1.github.io
109 lines (94 loc) · 2.58 KB
/
unknownazzwipe1.github.io
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
<!DOCTYPE html>
<html>
<head>
<title>Material You PDF Viewer</title>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="manifest" href="manifest.json">
<script src="https://cdnjs.cloudflare.com/ajax/libs/pwabuilder/3.4.0/pwabuilder.min.js"></script>
<style>
* {
box-sizing: border-box;
}
body {
font-family: Roboto, sans-serif;
margin: 0;
padding: 0;
}
.pdf-viewer {
width: 100%;
height: 100%;
overflow: hidden;
}
.pdf-viewer canvas {
width: 100%;
height: 100%;
}
.pdf-viewer .controls {
position: absolute;
bottom: 0;
left: 0;
right: 0;
padding: 1rem;
background-color: var(--mdc-theme-surface);
border-top: 1px solid var(--mdc-theme-on-surface-100);
}
.pdf-viewer .controls button {
margin: 0 1rem;
padding: 0.5rem 1rem;
border: none;
background-color: transparent;
color: var(--mdc-theme-on-surface-100);
font-size: 1rem;
font-weight: 500;
cursor: pointer;
}
.pdf-viewer .controls button:hover {
background-color: var(--mdc-theme-primary);
color: white;
}
</style>
</head>
<body>
<div class="pdf-viewer">
<canvas></canvas>
<div class="controls">
<button>Previous</button>
<button>Next</button>
<button>Zoom In</button>
<button>Zoom Out</button>
<input type="file" id="pdf-file">
</div>
</div>
<script>
const pdfViewer = document.querySelector('.pdf-viewer');
const pdfCanvas = pdfViewer.querySelector('canvas');
const controls = pdfViewer.querySelector('.controls');
const pdfFile = null;
const pdf = new PDFJS.PDFDocument();
pdf.open(pdfFile);
pdf.getPage(1).then(page => {
const ctx = pdfCanvas.getContext('2d');
page.render(ctx);
});
controls.querySelectorAll('button').forEach(button => {
button.addEventListener('click', () => {
// Do something
});
});
// Handle the file selection
document.getElementById('pdf-file').addEventListener('change', () => {
pdfFile = document.getElementById('pdf-file').files[0];
// Load the new PDF file
pdf.open(pdfFile);
// Render the first page
pdf.getPage(1).then(page => {
const ctx = pdfCanvas.getContext('2d');
page.render(ctx);
});
});
// Install the PWA
pwaBuilder.install();
</script>
</body>
</html>