Spaces:
Sleeping
Sleeping
Update templates/gui.html
Browse files- templates/gui.html +6 -39
templates/gui.html
CHANGED
|
@@ -3,49 +3,16 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>PDF
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.11.938/pdf.min.js"></script>
|
| 10 |
|
| 11 |
<script>
|
| 12 |
-
//
|
| 13 |
-
|
| 14 |
-
console.log('PDF.js loaded successfully');
|
| 15 |
-
} else {
|
| 16 |
-
console.error('Failed to load PDF.js');
|
| 17 |
-
}
|
| 18 |
-
|
| 19 |
-
// Render PDF on page load
|
| 20 |
-
async function renderPdf() {
|
| 21 |
-
try {
|
| 22 |
-
const url = '/download-pdf';
|
| 23 |
-
const pdf = await pdfjsLib.getDocument(url).promise;
|
| 24 |
-
|
| 25 |
-
console.log('PDF loaded');
|
| 26 |
-
|
| 27 |
-
const page = await pdf.getPage(2); // Load the second page
|
| 28 |
-
|
| 29 |
-
const viewport = page.getViewport({ scale: 1.5 });
|
| 30 |
-
const canvas = document.getElementById('pdfCanvas');
|
| 31 |
-
const context = canvas.getContext('2d');
|
| 32 |
-
|
| 33 |
-
canvas.height = viewport.height;
|
| 34 |
-
canvas.width = viewport.width;
|
| 35 |
-
|
| 36 |
-
await page.render({ canvasContext: context, viewport }).promise;
|
| 37 |
-
|
| 38 |
-
} catch (error) {
|
| 39 |
-
console.error('Error loading PDF:', error);
|
| 40 |
-
}
|
| 41 |
-
}
|
| 42 |
-
|
| 43 |
-
window.onload = renderPdf;
|
| 44 |
</script>
|
| 45 |
-
</head>
|
| 46 |
|
| 47 |
-
<body>
|
| 48 |
-
<h2>PDF Viewer</h2>
|
| 49 |
-
<canvas id="pdfCanvas"></canvas>
|
| 50 |
</body>
|
| 51 |
</html>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>View PDF</title>
|
| 7 |
+
</head>
|
| 8 |
+
<body>
|
| 9 |
|
| 10 |
+
<h2>PDF Viewer</h2>
|
|
|
|
| 11 |
|
| 12 |
<script>
|
| 13 |
+
// Redirect to the PDF URL in the current tab
|
| 14 |
+
window.location.href = '/view-pdf';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
</script>
|
|
|
|
| 16 |
|
|
|
|
|
|
|
|
|
|
| 17 |
</body>
|
| 18 |
</html>
|