4242
4343< h1 > jsPDF Demos</ h1 >
4444
45- < p > Examples for using jsPDF with Data URIs below. Go < a href ="http ://jspdf.googlecode. com/ "> back to project homepage</ a > .</ p >
45+ < p > Examples for using jsPDF with Data URIs below. Go < a href ="https ://github. com/MrRio/jsPDF "> back to project homepage</ a > .</ p >
4646
4747< h2 > Simple Two-page Text Document</ h2 >
4848< pre > var doc = new jsPDF();
@@ -53,7 +53,7 @@ <h2>Simple Two-page Text Document</h2>
5353
5454// Output as Data URI
5555doc.output('datauri');</ pre >
56- < a href ="javascript:demo1 () "> Run Code</ a >
56+ < a href ="javascript:demoTwoPageDocument () "> Run Code</ a >
5757
5858< h2 > Different font sizes</ h2 >
5959< pre > var doc = new jsPDF();
@@ -65,7 +65,7 @@ <h2>Different font sizes</h2>
6565
6666// Output as Data URI
6767doc.output('datauri');</ pre >
68- < a href ="javascript:demo2 () "> Run Code</ a >
68+ < a href ="javascript:demoFontSizes () "> Run Code</ a >
6969
7070< h2 > Different font types</ h2 >
7171< pre > var doc = new jsPDF();
@@ -89,7 +89,7 @@ <h2>Different font types</h2>
8989
9090// Output as Data URI
9191doc.output('datauri');</ pre >
92- < a href ="javascript:demo3 () "> Run Code</ a >
92+ < a href ="javascript:demoFontTypes () "> Run Code</ a >
9393
9494< h2 > Different text colors</ h2 >
9595< pre > var doc = new jsPDF();
@@ -111,7 +111,7 @@ <h2>Different text colors</h2>
111111
112112// Output as Data URI
113113doc.output('datauri');</ pre >
114- < a href ="javascript:demo4 () "> Run Code</ a >
114+ < a href ="javascript:demoTextColors () "> Run Code</ a >
115115
116116< h2 > Adding metadata</ h2 >
117117< pre > var doc = new jsPDF();
@@ -128,7 +128,7 @@ <h2>Adding metadata</h2>
128128
129129// Output as Data URI
130130doc.output('datauri');</ pre >
131- < a href ="javascript:demo5 () "> Run Code</ a >
131+ < a href ="javascript:demoMetadata () "> Run Code</ a >
132132
133133
134134< h2 > Example of user input</ h2 >
@@ -155,7 +155,7 @@ <h2>Example of user input</h2>
155155 doc.text(20, 30 + (i * 10), i + ' x ' + multiplier + ' = ' + (i * multiplier));
156156}
157157doc.output('datauri');</ pre >
158- < a href ="javascript:demo6 () "> Run Code</ a >
158+ < a href ="javascript:demoUserInput () "> Run Code</ a >
159159
160160< h2 > Draw example: rectangles / squares</ h2 >
161161< pre > var doc = new jsPDF();
@@ -180,7 +180,7 @@ <h2>Draw example: rectangles / squares</h2>
180180
181181// Output as Data URI
182182doc.output('datauri');</ pre >
183- < a href ="javascript:demo7 () "> Run Code</ a >
183+ < a href ="javascript:demoRectangles () "> Run Code</ a >
184184
185185< h2 > Draw example: lines</ h2 >
186186< pre > var doc = new jsPDF();
@@ -212,11 +212,28 @@ <h2>Draw example: lines</h2>
212212
213213// Output as Data URI
214214doc.output('datauri');</ pre >
215- < a href ="javascript:demo8() "> Run Code</ a >
215+ < a href ="javascript:demoLines() "> Run Code</ a >
216+
217+ < h2 > Draw circles and ellipses: lines</ h2 >
218+ < pre > var doc = new jsPDF();
219+
220+ doc.ellipse(40, 20, 10, 5);
221+
222+ doc.setFillColor(0,0,255);
223+ doc.ellipse(80, 20, 10, 5, 'F');
224+
225+ doc.setLineWidth(1);
226+ doc.setDrawColor(0);
227+ doc.setFillColor(255,0,0);
228+ doc.circle(120, 20, 5, 'FD');
229+
230+ // Output as Data URI
231+ doc.output('datauri');</ pre >
232+ < a href ="javascript:demoCircles() "> Run Code</ a >
216233
217234< script type ="text/javascript ">
218235
219- function demo1 ( ) {
236+ function demoTwoPageDocument ( ) {
220237 var doc = new jsPDF ( ) ;
221238 doc . text ( 20 , 20 , 'Hello world!' ) ;
222239 doc . text ( 20 , 30 , 'This is client-side Javascript, pumping out a PDF.' ) ;
@@ -227,7 +244,7 @@ <h2>Draw example: lines</h2>
227244 doc . output ( 'datauri' ) ;
228245}
229246
230- function demo2 ( ) {
247+ function demoFontSizes ( ) {
231248 var doc = new jsPDF ( ) ;
232249 doc . setFontSize ( 22 ) ;
233250 doc . text ( 20 , 20 , 'This is a title' ) ;
@@ -239,7 +256,7 @@ <h2>Draw example: lines</h2>
239256 doc . output ( 'datauri' ) ;
240257}
241258
242- function demo3 ( ) {
259+ function demoFontTypes ( ) {
243260 var doc = new jsPDF ( ) ;
244261
245262 doc . text ( 20 , 20 , 'This is the default font.' ) ;
@@ -264,7 +281,7 @@ <h2>Draw example: lines</h2>
264281 doc . output ( 'datauri' ) ;
265282}
266283
267- function demo4 ( ) {
284+ function demoTextColors ( ) {
268285 var doc = new jsPDF ( ) ;
269286
270287 doc . setTextColor ( 100 ) ;
@@ -286,7 +303,7 @@ <h2>Draw example: lines</h2>
286303 doc . output ( 'datauri' ) ;
287304}
288305
289- function demo5 ( ) {
306+ function demoMetadata ( ) {
290307 var doc = new jsPDF ( ) ;
291308 doc . text ( 20 , 20 , 'This PDF has a title, subject, author, keywords and a creator.' ) ;
292309
@@ -303,7 +320,7 @@ <h2>Draw example: lines</h2>
303320 doc . output ( 'datauri' ) ;
304321}
305322
306- function demo6 ( ) {
323+ function demoUserInput ( ) {
307324 var name = prompt ( 'What is your name?' ) ;
308325 var multiplier = prompt ( 'Enter a number:' ) ;
309326 multiplier = parseInt ( multiplier ) ;
@@ -330,7 +347,7 @@ <h2>Draw example: lines</h2>
330347
331348}
332349
333- function demo7 ( ) {
350+ function demoRectangles ( ) {
334351 var doc = new jsPDF ( ) ;
335352
336353 doc . rect ( 20 , 20 , 10 , 10 ) ; // empty square
@@ -355,7 +372,7 @@ <h2>Draw example: lines</h2>
355372 doc . output ( 'datauri' ) ;
356373}
357374
358- function demo8 ( ) {
375+ function demoLines ( ) {
359376 var doc = new jsPDF ( ) ;
360377
361378 doc . line ( 20 , 20 , 60 , 20 ) ; // horizontal line
@@ -387,6 +404,22 @@ <h2>Draw example: lines</h2>
387404 doc . output ( 'datauri' ) ;
388405}
389406
407+ function demoCircles ( ) {
408+ var doc = new jsPDF ( ) ;
409+
410+ doc . ellipse ( 40 , 20 , 10 , 5 ) ;
411+
412+ doc . setFillColor ( 0 , 0 , 255 ) ;
413+ doc . ellipse ( 80 , 20 , 10 , 5 , 'F' ) ;
414+
415+ doc . setLineWidth ( 1 ) ;
416+ doc . setDrawColor ( 0 ) ;
417+ doc . setFillColor ( 255 , 0 , 0 ) ;
418+ doc . circle ( 120 , 20 , 5 , 'FD' ) ;
419+
420+ // Output as Data URI
421+ doc . output ( 'datauri' ) ;
422+ }
390423</ script >
391424
392425
0 commit comments