Comments (9)
Well, it is trying to turn that string into a set of PDF417 codewords for barcode generation. I'm not sure what you want the end result to be, but with that initialization I wouldn't expect a scan to return data.join].pack("H*")
.
Maybe you want to try using the raw_codewords
method? That would look like this:
barcode = PDF417.new
barcode.raw_codewords = data
Or maybe
barcode = PDF417.new(:raw_codewords => data)
If that doesn't do it then it means digging into C code to fix it but I think the assumption you ran into is that it is passed a text string to be encoded, and that's a string with some very special characters.
from pdf417.
Can you please explain how to convert hex data I'm trying to pass into element of raw_codewords
array?
Thanks!
from pdf417.
Not any better than I have above - to set raw_codewords
pass it an array of the raw codewords.
What happens when this barcode is scanned, a bunch of binary data comes back?
from pdf417.
I mean, How data in raw_codewords
is encoded?
For example
barcode = PDF417.new("test")
p barcode.codewords # [4, 829, 138, 599]
first element - length of array, what about other elements?
Yes, after scan binary data comes back.
from pdf417.
Okay, looking at https://github.com/asee/pdf417/blob/master/ext/pdf417/pdf417.c#L189 and https://en.wikipedia.org/wiki/PDF417#Codewords it looks like the codewords should be integers and represent the binary data that has been encoded in the PDF417 format.
This gem is a wrapper around a C library and looking at the method it uses to convert text to codewords it looks like it will occasionally try to use compact binary codeword substitutes, but that it expects text data - https://github.com/asee/pdf417/blob/master/ext/pdf417/pdf417lib.c#L520
from pdf417.
You need to fix your code. Problem: you setting ruby string to char array using StringValuePtr(text)
, but You don't set the right string size, RSTRING_LEN(text)
- will return the exact ruby string length. So, if you set p.lenText = (int)RSTRING_LEN(text);
there will be no problem :)
I've created a pull request to fix this, take a look.
from pdf417.
That is great, thank you very much! It makes a log of sense now that you point it out too...
from pdf417.
FYI, I bumped this up to 1.0.0, fixed some other errors that came up and released a new version of the gem
from pdf417.
👍
from pdf417.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pdf417.