MrRio/jsPDF — pull request #203 by bgribaudo (2014-03-07 21:30:58+00:00)
Title: Setting lines()'s style can be posponed

At present, calls to lines() always output a PDF path-painting operator (S, F, B, etc.). With this patch, a null style suppresses output of the path-painting operator so that a single shape may be defined using multiple lines() calls.

This patch allows jspdf.plugin.svgToPDF (https://github.com/ahwolf/jsPDF/blob/master/jspdf.plugin.svgToPdf.js) to work (see lines 338, 369, 384 which rely on this behavior).

## Example
This patch allows the following:
````
var pdf = new jsPDF("portrait", "mm", "letter");
pdf.lines([[0.05759999999999721,-0.02880000000000038,0.11519999999999797,-0.02880000000000038,0.2015999999999991,-0.02880000000000038],[0.345600000000001,0,0.7487999999999992,0.28800000000000025,1.3247999999999997,1.0079999999999991],[2.332799999999999,2.6784,3.9743999999999992,7.344000000000001,3.9743999999999992,11.145600000000001],[0,0.2879999999999967,-0.05760000000000076,0.5183999999999997,-0.05760000000000076,0.8063999999999964],[-0.2591999999999999,4.521599999999999,-2.1023999999999994,8.236800000000002,-5.759999999999998,11.750399999999999],[-0.9791999999999987,0.9504000000000019],[-0.345600000000001,0.3744000000000014],[0,0.11520000000000152],[0.2015999999999991,0.8639999999999972],[0.31680000000000063,1.5551999999999992],[0.31680000000000063,1.4400000000000048],[0.4319999999999986,1.9583999999999974,0.6047999999999973,2.9664,0.6047999999999973,2.9664],[0,0,0,0,0,0],[0,0,0.11520000000000152,0,0.2591999999999999,-0.028800000000003933],[0.1440000000000019,0,0.6048000000000009,-0.05760000000000076,1.0944000000000002,-0.05760000000000076],[0.345600000000001,0,0.691200000000002,0.05760000000000076,0.8640000000000008,0.05760000000000076],[4.0608,0.5183999999999997,7.199999999999999,3.427199999999999,8.0928,7.516799999999996],[0.17279999999999873,0.6624000000000052,0.2303999999999995,1.382400000000004,0.2303999999999995,2.102400000000003],[0,3.8880000000000052,-2.332799999999999,7.603200000000001,-6.2208000000000005,9.36],[-0.2303999999999995,0.14400000000000546,-0.3167999999999971,0.17279999999999518,-0.3167999999999971,0.17279999999999518],[0,0.028800000000003933],[0,0,0.17279999999999873,0.6624000000000052,0.3167999999999971,1.411200000000008],[0.43200000000000216,2.1888000000000005],[0.4031999999999982,1.7567999999999983],[0.2303999999999995,1.123199999999997,0.345600000000001,1.9295999999999935,0.345600000000001,2.6495999999999924],[0,0.6336000000000013,-0.08640000000000114,1.209600000000009,-0.2303999999999995,1.8719999999999998],[-0.9792000000000023,4.003200000000007,-4.464000000000002,6.393600000000006,-8.0928,6.393600000000006],[-1.7856000000000005,0,-3.6288,-0.5760000000000076,-5.2416,-1.8719999999999998],[-1.4399999999999995,-1.209600000000009,-2.0736000000000007,-2.304000000000002,-2.0736000000000007,-3.7439999999999997],[0,-2.534400000000005,2.0448000000000004,-4.320000000000007,4.176,-4.320000000000007],[0.748800000000001,0,1.4976000000000002,0.23040000000000305,2.217600000000001,0.6624000000000052],[1.2096,0.8352000000000004,1.7568000000000001,2.102400000000003,1.7568000000000001,3.3408000000000015],[0,1.9008000000000038,-1.3247999999999997,3.7728000000000037,-3.6000000000000014,3.916799999999995],[-0.2303999999999995,0],[0.1728000000000005,0.11520000000000152],[0.9504000000000001,0.4031999999999982,1.9008000000000002,0.6047999999999973,2.8224,0.6047999999999973],[2.332799999999999,0,4.521599999999999,-1.1807999999999907,5.846399999999999,-3.2256],[0.7487999999999992,-1.152000000000001,1.152000000000001,-2.505600000000001,1.152000000000001,-3.8592000000000013],[0,-0.5183999999999997,-0.08640000000000114,-1.0367999999999995,-0.2015999999999991,-1.612799999999993],[0,-0.05760000000000787,-0.08640000000000114,-0.5183999999999997,-0.20160000000000266,-0.9504000000000019],[-0.6335999999999977,-3.1103999999999985,-1.0079999999999991,-4.924800000000005,-1.0079999999999991,-4.924800000000005],[0,0,0,0,0,0],[-0.05760000000000076,0,-0.17279999999999873,0,-0.2591999999999999,0.05760000000000787],[-0.28800000000000025,0.057599999999993656,-0.8928000000000011,0.2015999999999991,-1.152000000000001,0.23040000000000305],[-0.6335999999999977,0.08639999999999759,-1.2383999999999986,0.11519999999998731,-1.8143999999999991,0.11519999999998731],[-5.6448,0,-10.886399999999998,-3.8015999999999934,-12.7008,-9.417599999999993],[-0.4607999999999999,-1.4976000000000056,-0.7200000000000006,-2.995199999999997,-0.7200000000000006,-4.492800000000003],[0,-2.995199999999997,0.9504000000000001,-5.9328,2.7936000000000005,-8.553599999999995],[2.015999999999999,-2.8512000000000057,4.031999999999999,-5.299199999999999,6.5088,-7.833600000000004],[0.8640000000000008,-0.8928000000000011],[-0.2016000000000009,-1.0655999999999963],[-0.3743999999999996,-1.7567999999999983],[-0.48960000000000114,-2.2464000000000013],[-0.14399999999999835,-0.8352000000000004,-0.31679999999999886,-1.641600000000004,-0.34559999999999924,-1.8143999999999991],[-0.14400000000000013,-0.9504000000000019,-0.2303999999999995,-1.8719999999999998,-0.2303999999999995,-2.822400000000002],[0,-3.6287999999999982,1.1807999999999996,-7.113600000000002,3.3984000000000005,-9.9072],[0.6623999999999981,-0.8640000000000008,1.8431999999999995,-2.016000000000002,2.16,-2.1023999999999994]], 19.0544, 25.8288, [1,1], null);
pdf.lines([[-0.05760000000000076,0,-0.14399999999999835,0,-0.2303999999999995,0],[-1.1808000000000014,0,-2.7072000000000002,1.0944000000000002,-3.7439999999999997,2.7072000000000002],[-1.0655999999999998,1.5840000000000031,-1.6128,3.686399999999999,-1.6128,5.846400000000003],[0,0.5760000000000005,0.02880000000000038,1.1807999999999978,0.11519999999999975,1.7855999999999952],[0.08639999999999936,0.43200000000000216,0.11519999999999975,0.720000000000006,0.34559999999999924,1.7568000000000054],[0.4032000000000018,1.8143999999999991],[0.11519999999999797,0.5471999999999966,0.2015999999999991,0.9791999999999987,0.2015999999999991,1.0367999999999995],[0,0],[0.02880000000000038,0,0.9216000000000015,-0.9791999999999987,1.2095999999999982,-1.3248000000000033],[2.8800000000000025,-3.254399999999997,4.6080000000000005,-6.681599999999996,4.982400000000002,-9.705599999999997],[0.02880000000000038,-0.2880000000000038,0.02880000000000038,-0.5183999999999997,0.02880000000000038,-0.8064000000000036],[0,-0.892799999999994,-0.11520000000000152,-1.7567999999999983,-0.31680000000000063,-2.2175999999999973],[-0.2303999999999995,-0.460799999999999,-0.7487999999999992,-0.8352000000000004,-1.3824000000000005,-0.8928000000000011]], 20.8122, 31.5312, [1,1], null);
pdf.lines([[-0.05759999999999721,-0.4031999999999982,-0.14399999999999835,-0.7199999999999989,-0.14399999999999835,-0.7775999999999996],[0,0,0,0,-0.02880000000000038,0],[-0.05760000000000076,0,-1.2959999999999993,1.4400000000000048,-2.16,2.4480000000000004],[-1.4687999999999998,1.7856000000000023,-3.023999999999999,3.916800000000002,-3.6576000000000004,4.953600000000002],[-1.2096,2.044800000000002,-1.8143999999999991,4.32,-1.8143999999999991,6.5663999999999945],[0,1.4688000000000016,0.28800000000000025,2.8800000000000096,0.8064,4.23360000000001],[1.5551999999999992,4.0031999999999925,5.1264,6.508799999999994,9.0144,6.508799999999994],[0.460799999999999,0,0.9791999999999987,-0.028800000000003933,1.468799999999998,-0.11520000000000152],[0.6336000000000013,-0.11520000000000152,1.411200000000001,-0.34559999999999036,1.411200000000001,-0.43200000000000216],[0,0],[0,0,-0.05760000000000076,-0.2879999999999967,-0.14399999999999835,-0.6047999999999973],[-0.8352000000000004,-4.118399999999994],[-0.6624000000000016,-3.0816000000000087],[-0.4319999999999986,-2.1311999999999926],[-0.460799999999999,-2.073599999999999],[-0.23040000000000305,-1.2384000000000057,-0.31680000000000063,-1.5551999999999992,-0.31680000000000063,-1.5551999999999992],[0,0,0,-0.028800000000003933,-0.02880000000000038,-0.028800000000003933],[-0.17280000000000228,0,-1.0944000000000002,0.4608000000000061,-1.497600000000002,0.7488000000000028],[-1.4975999999999984,1.0367999999999995,-2.275199999999998,2.6783999999999963,-2.275199999999998,4.2912000000000035],[0,1.5263999999999953,0.7487999999999992,3.0527999999999906,2.1888000000000005,3.945599999999999],[0.31680000000000063,0.2015999999999991,0.4319999999999986,0.3743999999999943,0.4319999999999986,0.5759999999999934],[0,0.028800000000003933,0,0.11520000000000152,0,0.14400000000000546],[-0.05760000000000076,0.34559999999999036,-0.2591999999999999,0.4895999999999958,-0.5472000000000001,0.4895999999999958],[-0.11519999999999797,0,-0.2591999999999999,-0.028800000000003933,-0.4319999999999986,-0.11520000000000152],[-2.6496000000000013,-1.152000000000001,-4.4352,-3.887999999999991,-4.4352,-6.883200000000002],[0,0],[0,-3.455999999999996,2.1599999999999983,-6.451199999999993,5.4719999999999995,-7.631999999999998],[0.17279999999999873,-0.05760000000000076],[-0.28800000000000025,-1.4399999999999977],[-0.8064,-3.8592000000000013]], 16.4624, 53.7936, [1,1], null);
pdf.lines([[-0.2303999999999995,-0.028799999999996828,-0.460799999999999,-0.028799999999996828,-0.6335999999999977,-0.028799999999996828],[-0.05760000000000076,0,-0.1440000000000019,0,-0.20160000000000266,0],[-0.14399999999999835,0],[0.11519999999999797,0.5183999999999997],[0.6048000000000009,2.822400000000002],[0.3744000000000014,1.843199999999996],[0.4031999999999982,1.8144000000000062],[0.8064,4.0031999999999925],[0.31680000000000063,1.5264000000000095],[0.11520000000000152,0.4031999999999982,0.17280000000000228,0.7487999999999886,0.2015999999999991,0.7487999999999886],[0,0,0,0,0,0],[0.02880000000000038,0,0.5183999999999997,-0.2879999999999967,0.8352000000000004,-0.5183999999999997],[1.4688000000000016,-1.0367999999999995,2.563200000000002,-2.6495999999999924,2.9664,-4.319999999999993],[0.1440000000000019,-0.5472000000000037,0.2015999999999991,-1.123199999999997,0.2015999999999991,-1.6704000000000007],[0,-3.3408000000000015,-2.4767999999999972,-6.3648000000000024,-5.846399999999999,-6.739200000000004]], 20.8724, 63.4128, [1,1], "FD");
````
which produces:
![example](https://f.cloud.github.com/assets/857202/2362487/d81c6d9c-a63e-11e3-90e7-8908f6b408ec.png)

In comparison, without the patch, the following is output:
![without](https://f.cloud.github.com/assets/857202/2362546/ac7ec972-a63f-11e3-9610-4ca74b7110ba.png)