From 57160d276280e078aca3418a30d5256ffa145cc2 Mon Sep 17 00:00:00 2001 From: Andre Renaud Date: Wed, 1 Aug 2018 11:11:56 +1200 Subject: barcode: Scale via the PDF rather than the barcode library This allows arbitrary barcode scaling, rather than whole multiple as required by github.com/boombuler/barcode --- contrib/barcode/barcode.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'contrib/barcode') diff --git a/contrib/barcode/barcode.go b/contrib/barcode/barcode.go index 26f99c3..ad84fe5 100644 --- a/contrib/barcode/barcode.go +++ b/contrib/barcode/barcode.go @@ -71,16 +71,10 @@ func printBarcode(pdf barcodePdf, code string, x, y float64, w, h *float64, flow bname := uniqueBarcodeName(code, x, y) info := pdf.GetImageInfo(bname) + scaleToWidth := unscaled.Bounds().Dx() + scaleToHeight := unscaled.Bounds().Dy() if info == nil { - scaleToWidth := unscaled.Bounds().Dx() - scaleToHeight := unscaled.Bounds().Dy() - if w != nil { - scaleToWidth = int(convertTo96Dpi(pdf, *w)) - } - if h != nil { - scaleToHeight = int(convertTo96Dpi(pdf, *h)) - } bcode, err := barcode.Scale( unscaled, scaleToWidth, @@ -99,7 +93,13 @@ func printBarcode(pdf barcodePdf, code string, x, y float64, w, h *float64, flow } } - pdf.Image(bname, x, y, 0, 0, flow, "jpg", 0, "") + if w != nil { + scaleToWidth = int(*w) + } + if h != nil { + scaleToHeight = int(*h) + } + pdf.Image(bname, x, y, float64(scaleToWidth), float64(scaleToHeight), flow, "jpg", 0, "") } -- cgit v1.2.1-24-ge1ad