Skip to content

stephen-last/srtps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SVG rects to path string (srtps)

Convert SVG rects to a single path string.

Motivation

I needed to generate PDF documents for printing onto labels media. Some of the labels need barcodes, and I wanted everything to be vector, no bitmaps. I decided to use PDF Kit which can use SVG path strings to draw vector shapes. So I needed a way to generate an SVG barcode and get an SVG path string to feed to .path().

API

import srtps from './dist/srtps'
const svg = `<svg><rect width='4' height='28' x='33.000' y='0' /></svg>`
const path = srtps.rectsToPath(svg)
console.log('path =', path)

Credits

  • Borrowed some maths from sstp

Test uses

  • Bardcode (Draw 1-D barcodes)
  • PDFKit (A JavaScript PDF generation library for Node and the browser)

About

SVG rects to path string.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published