-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
50 lines (44 loc) · 1.45 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
49
50
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML to PDF</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js" integrity="sha512-GsLlZN/3F2ErC5ifS5QtgpiJtWd43JWSuIgh7mbzZ8zBps+dvLusV+eNQATqgA/HdeKFVgA5v3S/cIrLF7QnIg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
</head>
<body>
<div>
This is a test!
</div>
<div id="html2pdf" style="padding: 0 20px; font-size: 30px; display:block;">
<h1>Title sample</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
<br>
sed do eiusmod tempor incididunt ut labore et
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
<br>
sed do eiusmod tempor incididunt ut labore et
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
<br>
sed do eiusmod tempor incididunt ut labore et
</p>
</div>
<div style="padding: 0 50px;">
<button style="padding: 10px" id="exportPDF">
Download PDf
</button>
</div>
<script>
let html2PDF = document.getElementById("html2pdf");
let exportPDF = document.getElementById("exportPDF");
// New Promise-based usage:
exportPDF.onclick = (e) => html2pdf(html2PDF);
</script>
</body>
</html>