# srtps

> SVG rects to path string (srtps).

Latest version **1.0.0** (published 2016-09-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install srtps
pnpm add srtps
yarn add srtps
bun add srtps
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-09-05 |
| First published | 2016-09-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+16 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Stephen Last |
| Maintainers | stephenlast |

## Links

- npm: https://www.npmjs.com/package/srtps
- Repository: https://github.com/stephen-last/srtps
- Homepage: https://github.com/stephen-last/srtps#readme
- Issues: https://github.com/stephen-last/srtps/issues
- npm.io page: https://npm.io/package/srtps

## Dependencies (1)

- [xmldom](https://npm.io/package/xmldom.md) ^0.1.22

## Recent versions

- 1.0.0 (latest) — 2016-09-05
- 0.3.1 — 2016-09-02
- 0.3.0 — 2016-09-02
- 0.2.5 — 2016-09-01
- 0.2.4 — 2016-09-01
- 0.2.3 — 2016-09-01
- 0.2.2 — 2016-09-01
- 0.2.1 — 2016-09-01
- 0.2.0 — 2016-09-01
- 0.1.1 — 2016-09-01
- 0.1.0 — 2016-09-01

## README

# SVG rects to path string (srtps)

Convert SVG `rects` to a single path string.

[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
[![Version](https://img.shields.io/npm/v/srtps.svg)](https://www.npmjs.com/package/srtps)
[![Downloads](https://img.shields.io/npm/dt/srtps.svg)](https://www.npmjs.com/package/srtps)

## 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](http://pdfkit.org/docs/vector.html#svg_paths) 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 PDF Kit's `.path()` method.

Only one dependency: [xmldom](https://github.com/jindw/xmldom).

## Install

`npm install srtps`

## Usage

### Basic

```javascript
import srtps from 'srtps'

const svg = `<svg><rect width='4' height='28' x='10' y='10' /></svg>`
const path = srtps.rectsToPath(svg)

console.log(path) // M 10.000 10.000  L 14.000 10.000  L 14.000 38.000  L 10.000 38.000  Z
```

### With Bardcode & PDFKit

```javascript
import fs from 'fs'
import bardcode from 'bardcode'
import PDFKit from 'pdfkit'
import srtps from 'srtps'

const svg = bardcode.drawBarcode('svg', '12345', {})
const path = srtps.rectsToPath(svg)

const pdf = new PDFKit()
pdf.pipe(fs.createWriteStream('./barcodes.pdf'))
pdf.path(path).fill('#000')
pdf.end()
```

## Credits

- Borrowed some maths from [sstp](https://github.com/mailzwj/sstp) (hat tip!)

## Test uses

- [Bardcode](https://github.com/froatsnook/bardcode) (Draw 1-D barcodes)
- [PDFKit](https://github.com/devongovett/pdfkit) (A JavaScript PDF generation library for Node and the browser)

---
_Source: https://npm.io/package/srtps · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
