MaxiCodeCodetextMode3

MaxiCodeCodetextMode3

Class for encoding and decoding the text embedded in the MaxiCode code for modes 3.
This sample shows how to encode and decode MaxiCode codetext for mode 3.

Constructor

new MaxiCodeCodetextMode3()

Source:
Examples
//Mode 3 with standart second message
 let maxiCodeCodetext = new MaxiCodeCodetextMode3();
 maxiCodeCodetext.setPostalCode("B1050");
 maxiCodeCodetext.setCountryCode(056);
 maxiCodeCodetext.setServiceCategory(999);
 let maxiCodeStandartSecondMessage = new MaxiCodeStandartSecondMessage();
 maxiCodeStandartSecondMessage.setMessage("Test message");
 maxiCodeCodetext.setSecondMessage(maxiCodeStandartSecondMessage);
 let complexGenerator = new ComplexBarcodeGenerator(maxiCodeCodetext);
 complexGenerator.generateBarCodeImage(BarcodeImageFormat.PNG);

 
//Mode 3 with structured second message
 let maxiCodeCodetext = new MaxiCodeCodetextMode3();
 maxiCodeCodetext.setPostalCode("B1050");
 maxiCodeCodetext.setCountryCode(056);
 maxiCodeCodetext.setServiceCategory(999);
 let maxiCodeStructuredSecondMessage = new MaxiCodeStructuredSecondMessage();
 maxiCodeStructuredSecondMessage.add("634 ALPHA DRIVE");
 maxiCodeStructuredSecondMessage.add("PITTSBURGH");
 maxiCodeStructuredSecondMessage.add("PA");
 maxiCodeStructuredSecondMessage.setYear(99);
 maxiCodeCodetext.setSecondMessage(maxiCodeStructuredSecondMessage);
 let complexGenerator = new ComplexBarcodeGenerator(maxiCodeCodetext);
 complexGenerator.generateBarCodeImage(BarcodeImageFormat.PNG);

 
//Decoding raw codetext with standart second message
 let reader = new BarCodeReader("c:\\test.png", null, DecodeType.MAXI_CODE);
 reader.readBarCodes().forEach(function(result, i, results)
 {
     let resultMaxiCodeCodetext = ComplexCodetextReader.tryDecodeMaxiCode(result.getExtended().getMaxiCode().getMaxiCodeMode(), result.getCodeText());
     if (resultMaxiCodeCodetext instanceOf MaxiCodeCodetextMode3)
     {
         let maxiCodeStructuredCodetext = resultMaxiCodeCodetext;
         console.log("BarCode Type: " + maxiCodeStructuredCodetext.getPostalCode());
         console.log("MaxiCode mode: " + maxiCodeStructuredCodetext.getCountryCode());
         console.log("BarCode CodeText: " + maxiCodeStructuredCodetext.getServiceCategory());
         if (maxiCodeStructuredCodetext.getSecondMessage() instanceOf MaxiCodeStandartSecondMessage)
         {
             let secondMessage = maxiCodeStructuredCodetext.getSecondMessage();
             console.log("Message: " + secondMessage.getMessage());
         }
     }
 });

 
//Decoding raw codetext with structured second message
 let reader = new BarCodeReader("c:\\test.png", null, DecodeType.MAXI_CODE);
 reader.readBarCodes().forEach(function(result, i, results)
 {
     let resultMaxiCodeCodetext = ComplexCodetextReader.tryDecodeMaxiCode(result.getExtended().getMaxiCode().getMaxiCodeMode(), result.getCodeText());
     if (resultMaxiCodeCodetext instanceOf MaxiCodeCodetextMode3)
     {
         let maxiCodeStructuredCodetext = resultMaxiCodeCodetext;
         console.log("BarCode Type: " + maxiCodeStructuredCodetext.getPostalCode());
         console.log("MaxiCode mode: " + maxiCodeStructuredCodetext.getCountryCode());
         console.log("BarCode CodeText: " + maxiCodeStructuredCodetext.getServiceCategory());
         if (maxiCodeStructuredCodetext.getSecondMessage() instanceOf MaxiCodeStructuredSecondMessage)
         {
             let secondMessage = maxiCodeStructuredCodetext.getSecondMessage();
             console.log("Message:");
             secondMessage.getIdentifiers().forEach(identifier,i, identifiers){
                 console.log(identifier);
             });
         }
     }
 });

Methods

getMode()

Gets MaxiCode mode.
Returns:
Type Description
MaxiCode mode
Source: