-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.html
48 lines (32 loc) · 1.5 KB
/
index.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
46
47
48
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<link rel="stylesheet" type="text/css" href="styles.css" />
<script src="src/ForeignHtmlRenderer.js" type="text/javascript"></script>
</head>
<body>
<div id="snapshotContainer"></div>
<script type="text/javascript">
const renderer = new ForeignHtmlRenderer(document.styleSheets);
renderer
.renderToBase64Png(`
<div style="background:#fff; border:2px solid #2687ea; padding:25px; border-radius:25px;">
<!-- text rendering -->
<p style="font-size:24px;">ABC ^ <span style="background:#000; color:#fff; padding:10px;">XYZ</span></p>
<!-- image rendering -->
<div><img src="test-bigfoot.svg" width="64" /></div>
<!-- background image rendering -->
<div style="background:url(test-bigfoot.svg) center center repeat-x; width:500px; height:100px;"></div>
<!-- background image rendering via CSS stylesheet-->
<div class="bg-image-pattern"></div>
</div>
`,
1024,
768)
.then((base64png) => {
document.getElementById(`snapshotContainer`).innerHTML = `<img src="${base64png}" />`;
});
</script>
</body>
</html>