GithubHelp home page GithubHelp logo

kamilturek / go-zpl Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 1.0 35 KB

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

License: MIT License

Go 100.00%
zpl zpl-programming-language labelary cli converter go golang

go-zpl's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.