From 8bb378ed25b3a5dffd757feec7bdd937bf9b114d Mon Sep 17 00:00:00 2001 From: hooper114 Date: Sun, 4 Jan 2009 22:39:38 +0000 Subject: [PATCH] Make Data Matrix retry if data doesn't fit in specified symbol size. --- backend/dmatrix.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/backend/dmatrix.c b/backend/dmatrix.c index 9665f772..fd00b1ba 100644 --- a/backend/dmatrix.c +++ b/backend/dmatrix.c @@ -1282,6 +1282,19 @@ int dmatrix(struct zint_symbol *symbol, unsigned char source[]) if(symbol->option_1 == 1) { /* ECC 200 */ error_number = iec16022ecc200(source, barcodelen, symbol); + if((error_number != 0) && (symbol->option_2 != 0)) { + if(strcmp(symbol->errtxt, "Cannot make barcode fit") == 0) { + /* Can't fit data in the symbol size specified - + use automatic symbol sizing instead */ + symbol->option_2 = 0; + error_number = iec16022ecc200(source, barcodelen, symbol); + if(error_number == 0) { + /* It worked! */ + strcpy(symbol->errtxt, "Cannot make barcode fit"); + error_number = WARN_INVALID_OPTION; + } + } + } } else { /* ECC 000 - 140 */ error_number = matrix89(symbol, source);