Dev Center
Table of contents

Thanks for downloading Dynamsoft Barcode Reader Package!

Your download will start shortly. If your download does not begin, click here to retry.

How to Read Postal Codes

Which Types of Postal Codes are Supported

Dynamsoft Barcode Reader (DBR) supports the following types of postal codes. Details about each barcode type can be found on the list of supported barcode types page.

  • USPS Intelligent Mail
  • Postnet
  • Planet
  • Australian Post
  • Royal Mail 4-State Customer Barcode

Particular Parameter Required

DBR provides a parameter, BarcodeFormatIds, to control the formats of the barcode to process. To enable decoding the postal codes, simply set a BF_POSTALCODE or a specific postal code format enumeration to this parameter.

Sample Code

You can configure the parameter BarcodeFormatIds in two different ways, depending on your requirements. You can do it through SimplifiedCaptureVisionSettings, or if it suits your needs better, you can opt for JSON Template. Below are examples illustrating both of these configuration methods:

  • Configure barcode format via SimplifiedCaptureVisionSettings.
  • C++
  • Android
  • Objective-C
  • Swift
char szErrorMsg[256] = {0};
// Obtain current runtime settings of `CCaptureVisionRouter` instance.
CCaptureVisionRouter* cvr = new CCaptureVisionRouter;
SimplifiedCaptureVisionSettings settings;
cvr->GetSimplifiedSettings(CPresetTemplate::PT_READ_BARCODES, &settings);
// Enable all supported types of postal codes.
settings.barcodeSettings.barcodeFormatIds = BF_POSTALCODE;
// Update the settings.
cvr->UpdateSettings(CPresetTemplate::PT_READ_BARCODES, &settings, szErrorMsg, 256);
try {
   // Obtain current runtime settings. `cvr` is an instance of `CaptureVisionRouter`.
   // Here we use `EnumPresetTemplate.PT_READ_BARCODES` as an example. You can change it to your own template name or the name of other preset template.
   SimplifiedCaptureVisionSettings captureVisionSettings = cvr.getSimplifiedSettings(EnumPresetTemplate.PT_READ_BARCODES);
   captureVisionSettings.barcodeSettings.barcodeFormatIds = BF_POSTALCODE;
   // Update the settings. Remember to specify the same template name you used when getting the settings.
   cvr.updateSettings(EnumPresetTemplate.PT_READ_BARCODES, captureVisionSettings);
} catch (CaptureVisionRouterException e) {
   e.printStackTrace();
}
NSError *error;
// Obtain current runtime settings. `cvr` is an instance of `CaptureVisionRouter`.
// Here we use `EnumPresetTemplate.PT_READ_BARCODES` as an example. You can change it to your own template name or the name of other preset template.
DSSimplifiedCaptureVisionSettings *captureVisionSettings = [self.cvr getSimplifiedSettings:DSPresetTemplateReadBarcodes error:&error];
captureVisionSettings.barcodeSettings.barcodeFormatIds = DSBarcodeFormatPostalCode;
// Update the settings. Remember to specify the same template name you used when getting the settings.
[self.cvr updateSettings:DSPresetTemplateReadBarcodes settings:captureVisionSettings error:&error];
do{
   // Obtain current runtime settings. `cvr` is an instance of `CaptureVisionRouter`.
   // Here we use `EnumPresetTemplate.PT_READ_BARCODES` as an example. You can change it to your own template name or the name of other preset template.
   let captureVisionSettings = try cvr.getSimplifiedSettings(PresetTemplate.readBarcodes.rawValue)
   captureVisionSettings.barcodeSettings?.barcodeFormatIds = .postalCode
   // Update the settings. Remember to specify the same template name you used when getting the settings.
   try cvr.updateSettings(PresetTemplate.readBarcodes.rawValue, settings: captureVisionSettings)
}catch{
   // Add code to do when error occurs.
}
  • Configure barcode format via JSON parameter template file
    • update parameter BarcodeFormatIds in JSON template
       {
      "CaptureVisionTemplates": [
          {
              "Name" : "CV_0",
              "ImageROIProcessingNameArray": ["TA_0" ]
          }       
      ],
      "TargetROIDefOptions" : [
          {
              "Name" : "TA_0",
              "TaskSettingNameArray": [ "BR_0" ]
          }
      ],
      "BarcodeReaderTaskSettingOptions": [
          {
              "Name" : "BR_0",
              "BarcodeFormatIds" : ["BF_POSTALCODE"]
          }
      ]
       }
      
    • save the above template to file setting.json

    • apply settings by calling method InitSettingsFromFile
  • C++
  • Android
  • Objective-C
  • Swift
char szErrorMsg[256] = {0};
CCaptureVisionRouter* cvr = new CCaptureVisionRouter;
cvr->InitSettingsFromFile("PATH-TO-YOUR-SETTING-FILE", szErrorMsg, 256);
// more process here
try {
   // `cvr` is an instance of `CaptureVisionRouter`.
   cvr.initSettingsFromFile("PATH-TO-YOUR-SETTING-FILE");
} catch (CaptureVisionRouterException e) {
   e.printStackTrace();
}
NSError *error;
// `cvr` is an instance of `DSCaptureVisionRouter`.
[self.cvr initSettingsFromFile:@"PATH-TO-YOUR-SETTING-FILE" error:&error];
do{
   //`cvr` is an instance of `CaptureVisionRouter`.
   try cvr.initSettingsFromFile("PATH-TO-YOUR-SETTING-FILE")
}catch{
   // Add code to do when error occurs.
}

This page is compatible for:

Version 7.5.0

Is this page helpful?

YesYes NoNo

In this article:

latest version

  • Latest version
  • Version 10.x
    • Version 10.0.21
    • Version 10.0.20
    • Version 10.0.10
    • Version 10.0.0
  • Version 9.x
    • Version 9.6.33
    • Version 9.6.32
    • Version 9.6.31
    • Version 9.6.30
    • Version 9.6.20
    • Version 9.6.10
    • Version 9.6.0
    • Version 9.4.0
    • Version 9.2.0
    • Version 9.0.0
  • Version 8.x
    • Version 8.8.0
    • Version 8.6.0
    • Version 8.4.0
    • Version 8.2.0
    • Version 8.1.2
    • Version 8.1.0
    • Version 8.0.0
  • Version 7.x
    • Version 7.6.0
    • Version 7.5.0
Change +