GithubHelp home page GithubHelp logo

boombuler / barcode Goto Github PK

View Code? Open in Web Editor NEW
1.4K 41.0 162.0 158 KB

a barcode creation lib for golang

License: MIT License

Go 100.00%
barcode go qrcode-generator datamatrix aztec-code codabar code128 code39 code93 ean13

barcode's People

Contributors

aaronarduino avatar anders avatar bertabus avatar boombuler avatar bryant1410 avatar codelingobot avatar extemporalgenome avatar gitter-badger avatar huysentruitw avatar jackbot avatar logic avatar pmoneda avatar sbinet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

barcode's Issues

Code128

Hi,
i'm trying to use this code
`qrCode, _ := code128.Encode("test1002")

// create the output file
file, _ := os.Create("qrcode.png")
defer file.Close()

// encode the barcode as png
png.Encode(file, qrCode)`

but the code 128 generated is very small.
What do i wrong?
qrcode

Datamatrix ECC200 16x48 with variable module size

We have been using https://linux.die.net/man/1/dmtxwrite for a while but I'd like to use more this library.

I'm reading the code and fiddling around to implement a 16x48 datamatrix with a module size of 5 pixels but I have some questions related to a low knowledge of the datamatrix spec and I hoped to receive some feedback.

I'd like to keep this ticket open for future questions and feedbacks as I learn the library and try to implement my changes, hopefully for a successful PR in the future.

base64 png

Is there a way to directly encode the barcode to base64 ? Then I could output into pdf as img tag

Thank you for replying... but my question was unanswered

Thank you for replying... but which one is correct?

I am new to programming in Go... and could use a little help with this.... (thanks !)

		bytes := []byte("hello world")
		azCode, _ := aztec.Encode(bytes, aztec.DEFAULT_EC_PERCENT, aztec.DEFAULT_LAYERS)
		azCode, _ = barcode.Scale(azCode, 40, 100)

		retval := A or B 

              return retval

So how do I convert the barcode to a byte array?

( I don't need it in a PNG or other image type... I just need a byte string )

A

retval := []byte(azCode.Content())  // is this right????

or

B

retval := []byte(azCode)

// actually go has a problem with this:
// cannot convert azCode (variable of type barcode.Barcode) to []bytecompilerInvalidConversion

Originally posted by @MichaelLiss in #66 (comment)

[Question] Genrating an GS1-128 barcode

Hi!

We're using you library to generate barcodes and so far it been working geat.

However we've hit a road bump in generating a GS1-128 barcode (most likely we've missunderstood how the library works) when it comes to the hidden FNC1 character. Looking though the source it looks like you support this but it's a bit unclear to us how should generate this type of label.

Are we supposed to send in the FNC1 character manually?

Any way to get the checksum for code 128 barcodes?

I'm writing an application which generates barcodes for logistics labels and one of the requirements is that the checksum from code 128 subset C barcode is printed on the label. Is there any easy way to access that value using this library?

doubt about barcode pattern

Hi, I tried to use twoofive barcode and I had some issues when reading barcode at banking mobile app So, I found in the code the following part
capturar

And there is a diference in the width. So I tried to change the interleaved option width to 3 and after that the mobile banking app started to read barcode faster. Why there is a diference between two options?

Tests errors: runeint_test.go:7:3: Errorf format %d has arg string(IntToRune(0)) of wrong type string

The following errors are happening with Go 1.15 on Fedora Rawhide:

github.com/boombuler/barcode/utils
# github.com/boombuler/barcode/utils
./runeint_test.go:7:3: Errorf format %d has arg string(IntToRune(0)) of wrong type string
./runeint_test.go:16:3: Error call has possible formatting directive %d
./runeint_test.go:19:3: Error call has possible formatting directive %d
./runeint_test.go:22:3: Error call has possible formatting directive %d
FAIL	github.com/boombuler/barcode/utils [build failed]

Feature Request: Decode/Read Functionality

Would it be possible to add the decoding or reading functionality to the package? Going through the code, I couldn't find any. Unless the purpose is solely to create barcodes.

MaxiCode

Would you see any possibility MaxiCode barcodes could be included in the library in the (near) future ?

Error about Scale function

Hi
I got an error when resize barcode which is can not scale barcode to an image smaller than 244x1,I paste the code as blow
`
content:="hello code128"

barcodePic, err := code128.Encode(content)

if err != nil {

	return  err

}

codePic, err := barcode.Scale(barcodePic, 200, 30)

if err != nil {

	return  err

}

file, err := os.Create("sample.png")

if err != nil {

	return err

}

defer file.Close()

err = png.Encode(file, codePic)

if err != nil {

	return  err

}

`
Pls help to check it
Thanks a lot

Does not allow for specifying an encoding

This library is only capable of encoding UTF-8 strings. Many external systems that read barcodes require specific encoding such as ISO-8859-1 or Shift_JIS. This is especially true of legacy hardware.

The ability to specify the encoding of the string would make this library much more useful.

Printer and reader

