Avatar

Correct answer by
Level 10

Raja,

Here is a simple example of a custom barcode encoding of a PaperFormsBarcode using a pipe-delimiter.

p.png

The text field 'Barcode encoding' contains the value of the PaperFormsBarcode object. It is a useful debugging technique.

The calculate event on the PaperFormsBarcode object does the encoding.

// form1.page1.subform1.barcode::calculate - (JavaScript, client)

if (xfa.host.version < 7.05) {

    this.rawValue = " ";

}

else {

   this.rawValue = encodeBarcode();

}

function encodeBarcode() {

  // define barcode variables

  var firstName;

  var lastName;

  var address1;

  var address2;

  var city;

  var state;

  var zipCode;

  // check First Name for null

  if (form1.page1.subform1.firstName.isNull) {

    firstName = "";

  }

  else {

    firstName = form1.page1.subform1.firstName.rawValue;

  }

  // check Last Name for null

  if (form1.page1.subform1.lastName.isNull) {

    lastName = "";

  }

  else {

    lastName = form1.page1.subform1.lastName.rawValue;

  }

  // check Address for null

  if (form1.page1.subform1.address1.isNull) {

    address1 = "";

  }

  else {

    address1 = form1.page1.subform1.address1.rawValue;

  }

  // check Address for null

  if (form1.page1.subform1.address2.isNull) {

    address2 = "";

  }

  else {

    address2 = form1.page1.subform1.address2.rawValue;

  }

  // check City for null

  if (form1.page1.subform1.city.isNull) {

    city = "";

  }

  else {

    city = form1.page1.subform1.city.rawValue;

  }

  // check State for a null selection

  if (form1.page1.subform1.state.isNull) {

    state = "";

  }

  else {

    state = form1.page1.subform1.state.rawValue;

  }

  // check ZIP Code for null

  if (form1.page1.subform1.zipCode.isNull) {

    zipCode = "";

  }

  else {

    zipCode = form1.page1.subform1.zipCode.rawValue;

  }

  // build barcode string for encoding

  var str = firstName + "|"

  + lastName + "| "

  + address1 + "| "

  + address2 + "| "

  + city + "| "

  + state +  "|"

  + zipCode;

// return the encoding string

return (str);

}

Steve

View solution in original post