Marthee commited on
Commit
9abb0bf
·
verified ·
1 Parent(s): 17982ca

Update templates/gui.html

Browse files
Files changed (1) hide show
  1. templates/gui.html +56 -1
templates/gui.html CHANGED
@@ -1,4 +1,4 @@
1
- <!DOCTYPE html>
2
  <html lang="en">
3
  <head>
4
  <meta charset="UTF-8">
@@ -26,3 +26,58 @@
26
 
27
  </body>
28
  </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- <!DOCTYPE html>
2
  <html lang="en">
3
  <head>
4
  <meta charset="UTF-8">
 
26
 
27
  </body>
28
  </html>
29
+ -->
30
+ <!DOCTYPE html>
31
+ <html lang="en">
32
+ <head>
33
+ <meta charset="UTF-8">
34
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
35
+ <title>PDF Viewer</title>
36
+
37
+ <!-- Include PDF.js -->
38
+ <script src="https://mozilla.github.io/pdf.js/build/pdf.js"></script>
39
+
40
+ <style>
41
+ #pdf-container {
42
+ height: 90vh;
43
+ }
44
+ </style>
45
+ </head>
46
+ <body>
47
+
48
+ <h2>View PDF</h2>
49
+
50
+ <!-- PDF Rendering Container -->
51
+ <div id="pdf-container"></div>
52
+
53
+ <script>
54
+ async function openPdf() {
55
+ const url = `/view-pdf#page=${getPageFromHash()}`;
56
+
57
+ const pdfContainer = document.getElementById('pdf-container');
58
+
59
+ const pdf = await pdfjsLib.getDocument(url).promise;
60
+
61
+ const page = await pdf.getPage(parseInt(getPageFromHash()));
62
+
63
+ const viewport = page.getViewport({ scale: 1.5 });
64
+
65
+ const canvas = document.createElement('canvas');
66
+ const context = canvas.getContext('2d');
67
+ canvas.height = viewport.height;
68
+ canvas.width = viewport.width;
69
+
70
+ pdfContainer.appendChild(canvas);
71
+
72
+ await page.render({ canvasContext: context }).promise;
73
+ }
74
+
75
+ function getPageFromHash() {
76
+ const hashContent = window.location.hash.substring(6);
77
+ return parseInt(hashContent.split("#")[0]);
78
+ }
79
+
80
+ openPdf();
81
+ </script>
82
+
83
+ </body>