-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
102 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
html { | ||
height: 100%; | ||
} | ||
|
||
body { | ||
height: 100%; | ||
margin: 0; | ||
} | ||
|
||
canvas { | ||
height: 100%; | ||
width: 100%; | ||
object-fit: contain; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import pdfjs from 'https://cdn.jsdelivr.net/npm/pdfjs-dist@3.2.146/+esm'; | ||
|
||
pdfjs.GlobalWorkerOptions.workerSrc = 'https://cdn.jsdelivr.net/npm/pdfjs-dist@3.2.146/build/pdf.worker.min.js'; | ||
|
||
let canvas = document.querySelector('canvas'); | ||
|
||
let pdf = await pdfjs.getDocument(`/content/${canvas.dataset.inscription}`).promise; | ||
|
||
let page = await pdf.getPage(1); | ||
|
||
let scale = window.devicePixelRatio || 1; | ||
|
||
let viewport = page.getViewport({ scale }); | ||
|
||
canvas.width = Math.ceil(viewport.width * scale); | ||
|
||
canvas.height = Math.ceil(viewport.height * scale); | ||
|
||
page.render({ | ||
canvasContext: canvas.getContext('2d'), | ||
transform: [scale, 0, 0, scale, 0, 0], | ||
viewport, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!doctype html> | ||
<html lang=en> | ||
<head> | ||
<meta charset=utf-8> | ||
<link rel=stylesheet href=/static/preview-pdf.css> | ||
<script src=/static/preview-pdf.js defer type=module></script> | ||
</head> | ||
<body> | ||
<canvas data-inscription={{self.inscription_id}}></canvas> | ||
</body> | ||
</html> |