phpbarcodetcpdfchecksum

Is it possible to disable the automatic UPC checksum check in TCPDF?


I'm using TCPDF to generate a page of retail store bin tags. These tags include a 1D UPC barcode. The system has worked for years, save for one problem: manufacturers and/or distributors occasionally send out a UPC with the wrong checksum.

By the time the data gets to me, it's set in stone. My customer is a $1M/year retailer dealing with multiple $10B/year distributors. They'll never be able to wag that dog and they've been politely told the problem won't be fixed. Undoubtedly that number has become deeply embedded into who knows how many databases and reports.

And it causes TCPDF to error out when trying to generate a barcode. Yes, I can go find the correct checksum number, but that changes the 12-digit barcode, which is all that matters. I need to generate a scannable barcode regardless the final number.

Is there a way to disable the checksum check in TCPDF?

If not, is there a barcode type that's a UPC-style barcode that doesn't use a checksum check? I'm unfamiliar with most of the barcode types supported by TCPDF and the documentation doesn't even mention this check.


Solution

  • When printing an EAN/UPC barcode, TCPDF checks the checksum digit and throws an error if it is incorrect. There is no setting to disable that behavior, so you need to change the code. The most simple way is to comment out a line in the TCPDFBarcode::barcode_eanupc() method:

    } elseif ($r !== intval($code[$data_len])) {
                // wrong checkdigit
    //          return false;
            }