You can try it out here: ZPL to SVG Converter
The goal is to be able to convert from ZPL to SVG and possibly vice verse. The conversion speed is decently fast with under 10ms from current testing. There are still a lot of bugs and missing features.
- bwip-js for barcode rendering
- pako for Z64 graphic encoding
- canvas for graphic fields (only for Node.JS)
npm i bwip-js pako canvas
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bwip-js/4.5.1/bwip-js-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pako/2.1.0/pako.min.js"></script>
<script src="path_to/zpl2svg.js"></script>
const { zpl2svg } = require('path_to/zpl2svg.js')
const zpl_content = `
^XA
^CF0,32
^FO20,20^GB330,220,3^FS
^FO120,40^A0N,30,30^FDHello ZPL!^FS
^FO40,100^BY2^B3N,N,100,Y,N^FD1234567^FS
^XZ
`
const svg_content = zpl2svg(zpl_content, {
scale: 1,
width: 370,
height: 260
})
- ^XA
Start of label
- ^PR
Print rate (skipped)
- ^FX
Comment
- ^FS
End of field
- ^CF
Font selection
- ^FO/^F0
Field origin
- ^GB
Graphic box
- ^GD
Graphic diagonal line
- ^GC
Graphic circle
- ^GE
Graphic ellipse
- ^FR
Field reverse point
- ^FD
Field data
- ^BY
Barcode field default parameters
- ^B0/^BO
Aztec code (partially implemented)
- ^B1
Code 11
- ^B2
Interleaved 2 of 5
- ^B3
Code 39
- ^B4
Code 49
- ^B5
Planet code
- ^B7
PDF417
- ^B8
EAN8
- ^B9
UPCE
- ^BA
Code 93
- ^BB
Coda block
- ^BC
Code 128
- ^GF
Graphic field
- ^XZ
End of label