boombuler / barcode Goto Github PK
View Code? Open in Web Editor NEWa barcode creation lib for golang
License: MIT License
a barcode creation lib for golang
License: MIT License
Would by really nice to have support for https://en.wikipedia.org/wiki/PDF417
Sorry my poor English.
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.
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 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)
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?
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?
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
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?
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]
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.
When the size is 200 px, there is no border, but when set to 210 px, there is another 10 px border.
It would be nice to have a white frame around the QR code for easier scanning as not all scanners can scan this code if placed on dark background.
Would you see any possibility MaxiCode barcodes could be included in the library in the (near) future ?
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
We want to reduce the left and right side margin of barcode inside the generated image. Please advice.
I want to use Sourcegraph for barcode code search, browsing, and usage examples. Can an admin enable Sourcegraph for this repository? Just go to https://sourcegraph.com/github.com/boombuler/barcode. (It should only take 30 seconds.)
Thank you!
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.
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 ?
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.
Surely, it is for 1D barcode.
I used Code128 to generate my barcode, and used Scale to have my expected size.
But is there a way place the content string under the barcode?
something like this, https://en.wikipedia.org/wiki/Barcode#/media/File:Code_128B-2009-06-02.svg
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.
With certain data strings this library produces malformed data matrix barcodes
Sample string to reproduce:
{"po":12,"batchAction":"start_end"}
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.
Inclusion of JABCode and HiQ color barcode creators, to adapt those repos (C and Java respectively) into Golang.
Would be nice to have support for Aztec Code too (https://en.wikipedia.org/wiki/Aztec_Code)
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.
Hey, could you set tag on master branch?
qrCode, _ := qr.Encode('http://www.aa.com?a=123', qr.M, qr.Auto)
Scan the QR code and open it with a browser. The request address becomes https://www.aa.com/?a=123
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
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)
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 :).
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)
How to set the background color to be transparent?
How do you set the size of the border?
cannot assign barcode.Barcode to img (type barcode.BarcodeIntCS) in multiple assignment:
barcode.Barcode does not implement barcode.BarcodeIntCS (missing CheckSum method)
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.
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
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
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
?
Hi @boombuler, Can you create a new release with current commits from master branch?
New commits was un-tagged in version 1.0.0 for a long time: v1.0.0...master
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.
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! :)
The same to title...
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.
Not the black and white qr codes that we have now
Does this library support resizing code128 barcodes? I didn't find any in GoDoc. Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.