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 >
0 commit comments