Viewing the data of a paper forms barcode

The Using a Paper Forms Barcode snippet demonstrates the capacity of a paper forms barcode. It also shows how data capacity changes when mixed case and special characters are included in the data.

In this example, entering a number of characters less than 255 and then clicking the Generate Data button changes the barcode data capacity. Also, deselecting the Use UpperCase Characters Only check box demonstrates how the data capacity of the barcode is reduced when mixed case is used.

To add script for the Number of Characters to Generate text box

form1.#subform[0].CharstoGen::validate - (JavaScript, client) 
// The maximum number of characters to generate is 255. 
if (this.rawValue > 255) 
{ 
    this.rawValue = 255; 
    false; 
}

To add script for the Use Uppercase Characters Only check box

form1.#subform[0].UpperCaseOnly::change - (JavaScript, client) 
if (this.rawValue == 1) 
{ 
    CharacterBase.value = " ABC DEF GHI JKL MNO PQR STU VWX YZ,"; 
} 
else 
{ 
    CharacterBase.value = " ABC DEF GHI JKL MNO PQR STU VWX YZa bcd efg hij klm nop qrs tuv wxy z01 234 567 890 <xml>,"; 
    xfa.host.messageBox("When data is encoded into a PDF417 barcode, all UPPER CASE data requires less space in a barcode.  When switching back and forth from upper case to lower case, special characters must be embedded into the barcode to let the decoder or scanner know that a case change has taken place.  As you will be able to see from the example, the data capacity of the barcode is reduced when mixed cases are used.", "Upper Case" ,3, 1); 
} 
 
if (CharstoGen.rawValue >= 255) 
    CharstoGen.rawValue = 255;

To add script to the Generate Data button

form1.#subform[0].Button1::click - (JavaScript, client) 
// Display random data in Paper Form barcode. 
var RandomLetters = ""; 
var sequence = ""; 
var FieldFillSize = 0; 
var nIndex = 0; 
 
RandomLetters = CharacterBase.value; 
FieldFillSize = CharstoGen.rawValue;         
 
for (var i = 1; i <= FieldFillSize; i++) 
{ 
    nIndex = Math.floor(Math.random() * RandomLetters.length); 
    sequence = sequence + RandomLetters.charAt(nIndex); 
} 
 
BarcodeData.rawValue = sequence;

To add script to the barcode

BarcodeData.rawValue = sequence; 
    form1.#subform[0].Barcode::calculate - (JavaScript, client) 
//{{Start Generated Content// 
var is705ViewerRequired = false; 
//End Generated Content}}// 
 
function createBarcodeContent() 
{ 
       // TODO: Encode your barcode content here 
       var barcodeContent = " "; 
       barcodeContent = BarcodeData.rawValue; 
       return barcodeContent; 
} 
 
// Assign content to the barcode.  
// Note: Do not assign a null value to 
// the barcode. Otherwise, the barcode is 
// displayed as blank. 
if(createBarcodeContent() != null) 
{ 
       this.rawValue = createBarcodeContent(); 
} 
else 
{ 
       this.rawValue = " "; 
} 
// Final sanity check, located here not for  
// efficiency but for consistency and correctness 
if (is705ViewerRequired && xfa.host.version < 7.05) 
{ 
       this.rawValue = " "; 
}

To see similar examples, visit the LiveCycle Developer Center.

// Ethnio survey code removed