forked from parallax/jsPDF
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpdf2.html
More file actions
87 lines (77 loc) · 1.94 KB
/
Copy pathpdf2.html
File metadata and controls
87 lines (77 loc) · 1.94 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
.feedback-overlay-black {
background-color: #000;
opacity: 0.5;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
margin: 0;
}
</style>
<style>
div {
padding: 20px;
margin: 0 auto;
border: 5px solid black;
}
h1 {
border-bottom: 2px solid white;
}
h2 {
background: #efefef;
padding: 10px;
}
</style>
</head>
<body>
<div style="background: red;">
<div style="background: green;">
<div style="background: blue; border-color: white;">
<div style="background: yellow;">
<div style="background: orange;">
<h1>Heading</h1>
Text that isn't wrapped in anything.
<p>
Followed by some text wrapped in a <b><p> paragraph.</b>
</p>
<p>
Maybe add a <a href="#">link</a> or a different style of <a href="#" style='font-weight: 700; color: purple; font-size: 2em' id="highlight">link with a highlight</a>.
</p>
<hr />
<h2>More content</h2>
<div style="width: 10px; height: 10px; border-width: 10px; padding: 0;">a</div>
</div>
</div>
</div>
</div>
</div>
<script src='../../dist/jspdf.debug.js'></script>
<script src='../../libs/html2pdf.js'></script>
<script>
var pdf = new jsPDF('p', 'pt', 'letter');
var canvas = pdf.canvas;
var width = 600;
//canvas.width=8.5*72;
document.body.style.width=width + "px";
html2canvas(document.body, {
canvas:canvas,
onrendered: function(canvas) {
var iframe = document.createElement('iframe');
iframe.setAttribute('style', 'position:absolute;top:0;right:0;height:100%; width:600px');
document.body.appendChild(iframe);
iframe.src = pdf.output('datauristring');
//var div = document.createElement('pre');
//div.innerText=pdf.output();
//document.body.appendChild(div);
}
});
</script>
</body>
</html>