Skip to content

goqrsvg is a Go package that contains an API to do QR Code to SVG conversions

License

Notifications You must be signed in to change notification settings

miurhawk/goqrsvg

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goqrsvg

goqrsvg is an API that makes QR Code to SVG conversions. this is forked from github.com/aaronarduino/goqrsvg added is the ability to set specific colors on the svg

To use:

import "github.com/miurhawk/goqrsvg"

Uses:

"github.com/ajstarks/svgo"
"github.com/boombuler/barcode/qr"

Example Usage:

package main

import (
  "log"
  "net/http"

  "github.com/aaronarduino/goqrsvg"
  "github.com/ajstarks/svgo"
  "github.com/boombuler/barcode/qr"
)

func main() {
  http.Handle("/", http.HandlerFunc(circle))
  err := http.ListenAndServe(":2003", nil)
  if err != nil {
    log.Fatal("ListenAndServe:", err)
  }
}

func circle(w http.ResponseWriter, req *http.Request) {
  w.Header().Set("Content-Type", "image/svg+xml")
  s := svg.New(w)

  // Create the barcode
  qrCode, _ := qr.Encode("Hello World", qr.M, qr.Auto)

  // Write QR code to SVG
  qs := goqrsvg.NewQrSVG(qrCode, 5)
  qs.StartQrSVG(s)
  qs.WriteQrSVG(s)

  s.End()
}

Documentation:

See GoDoc

About

goqrsvg is a Go package that contains an API to do QR Code to SVG conversions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%