Skip to content

A CLI tool & Go package for conversion of ZPL files.

License

Notifications You must be signed in to change notification settings

kamilturek/go-zpl

Repository files navigation

go-zpl

A CLI tool & Go package for conversion of ZPL files. A wrapper around Labelary ZPL Web Service.

Installation

CLI Tool

Using Go:

go install github.com/kamilturek/go-zpl/cmd/go-zpl@latest

Using Homebrew:

brew install kamilturek/tap/go-zpl

Go package

go get github.com/kamilturek/go-zpl

Usage

CLI Tool

go-zpl provides a help message describing all available options along with their default values.

$ go-zpl --help              
Usage of go-zpl:
  -d int
        input label density [dpmm] (default 8)
  -f string
        output file format (default "png")
  -h int
        input label height [inch] (default 6)
  -o string
        output file path
  -v    version for go-zpl
  -version
        version for go-zpl
  -w int
        input label width [inch] (default 4)

By default, go-zpl reads ZPL data from the standard input and writes result to the standard output.

$ cat hello.zpl | go-zpl -f pdf | head -n 1
%PDF-1.4

It is possible to read ZPL data from a file and write the result to another one.

$ go-zpl -f pdf -o hello.pdf hello.zpl
$ head -n 1 hello.pdf                   
%PDF-1.4

Go package

package main

import "github.com/kamilturek/go-zpl"

func main() {
      // Using convenience wrapper
      zpl.ToPNG(
            []byte("^xa^cfa,50^fo100,100^fdHello World^fs^xz"),
            // Optional extra configuration
            zpl.WithWidth(4),
            zpl.WithHeight(6),
            zpl.WithDensity(8),
      )

      // Or configuring the converter from scratch
      f, _ := os.Open("hello.zpl")
      zpl.Convert(
            zpl.WithInput(f),
            zpl.WithOutput(os.Stdout),
            zpl.WithOutputFormat(zpl.PNG),
            zpl.WithDensity(12),
      )
}

License

See LICENSE.

Contributing

Please create a GitHub issue for any feedback, bugs, requests or issues. PRs are also welcome.

Running tests

  • General tests

    go test
  • Integration tests

    go test -tags=integration