Skip to content

Commit

Permalink
docs(readme): updates examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jshor authored Dec 16, 2019
1 parent 4c25dfd commit 8d7396e
Showing 1 changed file with 57 additions and 13 deletions.
70 changes: 57 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,70 @@ This Node.js module will allow you to generate over 50+ different types of 1D or
yarn add symbology
```

### Example usage
## Quick Examples

### Code 11 Example

```js
symbology
.createStream({
symbology: symbology.Barcode.CODE128
}, '8765432164')
.then((data) => {
console.log('Result: ', data)
})
```

This will log:

```json
{
"data": "data:image/png+data;base64,PHN [...] eFd==`
"message": "",
"code": 0
}
```

And the base64 PNG generated will look like:

![code 11](https://symbology.dev/assets/barcodes/barcode_14.png)

### MaxiCode Example

```js
const symbology = require('symbology')
symbology
.createFile({
symbology: Symbology.Barcode.MAXICODE,
option1: 2,
primary: '999999999840012',
fileName: 'maxiCodeExample.svg'
}, 'Secondary Message Here')
.then((data) => {
console.log('Result: ', data)
})
```

This creates `maxiCodeExample.svg` which looks like:

(async function () {
try {
await data = symbology.createStream({
symbology: symbology.Barcode.CODE128,
backgroundColor: 'ff00ff',
foregroundColor: '00ff00'
}, '12345')
![MaxiCode](https://symbology.dev/assets/barcodes/barcode_47.png)

### USPS Example

```js
symbology
.createFile({
symbology: Symbology.Barcode.ONECODE
fileName: 'uspsExample.eps'
}, '01234567094987654321-01234')
.then((data) => {
console.log('Result: ', data)
} catch (err) {
console.error('Error: ', err)
}
})()
})
```

This creates `uspsExample.eps` which looks like:

![USPS](https://symbology.dev/assets/barcodes/barcode_42.png)

## Documentation

[Read the comprehensive docs →](https://symbology.dev)
Expand Down

0 comments on commit 8d7396e

Please sign in to comment.