1D Barcodes with Optional Exception Message in Case of Incorrect Text
The BarCodeBuilder.setThrowExceptionWhenCodeTextIncorrect method is only used for 1D barcodes. It allows developers to choose what happens if the barcode text used when generating a barcode is not valid. There are two choices:
- Filter out the input text and generate a barcode with allowed characters
- Throw an exception
If the barcode text is incorrect and the value for the ThrowExceptionWhenCodeTextIncorrect property is set to true, an exception is thrown. Otherwise, the barcode text is corrected to match the barcode specification, with the following exceptions:
- An exception is always thrown for the Databar symbology if the barcode text is incorrect.
- An exception is never thrown for AustraliaPost, SingapurePost, Code39Extended, Code93Extended, Code16K, Code128 symbologies, even if the barcode text is incorrect.
The code below shows how to use the method.