This library looks just like what I need.

I am planning to integrate it with a USB based bar code reader. Has anyone tried this yet ?

Also reading via the camera on a phone.
I can give it a go and submit a sample but wanted to check first it will be accepted ?

barCode err 条形码生成错误

In file codabar/encoder.go. Encode (), it shoule be

if content == "!" || checkValid.ReplaceAllString(content, "!") == "!" {
		return nil, fmt.Errorf("can not encode \"%s\"", content)
	}

not

if content == "!" || checkValid.ReplaceAllString(content, "!") != "!" {
		return nil, fmt.Errorf("can not encode \"%s\"", content)
	}

or this packet can't gen barCode.
My English is poor, so sorry.

UUID

Hi, I am trying to use uuid for barcode but every online validator shows resulting image as invalid.
This generator produces valid uuid barcode according to this validator.

From what I've gathered it has most likely something to do with the FNC1 character but I have no idea what. I tried to prefix the uuid with it but no success.

Malformed Data Matrix generation

With certain data strings this library produces malformed data matrix barcodes

Sample string to reproduce:

{"po":12,"batchAction":"start_end"}

Does not allow encoding of binary data

All methods take a string as an input. While raw data could. be base64 encoded. There are applications where barcodes contain a byte array. To the extent that the barcode protocol permits it, it should be possible to have a method that takes a byte array as an input and encodes raw binary data.

EAN128 Barcode could be shorter (in case of GS1-128)

In case a GS1-128 bar code is generated (this is an EAN128), the bar code is encoded using Code B symbols. In this case however Code C can be used : the sequence is always FNC1 + even number of digits. Although the Code B encoding is technically correct, normally for GS1-128 Code C is used as this results in shorter bar codes.

I looked at the code, it appears function "shouldUseCTable" only checks digits, not FNC1. Ignoring FNC1 in this function appears to solve the issue, and generates shorter Code C bar codes.

Release?

Hey, could you set tag on master branch?

Supporting barcode text underneath code 128

Normally, code 128 barcodes have the barcode text underneath them.

barcode

Is there any plan to support this? If so, at a high level what is involved?

I may purpose a solution similar to scaledBarcode, but writtenBarcode, that places the encoded text below the barcode, but in the image.

Data race's

I found three data races while trying to use this component in a go-routine.
They seem to occur because of the unprotected access of maps.

WARNING: DATA RACE
Read at 0x00c0424302b0 by goroutine 23:
  github.com/boombuler/barcode/qr.(*errorCorrection).getPolynomial()
      d:/projects/go/src/github.com/boombuler/barcode/qr/errorcorrection.go:33 +0x474
  github.com/boombuler/barcode/qr.(*errorCorrection).calcECC()
      d:/projects/go/src/github.com/boombuler/barcode/qr/errorcorrection.go:37 +0x6c
  github.com/boombuler/barcode/qr.splitToBlocks()
      d:/projects/go/src/github.com/boombuler/barcode/qr/blocks.go:18 +0x346
  github.com/boombuler/barcode/qr.Encode()
      d:/projects/go/src/github.com/boombuler/barcode/qr/encoder.go:64 +0x106
WARNING: DATA RACE
Read at 0x00c0424302b0 by goroutine 23:
  github.com/boombuler/barcode/qr.(*errorCorrection).getPolynomial()
      d:/projects/go/src/github.com/boombuler/barcode/qr/errorcorrection.go:33 +0x474
  github.com/boombuler/barcode/qr.(*errorCorrection).calcECC()
      d:/projects/go/src/github.com/boombuler/barcode/qr/errorcorrection.go:37 +0x6c
  github.com/boombuler/barcode/qr.splitToBlocks()
      d:/projects/go/src/github.com/boombuler/barcode/qr/blocks.go:18 +0x346
  github.com/boombuler/barcode/qr.Encode()
      d:/projects/go/src/github.com/boombuler/barcode/qr/encoder.go:64 +0x106
WARNING: DATA RACE
Read at 0x00c04229ea00 by goroutine 25:
  github.com/boombuler/barcode/utils.(*GFPoly).MultByMonominal()
      d:/projects/go/src/github.com/boombuler/barcode/utils/gfpoly.go:48 +0xf3
  github.com/boombuler/barcode/utils.(*GFPoly).Divide()
      d:/projects/go/src/github.com/boombuler/barcode/utils/gfpoly.go:81 +0x438
  github.com/boombuler/barcode/qr.(*errorCorrection).calcECC()
      d:/projects/go/src/github.com/boombuler/barcode/qr/errorcorrection.go:41 +0xfa
  github.com/boombuler/barcode/qr.splitToBlocks()
      d:/projects/go/src/github.com/boombuler/barcode/qr/blocks.go:18 +0x346
  github.com/boombuler/barcode/qr.Encode()
      d:/projects/go/src/github.com/boombuler/barcode/qr/encoder.go:64 +0x106

Code 128A?

I need to encode the string FNC3+"$P\rI", but encoding \r (carriage return) requires code 128A. Further investigation reveals this library only supports 128B and 128C. Any chance you could add 128A as well?

