Skip to content

pdf417: use at least 3 rows - #106

Open
wleeaf wants to merge 1 commit into
boombuler:masterfrom
wleeaf:pdf417-min-rows
Open

wleeaf wants to merge 1 commit into
boombuler:masterfrom
wleeaf:pdf417-min-rows

Conversation

@wleeaf

@wleeaf wleeaf commented Oct 25, 2026

Copy link
Copy Markdown

pdf417.Encode puts short data at a low security level into a symbol with only 2 rows, for example Encode("A", 0), Encode("A", 1) and Encode("Hell", 0). ISO/IEC 15438 allows 3 to 90 rows, and readers don't find 2-row symbols: zxing-cpp, ZXing (Java) and rxing all fail on them.

This raises minRows to 3. A message that would fit in fewer rows now gets the 3-row, 2-column fallback size, so getPadding pads to columns * rows codewords instead of to the next multiple of columns. For every size the search loop picks, the two amounts are the same, so other symbols don't change.

TestMinimumRows encodes short strings at security levels 0 to 2 and checks the row count. On master it fails for 7 of them, which come out with 2 rows. go test ./..., go vet ./... and golangci-lint run pass.

I also decoded 910 PDF417 symbols with zxing-cpp: digits, text and alphanumerics of lengths 1 to 300 at security levels 0, 2 and 5, plus a few special inputs. On master 6 of them are not found. With this change all of them decode to the input, and ZXing (Java) and rxing read all 910 as well.

Short data at a low security level was encoded in 2 rows, which
ISO/IEC 15438 does not allow (a symbol has 3 to 90 rows), so readers
could not find the symbol. Raise minRows to 3 and pad the codewords to
fill all rows of the chosen size.
@danielwhite
danielwhite self-requested a review October 26, 2026 11:04
@danielwhite

Copy link
Copy Markdown
Collaborator

@wleeaf, thanks for the report. This was on my radar, but was scheduled behind further regression testing to land this week in preparation for a v1.2.0 release.

I'll follow up once that's complete and take a closer look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants