Skip to content

Commit 37016fb

Browse files
committed
Added examples for lines and rectangles
1 parent aed3044 commit 37016fb

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

examples/basic.htm

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,37 @@ <h2>Draw example: rectangles / squares</h2>
182182
doc.output('datauri');</pre>
183183
<a href="javascript:demo7()">Run Code</a>
184184

185+
<h2>Draw example: lines</h2>
186+
<pre>var doc = new jsPDF();
187+
188+
doc.line(20, 20, 60, 20); // horizontal line
189+
190+
doc.setLineWidth(0.5);
191+
doc.line(20, 25, 60, 25);
192+
193+
doc.setLineWidth(1);
194+
doc.line(20, 30, 60, 30);
195+
196+
doc.setLineWidth(1.5);
197+
doc.line(20, 35, 60, 35);
198+
199+
doc.setDrawColor(255,0,0); // draw red lines
200+
201+
doc.setLineWidth(0.1);
202+
doc.line(100, 20, 100, 60); // vertical line
203+
204+
doc.setLineWidth(0.5);
205+
doc.line(105, 20, 105, 60);
206+
207+
doc.setLineWidth(1);
208+
doc.line(110, 20, 110, 60);
209+
210+
doc.setLineWidth(1.5);
211+
doc.line(115, 20, 115, 60);
212+
213+
// Output as Data URI
214+
doc.output('datauri');</pre>
215+
<a href="javascript:demo8()">Run Code</a>
185216

186217
<script type="text/javascript">
187218

@@ -324,6 +355,38 @@ <h2>Draw example: rectangles / squares</h2>
324355
doc.output('datauri');
325356
}
326357

358+
function demo8() {
359+
var doc = new jsPDF();
360+
361+
doc.line(20, 20, 60, 20); // horizontal line
362+
363+
doc.setLineWidth(0.5);
364+
doc.line(20, 25, 60, 25);
365+
366+
doc.setLineWidth(1);
367+
doc.line(20, 30, 60, 30);
368+
369+
doc.setLineWidth(1.5);
370+
doc.line(20, 35, 60, 35);
371+
372+
doc.setDrawColor(255,0,0); // draw red lines
373+
374+
doc.setLineWidth(0.1);
375+
doc.line(100, 20, 100, 60); // vertical line
376+
377+
doc.setLineWidth(0.5);
378+
doc.line(105, 20, 105, 60);
379+
380+
doc.setLineWidth(1);
381+
doc.line(110, 20, 110, 60);
382+
383+
doc.setLineWidth(1.5);
384+
doc.line(115, 20, 115, 60);
385+
386+
// Output as Data URI
387+
doc.output('datauri');
388+
}
389+
327390
</script>
328391

329392

0 commit comments

Comments
 (0)