Skip to content

Library ​

sh
npm install barcode-grader
js
import { gradeFile, formatReport } from "barcode-grader";

const report = await gradeFile("label.pdf", { pages: [1], process: "flexo" });
for (const code of report.codes) {
  console.log(code.name, code.value, code.verdict, code.size?.magnification, code.grade?.letter);
  for (const issue of code.issues) console.log(` ${issue.rule}: ${issue.text}`);
}
console.log(formatReport(report, "label.pdf"));

gradeFile takes a path or the file's bytes.

Options ​

optionmeaning
pagespage numbers of a PDF to read
widthMma picture's printed width in mm, when the file has no resolution
dpia picture's resolution, overriding the file's
process"flexo", "offset", "gravure" or "digital"
hricompare the digits printed under EAN/UPC codes with what they encode (default true)

What a code carries ​

fieldcontent
name, format, value, textwhat it is and what it says
page, boxwhere it is; box is fractions of the page
verdict"ok", "check" or "fail"
issueseach with its rule, level and text
checkDigitwhether it is right, and what it should be
sizeX-dimension in mm, magnification, and GS1's range for the application
barHeightmeasured, and needed at this size
quietclear space each side in modules, and what the symbology needs
colourbar and space colours, symbol contrast in red light
gradeletter, value, the 2.8/06/660 notation, and the parameter that limited it
summaryone paragraph in plain words

Types ship with the package. The JSON form of a report is described by barcode-grader/schema/report.schema.json.

Judging alone ​

barcode-grader/rules exports gradeCodes, for callers with their own renderer and decoder.

MIT licensed. It predicts from the artwork; it is not a verifier.