ylliX - Online Advertising Network
Vertex AI - Antrophic and Mistral models: Why does it require Imegen access?

Svg string to svg path string conversion


Is there a nodejs / javascrpt library which converts a svg string to a svg path string or string array?

By svg string (input) I mean something like this:

<svg xmlns="http://www.w3.org/2000/svg" width="207.34" height="252.22">
  <rect width="206.34" height="251.22" x="-103.17" y="-125.61" rx=".057" ry=".057" style="stroke:none;stroke-width:1;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:#fff;fill-rule:nonzero;opacity:1" transform="translate(58.702 108.562)scale(.4456)"/>
  <rect width="35" height="35" x="-17.5" y="-17.5" rx=".057" ry=".057" style="stroke:none;stroke-width:1;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:#004885;fill-rule:nonzero;opacity:1" transform="translate(22.755 151.736)scale(.4456)"/>
  <rect width="35" height="35" x="-17.5" y="-17.5" rx=".057" ry=".057" style="stroke:none;stroke-width:1;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:#004885;fill-rule:nonzero;opacity:1" transform="translate(89.595 151.736)scale(.4456)"/>
  <path d="M0 0h85L0 85zm185 0h-85l85 85z" style="stroke:none;stroke-width:1;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:#004885;fill-rule:nonzero;opacity:1" transform="translate(14.957 54.818)scale(.4456)"/>
  <path d="M95 90c6.48-.084 7.39 1.305 8 5v50h12c4.134-.367 8.418-.368 10-7V80c-.59-6.328-1.449-13.018-10-30-.65-1.093-.628-2.117 0-3l1-1v-7h-12.994l-.03 7.014L104 47c.645 1.102.741 1.808 0 3-5.1 8.096-8.19 18.36-10 30v9c.136.729.61.781 1 1" style="stroke:none;stroke-width:1;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:#0075bd;fill-rule:nonzero;opacity:1" transform="translate(14.957 54.818)scale(.4456)"/>
  <path d="M67 100v46c.824 3.332 4.702 5.281 6.945 5.011h16.083c2.127-.16 6.229-2.006 5.972-6.011v-45c-.001.002-2.978-5.013-2.969-5l-23.028.003c-.005.016-2.992 5.002-3.003 4.997" style="stroke:none;stroke-width:1;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:#0075bd;fill-rule:nonzero;opacity:1" transform="translate(14.957 54.818)scale(.4456)"/>
  <path d="M131 111v16.001l13.998.003c15.003.006 14.997 31.002.002 30.996H45v-18l-31 26 31 26v-17h100c14.991-.003 28.003-15 28-30 0-19.993-13-33.996-28-34z" style="stroke:none;stroke-width:1;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:#004885;fill-rule:nonzero;opacity:1" transform="translate(14.957 54.818)scale(.4456)"/>
</svg>

The result should be something like this:

var svgPath = "M23 M95 90c6.48-.084 7.39 1.305 8 5v50h12c4.13 ..."

The final goal is to draw it using pdf-lib drawSvgPath()



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *