Skip to content

Commit b918c9a

Browse files
author
James Hall
committed
Table branch
1 parent d6e64c9 commit b918c9a

4 files changed

Lines changed: 136 additions & 1 deletion

File tree

examples/tables.htm

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<!DOCTYPE>
2+
<html>
3+
<head>
4+
<title>jsPDF</title>
5+
<style type="text/css">
6+
* { padding: 0; margin: 0; }
7+
body {
8+
padding: 30px;
9+
font-family: Arial, Helvetica, sans-serif;
10+
}
11+
h1 {
12+
margin-bottom: 1em;
13+
border-bottom: 1px solid #ccc;
14+
}
15+
16+
h2 {
17+
margin-bottom: 1em;
18+
border-bottom: 1px solid #ccc;
19+
}
20+
21+
pre {
22+
border: 1px dotted #ccc;
23+
background: #f7f7f7;
24+
padding: 10px;
25+
margin-bottom: 1em;
26+
}
27+
28+
h1 {
29+
margin-bottom: 0.7em;
30+
}
31+
32+
h2 {
33+
margin-top: 1em;
34+
}
35+
36+
p {
37+
margin-bottom: 1em;
38+
}
39+
table td, table th {
40+
border-top: 1px solid #ccc;
41+
border-left: 1px solid #ccc;
42+
text-align: left;
43+
padding: 5px;
44+
}
45+
46+
table {
47+
border-right: 1px solid #ccc;
48+
border-bottom: 1px solid #ccc;
49+
margin-bottom: 1em;
50+
}
51+
</style>
52+
<script type="text/javascript" src="../libs/base64.js"></script>
53+
<script type="text/javascript" src="../libs/sprintf.js"></script>
54+
<script type="text/javascript" src="../libs/jquery-1.5.1.min.js"></script>
55+
<script type="text/javascript" src="../jspdf.js"></script>
56+
</head>
57+
<body>
58+
<h1>jsPDF Demos</h1>
59+
60+
<p><b>This demo is unfinished.</b> Export a table to PDF.</p>
61+
62+
63+
<table cellpadding="0" cellspacing="0" id="export">
64+
<tr>
65+
<th>Name</th>
66+
<th>DOB</th>
67+
<th>City</th>
68+
</tr>
69+
<tr>
70+
<td>James Hall</td>
71+
<td>10th December</td>
72+
<td>York</td>
73+
</tr>
74+
<tr>
75+
<td>Dario Grandich</td>
76+
<td>10th December</td>
77+
<td>York</td>
78+
</tr>
79+
</table>
80+
81+
<p><a href="javascript:generateTable()">Generate Table</a></p>
82+
<script>
83+
84+
85+
var createTable = function(jspdf, table) {
86+
87+
jspdf.setDrawColor(204, 204, 204);
88+
89+
jspdf.line(20, 13, 180, 13);
90+
jspdf.text(23, 20, 'Something here');
91+
jspdf.line(20, 23, 180, 23);
92+
jspdf.text(23, 30, 'Something here');
93+
jspdf.line(20, 33, 180, 33);
94+
95+
// Sides
96+
jspdf.line(20, 13, 20, 33);
97+
jspdf.line(180, 13, 180, 33);
98+
99+
}
100+
101+
102+
function generateTable() {
103+
var doc = new jsPDF();
104+
105+
//doc.text(20, 20, 'This PDF has a title, subject, author, keywords and a creator.').text(20, 40, 'More');
106+
107+
createTable(doc, document.getElementById('export'));
108+
109+
doc.output('datauri');
110+
}
111+
112+
</script>
113+
114+
</body>
115+
</html>

jspdf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var jsPDF = function(orientation, unit, format){
1313
if (typeof format === 'undefined') format = 'a4';
1414

1515
// Private properties
16-
var version = '20100328';
16+
var version = '20110304';
1717
var buffer = '';
1818

1919
var pdfVersion = '1.3'; // PDF Version

jspdfutils.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
var jsPDFUtils = function() {
2+
3+
4+
}

libs/jquery-1.5.1.min.js

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)