diff --git a/bower.json b/bower.json index cd509a8d..8f5114f1 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "svg2pdf.js", "description": "A javascript-only SVG to PDF conversion utility that runs in the browser leveraging jsPDF", - "version": "1.0.0", + "version": "1.0.1", "main": "dist/svg2pdf.min.js", "authors": [{ "name": "yFiles for HTML Support Team", diff --git a/dist/svg2pdf.js b/dist/svg2pdf.js index 1cf83eb2..4b8d0f3b 100644 --- a/dist/svg2pdf.js +++ b/dist/svg2pdf.js @@ -1735,7 +1735,7 @@ function RGBColor(color_string) } if (typeof define === "function" && define.amd) { - define([],function () { + define(function () { return RGBColor; }); } else if (typeof module !== "undefined" && module.exports) { diff --git a/dist/svg2pdf.min.js b/dist/svg2pdf.min.js index e234347d..d6d80e19 100644 --- a/dist/svg2pdf.min.js +++ b/dist/svg2pdf.min.js @@ -1,2 +1,2 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.svg2pdf=t()}}(function(){var t;return function t(e,r,a){function i(s,o){if(!r[s]){if(!e[s]){var u="function"==typeof require&&require;if(!o&&u)return u(s,!0);if(n)return n(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var h=r[s]={exports:{}};e[s][0].call(h.exports,function(t){var r=e[s][1][t];return i(r?r:t)},h,h.exports,t,e,r,a)}return r[s].exports}for(var n="function"==typeof require&&require,s=0;s1&&(u=1),u<-1&&(u=-1),i*Math.acos(u)}function i(t,e,r,i,n,o,u,c,h,f){var l=f*(t-r)/2+h*(e-i)/2,d=-h*(t-r)/2+f*(e-i)/2,g=u*u,p=c*c,b=l*l,x=d*d,m=g*p-g*x-p*b;m<0&&(m=0),m/=g*x+p*b,m=Math.sqrt(m)*(n===o?-1:1);var v=m*u/c*d,y=m*-c/u*l,A=f*v-h*y+(t+r)/2,k=h*v+f*y+(e+i)/2,w=(l-v)/u,M=(d-y)/c,F=(-l-v)/u,C=(-d-y)/c,S=a(1,0,w,M),I=a(w,M,F,C);return 0===o&&I>0&&(I-=s),1===o&&I<0&&(I+=s),[A,k,S,I]}function n(t,e){var r=4/3*Math.tan(e/4),a=Math.cos(t),i=Math.sin(t),n=Math.cos(t+e),s=Math.sin(t+e);return[a,i,a-i*r,i+a*r,n+s*r,s-n*r,n,s]}var s=2*Math.PI;e.exports=function(t,e,r,a,o,u,c,h,f){var l=Math.sin(f*s/360),d=Math.cos(f*s/360),g=d*(t-r)/2+l*(e-a)/2,p=-l*(t-r)/2+d*(e-a)/2;if(0===g&&0===p)return[];if(0===c||0===h)return[];c=Math.abs(c),h=Math.abs(h);var b=g*g/(c*c)+p*p/(h*h);b>1&&(c*=Math.sqrt(b),h*=Math.sqrt(b));var x=i(t,e,r,a,o,u,c,h,l,d),m=[],v=x[2],y=x[3],A=Math.max(Math.ceil(Math.abs(y)/(s/4)),1);y/=A;for(var k=0;kMath.abs(f-o)?(f-s)/h:h/(f-o))/Math.PI,this.ax>=0?(this.rx=Math.sqrt(f),this.ry=Math.sqrt(l)):(this.ax+=90,this.rx=Math.sqrt(l),this.ry=Math.sqrt(f)),this},a.prototype.isDegenerate=function(){return this.rx=5760&&d.indexOf(t)>=0}function i(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:case 114:return!0}return!1}function n(t){return t>=48&&t<=57}function s(t){return t>=48&&t<=57||43===t||45===t||46===t}function o(t){this.index=0,this.path=t,this.max=t.length,this.result=[],this.param=0,this.err="",this.segmentStart=0,this.data=[]}function u(t){for(;t.index=i)return void(t.err="SvgPath: missed param (at pos "+a+")");if(e=t.path.charCodeAt(a),43!==e&&45!==e||(a++,e=a2&&(t.result.push([e,a[0],a[1]]),a=a.slice(2),r="l",e="m"===e?"l":"L"),"r"===r)t.result.push([e].concat(a));else for(;a.length>=l[r]&&(t.result.push([e].concat(a.splice(0,l[r]))),l[r]););}function f(t){var e,r,a,n,o=t.max;if(t.segmentStart=t.index,e=t.path.charCodeAt(t.index),!i(e))return void(t.err="SvgPath: bad command "+t.path[t.index]+" (at pos "+t.index+")");if(a=l[t.path[t.index].toLowerCase()],t.index++,u(t),t.data=[],!a)return void h(t);for(r=!1;;){for(n=a;n>0;n--){if(c(t),t.err.length)return;t.data.push(t.param),u(t),r=!1,t.index=t.max)break;if(!s(t.path.charCodeAt(t.index)))break}}h(t)}var l={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0},d=[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279];e.exports=function(t){var e=new o(t),r=e.max;for(u(e);e.index0,o=t.calc(a[1],a[2],f),c=["m",o[0],o[1]];break;default:for(h=a[0],c=[h],f=h.toLowerCase()===h,e=1;e=0;)t.matrix(this.__stack[e].toArray());this.__matrix(t),this.__stack=[]}},a.prototype.toString=function(){var t,e,r=[];this.__evaluateStack();for(var a=0;a0&&"m"!==e&&"M"!==e&&e===this.segments[a-1][0],r=r.concat(t?this.segments[a].slice(1):this.segments[a]);return r.join(" ").replace(/ ?([achlmqrstvz]) ?/gi,"$1").replace(/ \-/g,"-").replace(/zm/g,"z m")},a.prototype.translate=function(t,e){return this.__stack.push(s().translate(t,e||0)),this},a.prototype.scale=function(t,e){return this.__stack.push(s().scale(t,e||0===e?e:t)),this},a.prototype.rotate=function(t,e,r){return this.__stack.push(s().rotate(t,e||0,r||0)),this},a.prototype.skewX=function(t){return this.__stack.push(s().skewX(t)),this},a.prototype.skewY=function(t){return this.__stack.push(s().skewY(t)),this},a.prototype.matrix=function(t){return this.__stack.push(s().matrix(t)),this},a.prototype.transform=function(t){return t.trim()?(this.__stack.push(n(t)),this):this},a.prototype.round=function(t){var e,r=0,a=0,i=0,n=0;return t=t||0,this.__evaluateStack(),this.segments.forEach(function(s){var o=s[0].toLowerCase()===s[0];switch(s[0]){case"H":case"h":return o&&(s[1]+=i),i=s[1]-s[1].toFixed(t),void(s[1]=+s[1].toFixed(t));case"V":case"v":return o&&(s[1]+=n),n=s[1]-s[1].toFixed(t),void(s[1]=+s[1].toFixed(t));case"Z":case"z":return i=r,void(n=a);case"M":case"m":return o&&(s[1]+=i,s[2]+=n),i=s[1]-s[1].toFixed(t),n=s[2]-s[2].toFixed(t),r=i,a=n,s[1]=+s[1].toFixed(t),void(s[2]=+s[2].toFixed(t));case"A":case"a":return o&&(s[6]+=i,s[7]+=n),i=s[6]-s[6].toFixed(t),n=s[7]-s[7].toFixed(t),s[1]=+s[1].toFixed(t),s[2]=+s[2].toFixed(t),s[3]=+s[3].toFixed(t+2),s[6]=+s[6].toFixed(t),void(s[7]=+s[7].toFixed(t));default:return e=s.length,o&&(s[e-2]+=i,s[e-1]+=n),i=s[e-2]-s[e-2].toFixed(t),n=s[e-1]-s[e-1].toFixed(t),void s.forEach(function(e,r){r&&(s[r]=+s[r].toFixed(t))})}}),this},a.prototype.iterate=function(t,e){var r,a,i,n=this.segments,s={},o=!1,u=0,c=0,h=0,f=0;if(e||this.__evaluateStack(),n.forEach(function(e,r){var a=t(e,r,u,c);Array.isArray(a)&&(s[r]=a,o=!0);var i=e[0]===e[0].toLowerCase();switch(e[0]){case"m":case"M":return u=e[1]+(i?u:0),c=e[2]+(i?c:0),h=u,void(f=c);case"h":case"H":return void(u=e[1]+(i?u:0));case"v":case"V":return void(c=e[1]+(i?c:0));case"z":case"Z":return u=h,void(c=f);default:u=e[e.length-2]+(i?u:0),c=e[e.length-1]+(i?c:0)}}),!o)return this;for(i=[],r=0;r255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toHex=function(){var t=this.r.toString(16),e=this.g.toString(16),r=this.b.toString(16);return 1==t.length&&(t="0"+t),1==e.length&&(e="0"+e),1==r.length&&(r="0"+r),"#"+t+e+r},this.getHelpXML=function(){for(var t=new Array,r=0;r "+h.toRGB()+" -> "+h.toHex());c.appendChild(f),c.appendChild(l),u.appendChild(c)}catch(t){}return u}}return"function"==typeof t&&t.amd?t([],function(){return a}):"undefined"!=typeof r&&r.exports?r.exports=a:e.RGBColor=a,a}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this)},{}],9:[function(e,r,a){!function(a){function i(t,e){var r=f(t,"font-family");r&&o.setFont(r),e&&e.ok&&o.setTextColor(e.r,e.g,e.b);var a,i=f(t,"font-weight");i&&"bold"===i&&(a="bold");var n=f(t,"font-style");n&&"italic"===n&&(a+="italic"),o.setFontType(a);var s=16,u=f(t,"font-size");u&&(s=parseFloat(u),o.setFontSize(s))}var n,s,o,u=2/3,c=/url\(#([^)]+)\)/,h=function(t){var e=t.pathSegList;if(e)return e;e=[];var r=t.getAttribute("d");s&&(r=s(r).unshort().unarc().abs().toString());for(var a,i=/([a-df-zA-DF-Z])([^a-df-zA-DF-Z]*)/g;a=i.exec(r);){var n=F(a[2]),o=a[1],u="zZ".indexOf(o)>=0?0:"hHvV".indexOf(o)>=0?1:"mMlLtT".indexOf(o)>=0?2:"sSqQ".indexOf(o)>=0?4:"aA".indexOf(o)>=0?7:"cC".indexOf(o)>=0?6:-1,c=0;do{var h={pathSegTypeAsLetter:o};switch(o){case"h":case"H":h.x=n[c];break;case"v":case"V":h.y=n[c];break;case"c":case"C":h.x1=n[c+u-6],h.y1=n[c+u-5];case"s":case"S":h.x2=n[c+u-4],h.y2=n[c+u-3];case"t":case"T":case"l":case"L":case"m":case"M":h.x=n[c+u-2],h.y=n[c+u-1];break;case"q":case"Q":h.x1=n[c],h.y1=n[c+1],h.x=n[c+2],h.y=n[c+3];break;case"a":case"A":throw new Error("Cannot convert Arcs without SvgPath package")}e.push(h),c+=u}while(c=0},d=function(t,e){for(var r=[],a=0;a0&&("C"===s.pathSegTypeAsLetter||"S"===s.pathSegTypeAsLetter)?p([s.x2,s.y2],e):t>0&&("c"===s.pathSegTypeAsLetter||"s"===s.pathSegTypeAsLetter)?p([s.x2+a,s.y2+i],e):[e[0],e[1]]},m=function(t){this.prefix=t,this.id=0,this.nextChild=function(){return new m("_"+this.id++ +"_"+this.get())},this.get=function(){return this.prefix}},v=function(t,e){for(var r=/_\d+_/;!e[t]&&r.exec(t);)t=t.replace(r,"");return e[t]},y=function(t){return t.replace(/[\n\s\r]+/," ").trim()},A=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e},k=function(t){var e,r,a,i,n,s,u,c,h=o.unitMatrix;if(l(t,"svg,g"))c=parseFloat(t.getAttribute("x"))||0,u=parseFloat(t.getAttribute("y"))||0,s=t.getAttribute("viewBox"),s?(n=F(s),i=n[2]-n[0],a=n[3]-n[1],r=parseFloat(t.getAttribute("width"))||i,e=parseFloat(t.getAttribute("height"))||a,h=new o.Matrix(r/i,0,0,e/a,c-n[0],u-n[1])):h=new o.Matrix(1,0,0,1,c,u);else if(l(t,"marker"))if(c=-parseFloat(t.getAttribute("refX"))||0,u=-parseFloat(t.getAttribute("refY"))||0,s=t.getAttribute("viewBox")){n=F(s),i=n[2]-n[0],a=n[3]-n[1],r=parseFloat(t.getAttribute("markerWidth"))||i,e=parseFloat(t.getAttribute("markerHeight"))||a;var f=new o.Matrix(r/i,0,0,e/a,0,0),d=new o.Matrix(1,0,0,1,c,u);h=o.matrixMult(d,f)}else h=new o.Matrix(1,0,0,1,c,u);var g=t.getAttribute("transform");return g?o.matrixMult(h,M(g)):h},w=function(t){for(var e=F(t),r=[],a=0;a0;){var h=r.exec(t);if(h&&(e=F(h[1]),c=o.matrixMult(new o.Matrix(e[0],e[1],e[2],e[3],e[4],e[5]),c),t=t.substr(h[0].length)),h=i.exec(t)){e=F(h[1]);var f=Math.PI*e[0]/180;if(c=o.matrixMult(new o.Matrix(Math.cos(f),Math.sin(f),-Math.sin(f),Math.cos(f),0,0),c),e[1]&&e[2]){var l=new o.Matrix(1,0,0,1,e[1],e[2]),d=new o.Matrix(1,0,0,1,-e[1],-e[2]);c=o.matrixMult(d,o.matrixMult(c,l))}t=t.substr(h[0].length)}h=a.exec(t),h&&(e=F(h[1]),c=o.matrixMult(new o.Matrix(1,0,0,1,e[0],e[1]||0),c),t=t.substr(h[0].length)),h=n.exec(t),h&&(e=F(h[1]),e[1]||(e[1]=e[0]),c=o.matrixMult(new o.Matrix(e[0],0,0,e[1],0,0),c),t=t.substr(h[0].length)),h=s.exec(t),h&&(e=parseFloat(h[1]),c=o.matrixMult(new o.Matrix(1,0,Math.tan(e),1,0,0),c),t=t.substr(h[0].length)),h=u.exec(t),h&&(e=parseFloat(h[1]),c=o.matrixMult(new o.Matrix(1,Math.tan(e),0,1,0,0),c),t=t.substr(h[0].length))}return c},F=function(t){for(var e,r=[],a=/[+-]?(?:(?:\d+\.?\d*)|(?:\d*\.?\d+))(?:[eE][+-]?\d+)?/g;e=a.exec(t);)r.push(parseFloat(e[0]));return r},C=function(t){var e=/\s*rgba\(((?:[^,\)]*,){3}[^,\)]*)\)\s*/.exec(t);if(e){var r=F(e[1]),a=new n("rgb("+r.slice(0,3).join(",")+")");return a.a=r[3],a}return new n(t)},S=function(t,e){var r=t[0],a=t[1];return[e.a*r+e.c*a+e.e,e.b*r+e.d*a+e.f]},I=function(t){var e,r,a,i,n,s,o,u,c=parseFloat;if(l(t,"polygon")){var g=w(t.getAttribute("points"));for(r=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY,e=0;e=0&&(v=_,y=T),"MLCSQT".indexOf(L)>=0?(_=q.x,T=q.y):"mlcsqt".indexOf(L)>=0?(_=q.x+_,T=q.y+T):"zZ".indexOf(L)<0&&(_=A,T=k),"CSQTcsqt".indexOf(L)>=0?(r=Math.min(r,_,M[0],C[0],S[0]),i=Math.max(i,_,M[0],C[0],S[0]),a=Math.min(a,T,M[1],C[1],S[1]),n=Math.max(n,T,M[1],C[1],S[1])):(r=Math.min(r,_),i=Math.max(i,_),a=Math.min(a,T),n=Math.max(n,T))}u=[r,a,i-r,n-a]}else{if(l(t,"svg"))return s=t.getAttribute("viewBox"),s&&(o=F(s)),[c(t.getAttribute("x"))||o&&o[0]||0,c(t.getAttribute("y"))||o&&o[1]||0,c(t.getAttribute("width"))||o&&o[2]||0,c(t.getAttribute("height"))||o&&o[3]||0];if(l(t,"g"))u=[0,0,0,0],d(t,function(t,e){var r=I(e);u=[Math.min(u[0],r[0]),Math.min(u[1],r[1]),Math.max(u[0]+u[2],r[0]+r[2])-Math.min(u[0],r[0]),Math.max(u[1]+u[3],r[1]+r[3])-Math.min(u[1],r[1])]});else{if(l(t,"marker"))return s=t.getAttribute("viewBox"),s&&(o=F(s)),[o&&o[0]||0,o&&o[1]||0,o&&o[2]||c(t.getAttribute("marker-width"))||0,o&&o[3]||c(t.getAttribute("marker-height"))||0];if(l(t,"pattern"))return[c(t.getAttribute("x"))||0,c(t.getAttribute("y"))||0,c(t.getAttribute("width"))||0,c(t.getAttribute("height"))||0];var N=c(t.getAttribute("x1"))||c(t.getAttribute("x"))||c(t.getAttribute("cx")-c(t.getAttribute("r")))||0,O=c(t.getAttribute("x2"))||N+c(t.getAttribute("width"))||c(t.getAttribute("cx"))+c(t.getAttribute("r"))||0,P=c(t.getAttribute("y1"))||c(t.getAttribute("y"))||c(t.getAttribute("cy"))-c(t.getAttribute("r"))||0,E=c(t.getAttribute("y2"))||P+c(t.getAttribute("height"))||c(t.getAttribute("cy"))+c(t.getAttribute("r"))||0;u=[Math.min(N,O),Math.min(P,E),Math.max(N,O)-Math.min(N,O),Math.max(P,E)-Math.min(P,E)]}}if(!l(t,"marker,svg,g")){var G=f(t,"stroke-width")||1,j=f(t,"stroke-miterlimit");return j&&(G*=.5/Math.sin(Math.PI/12)),[u[0]-G,u[1]-G,u[2]+2*G,u[3]+2*G]}return u},_=function(t,e,r,a,i){for(var n=w(t.getAttribute("points")),s=[{op:"m",c:S(n[0],e)}],u=1;u=0),N=u&&(_===s.numberOfItems-1||"mM".indexOf(q)<0&&"mM".indexOf(s.getItem(_+1).pathSegTypeAsLetter)>=0),O=l&&_>0&&!(1===_&&"mM".indexOf(s.getItem(_-1).pathSegTypeAsLetter)>=0);if("sScCqQtT".indexOf(q)>=0)L&&I(g([y,A],d),[y,A],"start"),N&&I(g(p,c),c,"end"),O&&(v=g([y,A],d),v="mM".indexOf(s.getItem(_-1).pathSegTypeAsLetter)>=0?v:.5*(C+v),I(v,[y,A],"mid")),C=g(p,c),r=y,a=A,d=S(d,e),p=S(p,e),h=S(c,e),M.push({op:"c",c:[d[0],d[1],p[0],p[1],h[0],h[1]]});else if("lLhHvVmM".indexOf(q)>=0){if(v=g([y,A],c),L&&I(v,[y,A],"start"),N&&I(v,c,"end"),O){var P="mM".indexOf(q)>=0?C:"mM".indexOf(s.getItem(_-1).pathSegTypeAsLetter)>=0?v:.5*(C+v);I(P,[y,A],"mid")}C=v,h=S(c,e),M.push({op:m,c:h})}"MLCSQT".indexOf(q)>=0?(y=T.x,A=T.y):"mlcsqt".indexOf(q)>=0?(y=T.x+y,A=T.y+A):"zZ".indexOf(q)<0&&(y=i,A=n)}return{lines:M,markers:F}},p=d(s,e);if(u||f||l)for(var m=0;m0&&o.path(p.lines,a,i,n)},L=function(t,e,r){var a=t.getAttribute("href")||t.getAttribute("xlink:href");if(a){var i=o.getFormObject(r.get()+a.substring(1)),n=t.getAttribute("x")||0,s=t.getAttribute("y")||0,u=t.getAttribute("width")||i.width,c=t.getAttribute("height")||i.height,h=new o.Matrix(u/i.width||0,0,0,c/i.height||0,n,s);h=o.matrixMult(h,e),o.doFormObject(r.get()+a.substring(1),h)}},N=function(t,e){var r=S([parseFloat(t.getAttribute("x1")),parseFloat(t.getAttribute("y1"))],e),a=S([parseFloat(t.getAttribute("x2")),parseFloat(t.getAttribute("y2"))],e);o.line(r[0],r[1],a[0],a[1])},O=function(t,e,r,a){o.roundedRect(parseFloat(t.getAttribute("x"))||0,parseFloat(t.getAttribute("y"))||0,parseFloat(t.getAttribute("width")),parseFloat(t.getAttribute("height")),parseFloat(t.getAttribute("rx"))||0,parseFloat(t.getAttribute("ry"))||0,e,r,a)},P=function(t,e,r,a){o.ellipse(parseFloat(t.getAttribute("cx"))||0,parseFloat(t.getAttribute("cy"))||0,parseFloat(t.getAttribute("rx")),parseFloat(t.getAttribute("ry")),e,r,a)},E=function(t,e,r,a){var i=parseFloat(t.getAttribute("r"))||0;o.ellipse(parseFloat(t.getAttribute("cx"))||0,parseFloat(t.getAttribute("cy"))||0,i,i,e,r,a)},G=function(t,e){var r=f(t,"text-transform");switch(r){case"uppercase":return e.toUpperCase();case"lowercase":return e.toLowerCase();default:return e}},j=function(t,e,r,a){o.saveGraphicsState(),i(t,a);var s=function(t,e){var r=0;switch(t){case"end":r=e;break;case"middle":r=e/2;break;case"start":}return r},u=function(t,e){var r;return(r=t&&t.toString().match(/^([\-0-9.]+)em$/))?parseFloat(r[1])*e:(r=t&&t.toString().match(/^([\-0-9.]+)(px|)$/),r?parseFloat(r[1]):0)},c=document.createElementNS("http://www.w3.org/2000/svg","svg");c.appendChild(t),c.setAttribute("visibility","hidden"),document.body.appendChild(c);var h,l,g=t.getBBox(),p=0,b=f(t,"text-anchor");b&&(p=s(b,g.width));var x=o.getFontSize(),m=u(t.getAttribute("x"),x),v=u(t.getAttribute("y"),x),A=o.matrixMult(new o.Matrix(1,0,0,1,m,v),e);h=u(t.getAttribute("dx"),x),l=u(t.getAttribute("dy"),x),0===t.childElementCount?o.text(h-p,l,G(t,y(t.textContent)),void 0,A):d(t,function(e,r){o.saveGraphicsState();var a=f(r,"fill");i(r,a&&new n(a));var s=r.getExtentOfChar(0);o.text(s.x-m,s.y+.7*s.height-v,G(t,y(r.textContent)),void 0,A),o.restoreGraphicsState()}),document.body.removeChild(c),o.restoreGraphicsState()},V=function(t,e,r,a,i){d(t,function(t,n){"defs"===n.tagName.toLowerCase()&&(U(n,e,r,a,i),n.parentNode.removeChild(n))})},Y=function(t,e,r,a,i){var n=a.nextChild(),s=A(r);V(t,e,s,n,i),z(t,e,s,n,i)},z=function(t,e,r,a,i){d(t,function(t,n){U(n,e,r,a,i)})},H=function(t,e,r,a,i){var s,u=[],c=0,h=!1;d(t,function(t,e){if("stop"===e.tagName.toLowerCase()){var r=new n(f(e,"stop-color"));u.push({offset:parseFloat(e.getAttribute("offset")),color:[r.r,r.g,r.b]});var a=f(e,"stop-opacity");a&&1!=a&&(c+=parseFloat(a), +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.svg2pdf=t()}}(function(){var t;return function t(e,r,a){function i(s,o){if(!r[s]){if(!e[s]){var u="function"==typeof require&&require;if(!o&&u)return u(s,!0);if(n)return n(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var h=r[s]={exports:{}};e[s][0].call(h.exports,function(t){var r=e[s][1][t];return i(r?r:t)},h,h.exports,t,e,r,a)}return r[s].exports}for(var n="function"==typeof require&&require,s=0;s1&&(u=1),u<-1&&(u=-1),i*Math.acos(u)}function i(t,e,r,i,n,o,u,c,h,f){var l=f*(t-r)/2+h*(e-i)/2,d=-h*(t-r)/2+f*(e-i)/2,g=u*u,p=c*c,b=l*l,x=d*d,m=g*p-g*x-p*b;m<0&&(m=0),m/=g*x+p*b,m=Math.sqrt(m)*(n===o?-1:1);var v=m*u/c*d,y=m*-c/u*l,A=f*v-h*y+(t+r)/2,k=h*v+f*y+(e+i)/2,w=(l-v)/u,M=(d-y)/c,F=(-l-v)/u,C=(-d-y)/c,S=a(1,0,w,M),I=a(w,M,F,C);return 0===o&&I>0&&(I-=s),1===o&&I<0&&(I+=s),[A,k,S,I]}function n(t,e){var r=4/3*Math.tan(e/4),a=Math.cos(t),i=Math.sin(t),n=Math.cos(t+e),s=Math.sin(t+e);return[a,i,a-i*r,i+a*r,n+s*r,s-n*r,n,s]}var s=2*Math.PI;e.exports=function(t,e,r,a,o,u,c,h,f){var l=Math.sin(f*s/360),d=Math.cos(f*s/360),g=d*(t-r)/2+l*(e-a)/2,p=-l*(t-r)/2+d*(e-a)/2;if(0===g&&0===p)return[];if(0===c||0===h)return[];c=Math.abs(c),h=Math.abs(h);var b=g*g/(c*c)+p*p/(h*h);b>1&&(c*=Math.sqrt(b),h*=Math.sqrt(b));var x=i(t,e,r,a,o,u,c,h,l,d),m=[],v=x[2],y=x[3],A=Math.max(Math.ceil(Math.abs(y)/(s/4)),1);y/=A;for(var k=0;kMath.abs(f-o)?(f-s)/h:h/(f-o))/Math.PI,this.ax>=0?(this.rx=Math.sqrt(f),this.ry=Math.sqrt(l)):(this.ax+=90,this.rx=Math.sqrt(l),this.ry=Math.sqrt(f)),this},a.prototype.isDegenerate=function(){return this.rx=5760&&d.indexOf(t)>=0}function i(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:case 114:return!0}return!1}function n(t){return t>=48&&t<=57}function s(t){return t>=48&&t<=57||43===t||45===t||46===t}function o(t){this.index=0,this.path=t,this.max=t.length,this.result=[],this.param=0,this.err="",this.segmentStart=0,this.data=[]}function u(t){for(;t.index=i)return void(t.err="SvgPath: missed param (at pos "+a+")");if(e=t.path.charCodeAt(a),43!==e&&45!==e||(a++,e=a2&&(t.result.push([e,a[0],a[1]]),a=a.slice(2),r="l",e="m"===e?"l":"L"),"r"===r)t.result.push([e].concat(a));else for(;a.length>=l[r]&&(t.result.push([e].concat(a.splice(0,l[r]))),l[r]););}function f(t){var e,r,a,n,o=t.max;if(t.segmentStart=t.index,e=t.path.charCodeAt(t.index),!i(e))return void(t.err="SvgPath: bad command "+t.path[t.index]+" (at pos "+t.index+")");if(a=l[t.path[t.index].toLowerCase()],t.index++,u(t),t.data=[],!a)return void h(t);for(r=!1;;){for(n=a;n>0;n--){if(c(t),t.err.length)return;t.data.push(t.param),u(t),r=!1,t.index=t.max)break;if(!s(t.path.charCodeAt(t.index)))break}}h(t)}var l={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0},d=[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279];e.exports=function(t){var e=new o(t),r=e.max;for(u(e);e.index0,o=t.calc(a[1],a[2],f),c=["m",o[0],o[1]];break;default:for(h=a[0],c=[h],f=h.toLowerCase()===h,e=1;e=0;)t.matrix(this.__stack[e].toArray());this.__matrix(t),this.__stack=[]}},a.prototype.toString=function(){var t,e,r=[];this.__evaluateStack();for(var a=0;a0&&"m"!==e&&"M"!==e&&e===this.segments[a-1][0],r=r.concat(t?this.segments[a].slice(1):this.segments[a]);return r.join(" ").replace(/ ?([achlmqrstvz]) ?/gi,"$1").replace(/ \-/g,"-").replace(/zm/g,"z m")},a.prototype.translate=function(t,e){return this.__stack.push(s().translate(t,e||0)),this},a.prototype.scale=function(t,e){return this.__stack.push(s().scale(t,e||0===e?e:t)),this},a.prototype.rotate=function(t,e,r){return this.__stack.push(s().rotate(t,e||0,r||0)),this},a.prototype.skewX=function(t){return this.__stack.push(s().skewX(t)),this},a.prototype.skewY=function(t){return this.__stack.push(s().skewY(t)),this},a.prototype.matrix=function(t){return this.__stack.push(s().matrix(t)),this},a.prototype.transform=function(t){return t.trim()?(this.__stack.push(n(t)),this):this},a.prototype.round=function(t){var e,r=0,a=0,i=0,n=0;return t=t||0,this.__evaluateStack(),this.segments.forEach(function(s){var o=s[0].toLowerCase()===s[0];switch(s[0]){case"H":case"h":return o&&(s[1]+=i),i=s[1]-s[1].toFixed(t),void(s[1]=+s[1].toFixed(t));case"V":case"v":return o&&(s[1]+=n),n=s[1]-s[1].toFixed(t),void(s[1]=+s[1].toFixed(t));case"Z":case"z":return i=r,void(n=a);case"M":case"m":return o&&(s[1]+=i,s[2]+=n),i=s[1]-s[1].toFixed(t),n=s[2]-s[2].toFixed(t),r=i,a=n,s[1]=+s[1].toFixed(t),void(s[2]=+s[2].toFixed(t));case"A":case"a":return o&&(s[6]+=i,s[7]+=n),i=s[6]-s[6].toFixed(t),n=s[7]-s[7].toFixed(t),s[1]=+s[1].toFixed(t),s[2]=+s[2].toFixed(t),s[3]=+s[3].toFixed(t+2),s[6]=+s[6].toFixed(t),void(s[7]=+s[7].toFixed(t));default:return e=s.length,o&&(s[e-2]+=i,s[e-1]+=n),i=s[e-2]-s[e-2].toFixed(t),n=s[e-1]-s[e-1].toFixed(t),void s.forEach(function(e,r){r&&(s[r]=+s[r].toFixed(t))})}}),this},a.prototype.iterate=function(t,e){var r,a,i,n=this.segments,s={},o=!1,u=0,c=0,h=0,f=0;if(e||this.__evaluateStack(),n.forEach(function(e,r){var a=t(e,r,u,c);Array.isArray(a)&&(s[r]=a,o=!0);var i=e[0]===e[0].toLowerCase();switch(e[0]){case"m":case"M":return u=e[1]+(i?u:0),c=e[2]+(i?c:0),h=u,void(f=c);case"h":case"H":return void(u=e[1]+(i?u:0));case"v":case"V":return void(c=e[1]+(i?c:0));case"z":case"Z":return u=h,void(c=f);default:u=e[e.length-2]+(i?u:0),c=e[e.length-1]+(i?c:0)}}),!o)return this;for(i=[],r=0;r255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toHex=function(){var t=this.r.toString(16),e=this.g.toString(16),r=this.b.toString(16);return 1==t.length&&(t="0"+t),1==e.length&&(e="0"+e),1==r.length&&(r="0"+r),"#"+t+e+r},this.getHelpXML=function(){for(var t=new Array,r=0;r "+h.toRGB()+" -> "+h.toHex());c.appendChild(f),c.appendChild(l),u.appendChild(c)}catch(t){}return u}}return"function"==typeof t&&t.amd?t(function(){return a}):"undefined"!=typeof r&&r.exports?r.exports=a:e.RGBColor=a,a}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this)},{}],9:[function(e,r,a){!function(a){function i(t,e){var r=f(t,"font-family");r&&o.setFont(r),e&&e.ok&&o.setTextColor(e.r,e.g,e.b);var a,i=f(t,"font-weight");i&&"bold"===i&&(a="bold");var n=f(t,"font-style");n&&"italic"===n&&(a+="italic"),o.setFontType(a);var s=16,u=f(t,"font-size");u&&(s=parseFloat(u),o.setFontSize(s))}var n,s,o,u=2/3,c=/url\(#([^)]+)\)/,h=function(t){var e=t.pathSegList;if(e)return e;e=[];var r=t.getAttribute("d");s&&(r=s(r).unshort().unarc().abs().toString());for(var a,i=/([a-df-zA-DF-Z])([^a-df-zA-DF-Z]*)/g;a=i.exec(r);){var n=F(a[2]),o=a[1],u="zZ".indexOf(o)>=0?0:"hHvV".indexOf(o)>=0?1:"mMlLtT".indexOf(o)>=0?2:"sSqQ".indexOf(o)>=0?4:"aA".indexOf(o)>=0?7:"cC".indexOf(o)>=0?6:-1,c=0;do{var h={pathSegTypeAsLetter:o};switch(o){case"h":case"H":h.x=n[c];break;case"v":case"V":h.y=n[c];break;case"c":case"C":h.x1=n[c+u-6],h.y1=n[c+u-5];case"s":case"S":h.x2=n[c+u-4],h.y2=n[c+u-3];case"t":case"T":case"l":case"L":case"m":case"M":h.x=n[c+u-2],h.y=n[c+u-1];break;case"q":case"Q":h.x1=n[c],h.y1=n[c+1],h.x=n[c+2],h.y=n[c+3];break;case"a":case"A":throw new Error("Cannot convert Arcs without SvgPath package")}e.push(h),c+=u}while(c=0},d=function(t,e){for(var r=[],a=0;a0&&("C"===s.pathSegTypeAsLetter||"S"===s.pathSegTypeAsLetter)?p([s.x2,s.y2],e):t>0&&("c"===s.pathSegTypeAsLetter||"s"===s.pathSegTypeAsLetter)?p([s.x2+a,s.y2+i],e):[e[0],e[1]]},m=function(t){this.prefix=t,this.id=0,this.nextChild=function(){return new m("_"+this.id++ +"_"+this.get())},this.get=function(){return this.prefix}},v=function(t,e){for(var r=/_\d+_/;!e[t]&&r.exec(t);)t=t.replace(r,"");return e[t]},y=function(t){return t.replace(/[\n\s\r]+/," ").trim()},A=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e},k=function(t){var e,r,a,i,n,s,u,c,h=o.unitMatrix;if(l(t,"svg,g"))c=parseFloat(t.getAttribute("x"))||0,u=parseFloat(t.getAttribute("y"))||0,s=t.getAttribute("viewBox"),s?(n=F(s),i=n[2]-n[0],a=n[3]-n[1],r=parseFloat(t.getAttribute("width"))||i,e=parseFloat(t.getAttribute("height"))||a,h=new o.Matrix(r/i,0,0,e/a,c-n[0],u-n[1])):h=new o.Matrix(1,0,0,1,c,u);else if(l(t,"marker"))if(c=-parseFloat(t.getAttribute("refX"))||0,u=-parseFloat(t.getAttribute("refY"))||0,s=t.getAttribute("viewBox")){n=F(s),i=n[2]-n[0],a=n[3]-n[1],r=parseFloat(t.getAttribute("markerWidth"))||i,e=parseFloat(t.getAttribute("markerHeight"))||a;var f=new o.Matrix(r/i,0,0,e/a,0,0),d=new o.Matrix(1,0,0,1,c,u);h=o.matrixMult(d,f)}else h=new o.Matrix(1,0,0,1,c,u);var g=t.getAttribute("transform");return g?o.matrixMult(h,M(g)):h},w=function(t){for(var e=F(t),r=[],a=0;a0;){var h=r.exec(t);if(h&&(e=F(h[1]),c=o.matrixMult(new o.Matrix(e[0],e[1],e[2],e[3],e[4],e[5]),c),t=t.substr(h[0].length)),h=i.exec(t)){e=F(h[1]);var f=Math.PI*e[0]/180;if(c=o.matrixMult(new o.Matrix(Math.cos(f),Math.sin(f),-Math.sin(f),Math.cos(f),0,0),c),e[1]&&e[2]){var l=new o.Matrix(1,0,0,1,e[1],e[2]),d=new o.Matrix(1,0,0,1,-e[1],-e[2]);c=o.matrixMult(d,o.matrixMult(c,l))}t=t.substr(h[0].length)}h=a.exec(t),h&&(e=F(h[1]),c=o.matrixMult(new o.Matrix(1,0,0,1,e[0],e[1]||0),c),t=t.substr(h[0].length)),h=n.exec(t),h&&(e=F(h[1]),e[1]||(e[1]=e[0]),c=o.matrixMult(new o.Matrix(e[0],0,0,e[1],0,0),c),t=t.substr(h[0].length)),h=s.exec(t),h&&(e=parseFloat(h[1]),c=o.matrixMult(new o.Matrix(1,0,Math.tan(e),1,0,0),c),t=t.substr(h[0].length)),h=u.exec(t),h&&(e=parseFloat(h[1]),c=o.matrixMult(new o.Matrix(1,Math.tan(e),0,1,0,0),c),t=t.substr(h[0].length))}return c},F=function(t){for(var e,r=[],a=/[+-]?(?:(?:\d+\.?\d*)|(?:\d*\.?\d+))(?:[eE][+-]?\d+)?/g;e=a.exec(t);)r.push(parseFloat(e[0]));return r},C=function(t){var e=/\s*rgba\(((?:[^,\)]*,){3}[^,\)]*)\)\s*/.exec(t);if(e){var r=F(e[1]),a=new n("rgb("+r.slice(0,3).join(",")+")");return a.a=r[3],a}return new n(t)},S=function(t,e){var r=t[0],a=t[1];return[e.a*r+e.c*a+e.e,e.b*r+e.d*a+e.f]},I=function(t){var e,r,a,i,n,s,o,u,c=parseFloat;if(l(t,"polygon")){var g=w(t.getAttribute("points"));for(r=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY,e=0;e=0&&(v=_,y=T),"MLCSQT".indexOf(L)>=0?(_=q.x,T=q.y):"mlcsqt".indexOf(L)>=0?(_=q.x+_,T=q.y+T):"zZ".indexOf(L)<0&&(_=A,T=k),"CSQTcsqt".indexOf(L)>=0?(r=Math.min(r,_,M[0],C[0],S[0]),i=Math.max(i,_,M[0],C[0],S[0]),a=Math.min(a,T,M[1],C[1],S[1]),n=Math.max(n,T,M[1],C[1],S[1])):(r=Math.min(r,_),i=Math.max(i,_),a=Math.min(a,T),n=Math.max(n,T))}u=[r,a,i-r,n-a]}else{if(l(t,"svg"))return s=t.getAttribute("viewBox"),s&&(o=F(s)),[c(t.getAttribute("x"))||o&&o[0]||0,c(t.getAttribute("y"))||o&&o[1]||0,c(t.getAttribute("width"))||o&&o[2]||0,c(t.getAttribute("height"))||o&&o[3]||0];if(l(t,"g"))u=[0,0,0,0],d(t,function(t,e){var r=I(e);u=[Math.min(u[0],r[0]),Math.min(u[1],r[1]),Math.max(u[0]+u[2],r[0]+r[2])-Math.min(u[0],r[0]),Math.max(u[1]+u[3],r[1]+r[3])-Math.min(u[1],r[1])]});else{if(l(t,"marker"))return s=t.getAttribute("viewBox"),s&&(o=F(s)),[o&&o[0]||0,o&&o[1]||0,o&&o[2]||c(t.getAttribute("marker-width"))||0,o&&o[3]||c(t.getAttribute("marker-height"))||0];if(l(t,"pattern"))return[c(t.getAttribute("x"))||0,c(t.getAttribute("y"))||0,c(t.getAttribute("width"))||0,c(t.getAttribute("height"))||0];var N=c(t.getAttribute("x1"))||c(t.getAttribute("x"))||c(t.getAttribute("cx")-c(t.getAttribute("r")))||0,O=c(t.getAttribute("x2"))||N+c(t.getAttribute("width"))||c(t.getAttribute("cx"))+c(t.getAttribute("r"))||0,P=c(t.getAttribute("y1"))||c(t.getAttribute("y"))||c(t.getAttribute("cy"))-c(t.getAttribute("r"))||0,E=c(t.getAttribute("y2"))||P+c(t.getAttribute("height"))||c(t.getAttribute("cy"))+c(t.getAttribute("r"))||0;u=[Math.min(N,O),Math.min(P,E),Math.max(N,O)-Math.min(N,O),Math.max(P,E)-Math.min(P,E)]}}if(!l(t,"marker,svg,g")){var G=f(t,"stroke-width")||1,j=f(t,"stroke-miterlimit");return j&&(G*=.5/Math.sin(Math.PI/12)),[u[0]-G,u[1]-G,u[2]+2*G,u[3]+2*G]}return u},_=function(t,e,r,a,i){for(var n=w(t.getAttribute("points")),s=[{op:"m",c:S(n[0],e)}],u=1;u=0),N=u&&(_===s.numberOfItems-1||"mM".indexOf(q)<0&&"mM".indexOf(s.getItem(_+1).pathSegTypeAsLetter)>=0),O=l&&_>0&&!(1===_&&"mM".indexOf(s.getItem(_-1).pathSegTypeAsLetter)>=0);if("sScCqQtT".indexOf(q)>=0)L&&I(g([y,A],d),[y,A],"start"),N&&I(g(p,c),c,"end"),O&&(v=g([y,A],d),v="mM".indexOf(s.getItem(_-1).pathSegTypeAsLetter)>=0?v:.5*(C+v),I(v,[y,A],"mid")),C=g(p,c),r=y,a=A,d=S(d,e),p=S(p,e),h=S(c,e),M.push({op:"c",c:[d[0],d[1],p[0],p[1],h[0],h[1]]});else if("lLhHvVmM".indexOf(q)>=0){if(v=g([y,A],c),L&&I(v,[y,A],"start"),N&&I(v,c,"end"),O){var P="mM".indexOf(q)>=0?C:"mM".indexOf(s.getItem(_-1).pathSegTypeAsLetter)>=0?v:.5*(C+v);I(P,[y,A],"mid")}C=v,h=S(c,e),M.push({op:m,c:h})}"MLCSQT".indexOf(q)>=0?(y=T.x,A=T.y):"mlcsqt".indexOf(q)>=0?(y=T.x+y,A=T.y+A):"zZ".indexOf(q)<0&&(y=i,A=n)}return{lines:M,markers:F}},p=d(s,e);if(u||f||l)for(var m=0;m0&&o.path(p.lines,a,i,n)},L=function(t,e,r){var a=t.getAttribute("href")||t.getAttribute("xlink:href");if(a){var i=o.getFormObject(r.get()+a.substring(1)),n=t.getAttribute("x")||0,s=t.getAttribute("y")||0,u=t.getAttribute("width")||i.width,c=t.getAttribute("height")||i.height,h=new o.Matrix(u/i.width||0,0,0,c/i.height||0,n,s);h=o.matrixMult(h,e),o.doFormObject(r.get()+a.substring(1),h)}},N=function(t,e){var r=S([parseFloat(t.getAttribute("x1")),parseFloat(t.getAttribute("y1"))],e),a=S([parseFloat(t.getAttribute("x2")),parseFloat(t.getAttribute("y2"))],e);o.line(r[0],r[1],a[0],a[1])},O=function(t,e,r,a){o.roundedRect(parseFloat(t.getAttribute("x"))||0,parseFloat(t.getAttribute("y"))||0,parseFloat(t.getAttribute("width")),parseFloat(t.getAttribute("height")),parseFloat(t.getAttribute("rx"))||0,parseFloat(t.getAttribute("ry"))||0,e,r,a)},P=function(t,e,r,a){o.ellipse(parseFloat(t.getAttribute("cx"))||0,parseFloat(t.getAttribute("cy"))||0,parseFloat(t.getAttribute("rx")),parseFloat(t.getAttribute("ry")),e,r,a)},E=function(t,e,r,a){var i=parseFloat(t.getAttribute("r"))||0;o.ellipse(parseFloat(t.getAttribute("cx"))||0,parseFloat(t.getAttribute("cy"))||0,i,i,e,r,a)},G=function(t,e){var r=f(t,"text-transform");switch(r){case"uppercase":return e.toUpperCase();case"lowercase":return e.toLowerCase();default:return e}},j=function(t,e,r,a){o.saveGraphicsState(),i(t,a);var s=function(t,e){var r=0;switch(t){case"end":r=e;break;case"middle":r=e/2;break;case"start":}return r},u=function(t,e){var r;return(r=t&&t.toString().match(/^([\-0-9.]+)em$/))?parseFloat(r[1])*e:(r=t&&t.toString().match(/^([\-0-9.]+)(px|)$/),r?parseFloat(r[1]):0)},c=document.createElementNS("http://www.w3.org/2000/svg","svg");c.appendChild(t),c.setAttribute("visibility","hidden"),document.body.appendChild(c);var h,l,g=t.getBBox(),p=0,b=f(t,"text-anchor");b&&(p=s(b,g.width));var x=o.getFontSize(),m=u(t.getAttribute("x"),x),v=u(t.getAttribute("y"),x),A=o.matrixMult(new o.Matrix(1,0,0,1,m,v),e);h=u(t.getAttribute("dx"),x),l=u(t.getAttribute("dy"),x),0===t.childElementCount?o.text(h-p,l,G(t,y(t.textContent)),void 0,A):d(t,function(e,r){o.saveGraphicsState();var a=f(r,"fill");i(r,a&&new n(a));var s=r.getExtentOfChar(0);o.text(s.x-m,s.y+.7*s.height-v,G(t,y(r.textContent)),void 0,A),o.restoreGraphicsState()}),document.body.removeChild(c),o.restoreGraphicsState()},V=function(t,e,r,a,i){d(t,function(t,n){"defs"===n.tagName.toLowerCase()&&(U(n,e,r,a,i),n.parentNode.removeChild(n))})},Y=function(t,e,r,a,i){var n=a.nextChild(),s=A(r);V(t,e,s,n,i),z(t,e,s,n,i)},z=function(t,e,r,a,i){d(t,function(t,n){U(n,e,r,a,i)})},H=function(t,e,r,a,i){var s,u=[],c=0,h=!1;d(t,function(t,e){if("stop"===e.tagName.toLowerCase()){var r=new n(f(e,"stop-color"));u.push({offset:parseFloat(e.getAttribute("offset")),color:[r.r,r.g,r.b]});var a=f(e,"stop-opacity");a&&1!=a&&(c+=parseFloat(a), h=!0)}}),h&&(s=new o.GState({opacity:c/r.length}));var l=new o.ShadingPattern(e,r,u,s),g=i.get()+t.getAttribute("id");o.addShadingPattern(g,l),a[g]=t},B=function(t,e,r){var a=r.get()+t.getAttribute("id");e[a]=t;var i=I(t),n=new o.TilingPattern([i[0],i[1],i[0]+i[2],i[1]+i[3]],i[2],i[3],null,k(t));o.beginTilingPattern(n),z(t,o.unitMatrix,e,r,!1),o.endTilingPattern(a,n)},U=function(t,e,r,a,s){function u(){p=new n("rgb(0, 0, 0)"),g=!0,b="F"}var h,d,g=!1,p=null,b=null,x=null,m=null,y=s&&!l(t,"lineargradient,radialgradient,pattern");if(y?(h=k(t),d=I(t),o.beginFormObject(d[0],d[1],d[2],d[3],h),h=o.unitMatrix,s=!1):(h=o.matrixMult(k(t),e),o.saveGraphicsState()),l(t,"g,path,rect,text,ellipse,line,circle,polygon")){var A=f(t,"fill");if(A){var w=c.exec(A);if(w){x=a.get()+w[1];var S=v(x,r);if(S&&l(S,"lineargradient,radialgradient")){var G=h;if(!S.hasAttribute("gradientUnits")||"objectboundingbox"===S.getAttribute("gradientUnits").toLowerCase()){d||(d=I(t)),G=new o.Matrix(d[2],0,0,d[3],d[0],d[1]);var U=k(t);G=o.matrixMult(G,U)}var Q=M(S.getAttribute("gradientTransform"));m=o.matrixMult(Q,G)}else if(S&&l(S,"pattern")){var D,X,Z,R,$;m={};var W=o.unitMatrix;S.hasAttribute("patternUnits")&&"objectboundingbox"!==S.getAttribute("patternUnits").toLowerCase()||(d||(d=I(t)),W=new o.Matrix(1,0,0,1,d[0],d[1]),D=I(S),$=D[0]*d[0],X=D[1]*d[1],Z=D[2]*d[2],R=D[3]*d[3],m.boundingBox=[$,X,$+Z,X+R],m.xStep=Z,m.yStep=R);var J=o.unitMatrix;S.hasAttribute("patternContentUnits")&&"objectboundingbox"===S.getAttribute("patternContentUnits").toLowerCase()&&(d||(d=I(t)),J=new o.Matrix(d[2],0,0,d[3],0,0),D=m.boundingBox||I(S),$=D[0]/d[0],X=D[1]/d[1],Z=D[2]/d[2],R=D[3]/d[3],m.boundingBox=[$,X,$+Z,X+R],m.xStep=Z,m.yStep=R),m.matrix=o.matrixMult(o.matrixMult(J,W),h),b="F"}else x=S=null,u()}else p=C(A),p.ok?(g=!0,b="F"):b=null}else u();var K=1,tt=t.getAttribute("opacity")||t.getAttribute("fill-opacity");tt&&(K*=parseFloat(tt)),p&&"number"==typeof p.a&&(K*=p.a),o.setGState(new o.GState({opacity:K}))}if(l(t,"g,path,rect,ellipse,line,circle,polygon")){g&&o.setFillColor(p.r,p.g,p.b);var et=t.getAttribute("stroke");if(et){var rt;t.hasAttribute("stroke-width")&&(rt=Math.abs(parseFloat(t.getAttribute("stroke-width"))),o.setLineWidth(rt));var at=new n(et);at.ok&&(o.setDrawColor(at.r,at.g,at.b),0!==rt&&(b=(b||"")+"D")),t.hasAttribute("stroke-linecap")&&o.setLineCap(t.getAttribute("stroke-linecap")),t.hasAttribute("stroke-linejoin")&&o.setLineJoin(t.getAttribute("stroke-linejoin")),t.hasAttribute("stroke-dasharray")&&o.setLineDashPattern(F(t.getAttribute("stroke-dasharray")),parseInt(t.getAttribute("stroke-dashoffset"))||0),t.hasAttribute("stroke-miterlimit")&&o.setLineMiterLimit(parseFloat(t.getAttribute("stroke-miterlimit")))}}switch(i(t,p),t.tagName.toLowerCase()){case"svg":Y(t,h,r,a,s);break;case"g":V(t,h,r,a,s);case"a":case"marker":z(t,h,r,a,s);break;case"defs":z(t,h,r,a,!0);break;case"use":L(t,h,a);break;case"line":N(t,h);break;case"rect":o.setCurrentTransformationMatrix(h),O(t,b,x,m);break;case"ellipse":o.setCurrentTransformationMatrix(h),P(t,b,x,m);break;case"circle":o.setCurrentTransformationMatrix(h),E(t,b,x,m);break;case"text":j(t,h,g,p);break;case"path":q(t,h,a,b,x,m);break;case"polygon":_(t,h,b,x,m);break;case"image":o.setCurrentTransformationMatrix(h),T(t);break;case"lineargradient":H(t,"axial",[t.getAttribute("x1"),t.getAttribute("y1"),t.getAttribute("x2"),t.getAttribute("y2")],r,a);break;case"radialgradient":H(t,"radial",[t.getAttribute("fx")||t.getAttribute("cx"),t.getAttribute("fy")||t.getAttribute("cy"),0,t.getAttribute("cx")||0,t.getAttribute("cy")||0,t.getAttribute("r")||0],r,a);break;case"pattern":B(t,r,a)}y?o.endFormObject(a.get()+t.getAttribute("id")):o.restoreGraphicsState()},Q=function(t,e,r){o=e;var a=r.scale||1,i=r.xOffset||0,n=r.yOffset||0;return o.saveGraphicsState(),o.setCurrentTransformationMatrix(new o.Matrix(a,0,0,a,i,n)),U(t.cloneNode(!0),o.unitMatrix,{},new m(""),!1),o.restoreGraphicsState(),o};return"function"==typeof t&&t.amd?t(["./rgbcolor","./SvgPath"],function(t,e){return n=t,s=e,Q}):"undefined"!=typeof r&&r.exports?(n=e("./rgbcolor.js"),s=e("SvgPath"),r.exports=Q):(s=a.SvgPath,n=a.RGBColor,a.svg2pdf=Q,a.svgElementToPdf=Q),Q}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this)},{"./rgbcolor.js":8,SvgPath:1}]},{},[9])(9)}); \ No newline at end of file diff --git a/package.json b/package.json index 599ad751..fb0f7857 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svg2pdf.js", - "version": "1.0.0", + "version": "1.0.1", "description": "A javascript-only SVG to PDF conversion utility that runs in the browser leveraging jsPDF", "main": "src/svg2pdf.js", "files": [ diff --git a/src/svg2pdf.js b/src/svg2pdf.js index fbf39743..1efa5df2 100644 --- a/src/svg2pdf.js +++ b/src/svg2pdf.js @@ -40,6 +40,9 @@ SOFTWARE. var cToQ = 2 / 3; // ratio to convert quadratic bezier curves to cubic ones + var iriReference = /url\(#([^)]+)\)/; + + // pathSegList is marked deprecated in chrome, so parse the d attribute manually if necessary var getPathSegList = function (node) { var pathSegList = node.pathSegList; @@ -833,13 +836,13 @@ SOFTWARE. var markerElement; switch (marker.type) { case "start": - markerElement = svgIdPrefix.get() + /url\(#(\w+)\)/.exec(markerStart)[1]; + markerElement = svgIdPrefix.get() + iriReference.exec(markerStart)[1]; break; case "end": - markerElement = svgIdPrefix.get() + /url\(#(\w+)\)/.exec(markerEnd)[1]; + markerElement = svgIdPrefix.get() + iriReference.exec(markerEnd)[1]; break; case "mid": - markerElement = svgIdPrefix.get() + /url\(#(\w+)\)/.exec(markerMid)[1]; + markerElement = svgIdPrefix.get() + iriReference.exec(markerMid)[1]; break; } _pdf.doFormObject(markerElement, marker.tf); @@ -1192,7 +1195,7 @@ SOFTWARE. var fillColor = getAttribute(node, "fill"); if (fillColor) { - var url = /url\(#(\w+)\)/.exec(fillColor); + var url = iriReference.exec(fillColor); if (url) { // probably a gradient (or something unsupported) fillUrl = svgIdPrefix.get() + url[1];