(FNC3+"$P\rI" is a special code to begin/end programming Datalogic-brand barcode scanners)

AZTEC siez limitation ?

Hi,
I think i found a strange limitation in the AZTEC barcode. When there is more than 472 chars in the barcode, it is not readable in 33% error code mode :

...
cab2d := "lsdkfmlkfmlkmkmezlkfmlzkfkezfezmfkkljkljkljflmfkelmfklmfezlfkezlmfkzlmefkelfkezlmfezmlflemkflmfklzfelzkflmfkezlmfkezmlfkzefkemzlfkmlezkfmzelfkezmkfelzmfkelzmfkzelmfkezmlfkezlmkflemzfklmezfkelzmfkezmlkfezlfkelmzfkezlmfkezmfkezlmkflmezkfezlmfkezmlfkezmlfklmezkflemzfkzemlkflzmekflzemfkezlmkfezmlfkezlmfkezmlfkezflmkezmlfelmzkfelmzfkzekflemzfklmezfkflmezklmfkezlmfkezlmfkezlfkelzmfkelzmfkezmlfkezlmfkezlmfklzmefkmezlfklmezkflemzkfmlezkfmlezkfezflkzemflkzemlfkzelmfkmelzfkmlz"

keyAztec := barcode.RegisterAztec(pdf, cab2d, 33, 0)
barcode.Barcode(pdf, keyAztec, posX + 87.1, posY + 66.6, 28, 28, false)
...

=> the generated barcode is not readable.
=> if you delete one character and generate it again, it works again.

Please tell me if i made a mistake.

Thank you very much, excuse my poor english :).

QR encode broken for L correction level

Hi, I've catched encoding bug with QR encoded with L error correction level. Data read by scanner has one byte different from original. Data is in base64, and code.Content() returns correct value, so error must be somewhere in rendering.

I don't know QR algorithm internals well, and it could be possible that I simply have to increase error correction level, but I doubt it.

Here is an example code with real value from production:
http://play.golang.org/p/IWmXxzQzT3 (it will not work in playground, must be run locally)

QR: transparent

How to set the background color to be transparent?
How do you set the size of the border?

Datamatrix barcode size

Hi

I'm trying to create a datamatrix barcode that meets the following spec:

The Royal Mail 2D barcode is a Complex Mail Data Mark (CMDM) barcode. It has the
specified format of a Data Matrix type ECC200 code complying with the international
standard ISO/IEC 16022, version 2006. It must be produced as a type 12 barcode with
following key characteristics
• Barcode Size: 44 x 44 modules
• Module Size: 0.5mm - 0.7mm
• Physical Size: 22mm x 22mm - 30.8mm x 30.8mm
• Total Capacity (with C40 encoding): 213 characters

and it's working fine except that for a typical 204 character input string, it is generating a 52x52 or 48x48 barcode and not 44x44.

I'm way out of my depth here but suspect that the C40 encoding might be the problem.
Does this package support C40 encoding or am I barking up the wrong tree?

Any guidance would be much appreciated.

--
Ian.

Can the generated bar code be returned as a byte array?

Hi,

I have a requirement that the bar code be generated in memory and returned as a byte string.

Here is what I have... I don't know if "Content()" does what I think it does

		bytes := []byte("hello world")
		azCode, _ := aztec.Encode(bytes, aztec.DEFAULT_EC_PERCENT, aztec.DEFAULT_LAYERS)
		azCode, _ = barcode.Scale(azCode, 40, 100)
		retval := []byte(azCode.Content())

              return retval

Unreadable code128 image

I use this code to generate image

code, err := code128.EncodeWithoutChecksum("1234567890")
...
code, err = barcode.Scale(code, 180, 90)
...
err = png.Encode(w, code)

(some lines are skipped)
this is what I got in browser
image
image
and the lower image was generated with web online generator. As you can see there is difference starting from line 19, which makes my barcode incorrect. I tried two different mobile scanners, both of them easily scan lower image but cannot recognize upper one.

Do you have the same barcode for 1234567890?

144x144 datamatrix are not possible

When trying to create a datamatrix from a long text which would result in a 144x144 grid, the code crashes with an index out of range runtime error in
/barcode_master/src/github.com/boombuler/barcode/datamatrix/errorcorrection.go:69

As far as I can tell from the datamatrix specs, this type of grid has alternating block size and CWs.

Missing License

I'd like to use this package in a project of mine, but it's missing any license information. Can you please add some license information? Thanks! :)

How can we convert barcode to SVG image?

We are using this library to generate a code128 barcode image to display my order id in Jobticket, We are adding this image in HTML and then converting that HTML page into PDF to print it.

However the barcode image reads properly from image and HTML page through the mobile scanner and USB scanner both but when we convert the HTML Jobticket to PDF file, it does not scan unless we zoom it to high levels.

So We are planning if we can somehow generate SVG then it can not stretch or squash on the pdf file and can be read properly.

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.