-
Notifications
You must be signed in to change notification settings - Fork 2
/
preview-canvas.html
45 lines (37 loc) · 1.04 KB
/
preview-canvas.html
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
<!DOCTYPE html>
<html lang="en-AU">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="initial-scale=1, minimum-scale=1" />
<link rel="stylesheet" type="text/css" href="node_modules/urw-core35-fonts/index.css" />
<title>Canvas Preview</title>
<style>
*{
tab-size: 4;
box-sizing: border-box;
}
canvas{
position: fixed;
top: 0;
left: 0;
width: 100vw;
}
</style>
</head>
<body>
<canvas></canvas>
<script>
"use strict";
const source = require("fs").readFileSync("./test/fixtures/pdf-fonts.out", "utf8");
const CanvasRenderer = require("./lib/postproc/canvas.js");
const renderer = new CanvasRenderer();
renderer.process(source);
const canvas = document.querySelector("canvas");
canvas.width = window.innerWidth * window.devicePixelRatio;
canvas.height = window.innerHeight * window.devicePixelRatio;
const context = canvas.getContext("2d");
renderer.renderPage(1, context);
</script>
</body>
</html>