@@ -157,6 +157,30 @@ <h2>Example of user input</h2>
157157doc.output('datauri');</ pre >
158158< a href ="javascript:demo6() "> Run Code</ a >
159159
160+ < h2 > Draw example: rectangles / squares</ h2 >
161+ < pre > var doc = new jsPDF();
162+
163+ doc.rect(20, 20, 10, 10); // empty square
164+
165+ doc.rect(40, 20, 10, 10, 'F'); // filled square
166+
167+ doc.setDrawColor(255,0,0);
168+ doc.rect(60, 20, 10, 10); // empty red square
169+
170+ doc.setDrawColor(255,0,0);
171+ doc.rect(80, 20, 10, 10, 'FD'); // filled square with red borders
172+
173+ doc.setDrawColor(0);
174+ doc.setFillColor(255,0,0);
175+ doc.rect(100, 20, 10, 10, 'F'); // filled red square
176+
177+ doc.setDrawColor(0);
178+ doc.setFillColor(255,0,0);
179+ doc.rect(120, 20, 10, 10, 'FD'); // filled red square with black borders
180+
181+ // Output as Data URI
182+ doc.output('datauri');</ pre >
183+ < a href ="javascript:demo7() "> Run Code</ a >
160184
161185
162186< script type ="text/javascript ">
@@ -275,6 +299,31 @@ <h2>Example of user input</h2>
275299
276300}
277301
302+ function demo7 ( ) {
303+ var doc = new jsPDF ( ) ;
304+
305+ doc . rect ( 20 , 20 , 10 , 10 ) ; // empty square
306+
307+ doc . rect ( 40 , 20 , 10 , 10 , 'F' ) ; // filled square
308+
309+ doc . setDrawColor ( 255 , 0 , 0 ) ;
310+ doc . rect ( 60 , 20 , 10 , 10 ) ; // empty red square
311+
312+ doc . setDrawColor ( 255 , 0 , 0 ) ;
313+ doc . rect ( 80 , 20 , 10 , 10 , 'FD' ) ; // filled square with red borders
314+
315+ doc . setDrawColor ( 0 ) ;
316+ doc . setFillColor ( 255 , 0 , 0 ) ;
317+ doc . rect ( 100 , 20 , 10 , 10 , 'F' ) ; // filled red square
318+
319+ doc . setDrawColor ( 0 ) ;
320+ doc . setFillColor ( 255 , 0 , 0 ) ;
321+ doc . rect ( 120 , 20 , 10 , 10 , 'FD' ) ; // filled red square with black borders
322+
323+ // Output as Data URI
324+ doc . output ( 'datauri' ) ;
325+ }
326+
278327</ script >
279328
280329
0 commit comments