implement a native EPS writer

This commit is contained in:
Michael Stapelberg
2020-11-14 11:12:02 +01:00
parent f39a23b8dc
commit 31bda30724
5 changed files with 162 additions and 4 deletions

View File

@@ -105,7 +105,8 @@ func logic() error {
format != "svg" &&
format != "txt" &&
format != "html" &&
format != "wv" {
format != "wv" &&
format != "eps" {
msg := fmt.Sprintf("format (%q) must be one of png, svg, txt or html", format)
log.Printf("%s %s", prefix, msg)
http.Error(w, msg, http.StatusBadRequest)
@@ -157,6 +158,18 @@ func logic() error {
w.Header().Add("Content-Type", "image/svg+xml")
case "eps":
var err error
b, err = bill.EncodeToEPS()
if err != nil {
log.Printf("%s %s", prefix, err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Header().Add("Content-Type", "image/eps")
w.Header().Add("Content-Disposition", `attachment; filename="qr.eps"`)
case "txt":
w.Header().Add("Content-Type", "text/plain; charset=utf-8")
spew.Fdump(w, qrch.Validate())