-
-
Notifications
You must be signed in to change notification settings - Fork 624
/
index.html
274 lines (243 loc) · 7.89 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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pure/0.6.0/pure-min.css">-->
<link rel="stylesheet" href="examples/libs/pure-min.css">
<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pure/0.6.0/grids-responsive-min.css">-->
<link rel="stylesheet" href="examples/libs/grids-responsive-min.css">
<title>AutoTable sample</title>
<style>
* {
box-sizing: border-box;
}
html, body {
height: 100%;
overflow: hidden;
}
.navbar {
position: absolute;
top: 0;
left: 0;
right: 0;
background: #e74c3c;
border-bottom: 5px solid #c0392b;
height: 50px;
white-space: nowrap;
overflow-x: auto;
overflow-y: hidden;
padding: 0 10px;
}
.navbar h1 {
font-size: 20px;
color: #fff;
}
.menu {
padding: 0;
list-style: none;
}
.menu li {
vertical-align: top;
}
.menu li a {
text-decoration: none;
color: #fff;
font-weight: bold;
font-family: sans-serif;
padding: 10px 0;
line-height: 25px;
}
.menu li a:hover {
font-style: italic;
}
#panel {
background: #141f2b;
padding: 10px;
height: 100%;
}
#wrapper {
overflow: hidden;
height: 100%;
background: rgba(193, 193, 193, 1);
}
#output {
width: 100%;
height: 100%;
background: rgba(193, 193, 193, 1);
}
.table {
font-size: 14px;
}
</style>
</head>
<body>
<header class="navbar">
<h1>AutoTable - Generate PDF tables and lists (jsPDF plugin)</h1>
</header>
<div class="pure-g" style="padding-top: 50px; height: 100%;">
<div id="panel" class="pure-u-1 pure-u-md-1-5">
<ul class="menu">
<li><a href="#">Basic</a></li>
<li><a href="#minimal">Minimal</a></li>
<li><a href="#long">Long text</a></li>
<li><a href="#content">With content</a></li>
<li><a href="#multiple">Multiple tables</a></li>
<li><a href="#header-footer">Header and footer</a></li>
<li><a href="#defaults">Default options</a></li>
<li><a href="#colstyles">Column styles</a></li>
<li><a href="#spans">Rowspan and colspan</a></li>
<li><a href="#themes">Themes</a></li>
<li><a href="#nested">Nested</a></li>
<li><a href="#custom">Custom style</a></li>
<li><a href="#borders">Custom borders</a></li>
<li><a href="#horizontalPageBreak">Horizontal Page Break</a></li>
<li><a href="#horizontalPageBreakRepeat">Horizontal Page Break Repeat</a></li>
<li><a href="#horizontalPageBreakBehaviour">Horizontal Page Break Behaviour</a></li>
</ul>
<button id="download-btn" class="pure-button">Download PDF</button>
<!--<div class="editor">
<pre><code class="javascript">var test = "hey!";</code></pre></div>-->
</div>
<div id="wrapper" class="pure-u-1 pure-u-md-4-5">
<!--<iframe id="output"></iframe>-->
<object id="output" type="application/pdf">
<p>It appears you don't have PDF support in this web browser. <a href="#" id="download-link">Click here to download the PDF</a>.</p>
</object>
</div>
</div>
<style>
td, th {
border: solid 1px #777;
padding: 5px;
text-align: left;
}
</style>
<table class="table pure-table" id="basic-table" style="display: none;">
<thead>
<tr>
<th>ID</th>
<th colspan="2">Name</th>
<th>Email</th>
<th>Country</th>
<th>IP-address</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Donna</td>
<td>Moore</td>
<td>dmoore0@furl.net</td>
<td>China</td>
<td>211.56.242.221</td>
</tr>
<tr style="background: rgb(155, 89, 182); color: white;">
<td>2</td>
<td>Janice</td>
<td>Henry</td>
<td>jhenry1@theatlantic.com</td>
<td>Ukraine</td>
<td>38.36.7.199</td>
</tr>
<tr>
<td>3</td>
<td>Ruth</td>
<td>Wells</td>
<td>rwells2@constantcontact.com</td>
<td>Mexico</td>
<td>19.162.133.184</td>
</tr>
<tr>
<td>4</td>
<td>Jason</td>
<td>Ray</td>
<td>jray3@psu.edu</td>
<td>Brazil</td>
<td>10.68.11.42</td>
</tr>
<tr>
<td>5</td>
<td>Jane</td>
<td>Stephens</td>
<td>jstephens4@go.com</td>
<td>United States</td>
<td>47.32.129.71</td>
</tr>
<tr>
<td>6</td>
<td>Adam</td>
<td>Nichols</td>
<td>anichols5@com.com</td>
<td>Canada</td>
<td>18.186.38.37<br>18.123.22.82</td>
</tr>
</tbody>
</table>
<script>if (!window.Promise) window.Promise = {prototype: null}; // Needed for jspdf IE support</script>
<!-- 1.3.5 (no custom fonts), 1.4.1, 1.5.3 -->
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.4.1/jspdf.debug.js"></script>-->
<script src="examples/libs/jspdf.umd.js"></script>
<script>if (!window.jsPDF) window.jsPDF = window.jspdf.jsPDF</script>
<script src="examples/mitubachi-normal.js"></script>
<script src="examples/libs/faker.min.js"></script>
<script src="dist/jspdf.plugin.autotable.js"></script>
<script src="examples/examples.js"></script>
<!-- Some scripts to make the examples work nicely -->
<script>
window.onhashchange = function () {
update();
};
document.getElementById('download-btn').onclick = function () {
update(true);
};
document.getElementById('download-link').onclick = function () {
update(true);
};
function update(shouldDownload) {
var funcStr = window.location.hash.replace(/#/g, '') || 'basic';
var doc = window.examples[funcStr]();
doc.setProperties({
title: 'Example: ' + funcStr,
subject: 'A jspdf-autotable example pdf (' + funcStr + ')'
});
if (shouldDownload) {
doc.save('table.pdf');
} else {
//document.getElementById("output").src = doc.output('datauristring');
document.getElementById("output").data = doc.output('datauristring');
}
}
var base64Img, coinBase64Img;
imgToBase64('examples/document.jpg', function(base64) {
base64Img = base64;
imgToBase64('examples/coin.png', function(base64) {
coinBase64Img = base64;
update();
});
});
// You could either use a function similar to this or pre convert an image with for example http://dopiaza.org/tools/datauri
// https://stackoverflow.com/a/20285053/827047
function imgToBase64(src, callback) {
var outputFormat = src.substr(-3) === 'png' ? 'image/png' : 'image/jpeg';
var img = new Image();
img.crossOrigin = 'Anonymous';
img.onload = function() {
var canvas = document.createElement('CANVAS');
var ctx = canvas.getContext('2d');
var dataURL;
canvas.height = this.naturalHeight;
canvas.width = this.naturalWidth;
ctx.drawImage(this, 0, 0);
dataURL = canvas.toDataURL(outputFormat);
callback(dataURL);
};
img.src = src;
if (img.complete || img.complete === undefined) {
img.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
img.src = src;
}
}
</script>
</body>
</html>