These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Leading zero being dropped from postal code when read in 2D barcode

gnrltsao
Registered: Oct 6 2009
Posts: 15

I'm working on a form in Acrobat 9.0 Professional with a 2D barcode. For some reason, any Social Security Numbers or zip codes beginning with a zero are not read properly and the zero is dropped. However, I have the forms display everything perfectly fine. To clarify, when reading the data from the 2D barcode, leading zero's are dropped but everything displays in the form.

I've tried the valueAsString, custom format scripts, and custom keystroke scripts but nothing seems to fix this issue. Is there something i'm missing?

My Product Information:
Acrobat Pro 9.0, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Maybe you should post the file, or at least the code.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Are you aware that the bar code field is running a custom calculation script that may need to be modified?

For example, in a form with the zip code entered into a field named 'zip', the custom caculation script for the bar code fiedl could be coded as follows:
/* Customize: */function bMemberOf(strName, aStrNames){for (var nMembIdx in aStrNames){if (strName == aStrNames[nMembIdx])return true;}return false;} // end bMemberOf function strTabDelimited(oParam){var bNeedTab = false;var strNames = "";var strValues = "";for (var i = 0; i < oParam.oDoc.numFields; ++i){var strFieldName = oParam.oDoc.getNthFieldName(i);if ((null == oParam.aFields || bMemberOf(strFieldName, oParam.aFields))&& (null == oParam.strXclField || strFieldName != oParam.strXclField)&& (oParam.oDoc.getField(strFieldName).type != "button")){if (bNeedTab){if (oParam.bFieldNames)strNames += "\t";strValues += "\t";}if (oParam.bFieldNames)strNames += strFieldName;// for leading zeros the following line needs to be modified for specific fieldsif(strFieldName == 'zip') {strValues += oParam.oDoc.getField(strFieldName).valueAsString;} else {strValues += oParam.oDoc.getField(strFieldName).value;}bNeedTab = true;}}if (oParam.bFieldNames)return strNames + "\n" + strValues;elsereturn strValues;} // end strTabDelimited try{// modified lines followconsole.show();console.clear(); // bring up consoleconsole.println('Bar Code Calculate'); // clear consoleif ( app.viewerVersion >= ADBE.PMD_Need_Version )// enter field names between brackets for aFields parameterevent.value = strTabDelimited({oDoc: this, aFields: ['street', 'city', 'state', 'zip'], bFieldNames: true});else event.value = " ";}catch (e){event.value = " ";}console.println('result:\n\n ' + event.value); // display result

George Kaiser

gnrltsao
Registered: Oct 6 2009
Posts: 15
I just noticed now. This custom calculation script only takes into account the zip code or does it take into account all other fields? I have 115 fields that I would need this barcode to read...would i list the 113 other fields as Afields? I'm rather new to this so I thank you for your patience.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Well how many of the fields will have leading zeros?

You can modify the code to do all fields if necessary or just the fields that have leading zeros.

George Kaiser

gnrltsao
Registered: Oct 6 2009
Posts: 15
Thank you, it appears to be working. One more question. It seems as if the field names are included. Is there anyway to remove the field names from this and have only the data from the selected fields populate?
gnrltsao
Registered: Oct 6 2009
Posts: 15
This is the code that I currently have. For some reason, it is doubling the output of the fields that I edited.

/* Customize: */
function bMemberOf(strName, aStrNames)
{
for (var nMembIdx in aStrNames)
{
if (strName == aStrNames[nMembIdx])
return true;
}
return false;
} // end bMemberOf

function strTabDelimited(oParam)
{
var bNeedTab = false;
var strNames = "";
var strValues = "";
for (var i = 0; i < oParam.oDoc.numFields; ++i)
{
var strFieldName = oParam.oDoc.getNthFieldName(i);
if ((null == oParam.aFields || bMemberOf(strFieldName, oParam.aFields))
&& (null == oParam.strXclField || strFieldName != oParam.strXclField)
&& (oParam.oDoc.getField(strFieldName).type != "button"))
{
if (bNeedTab)
{
if (oParam.bFieldNames)
strNames += "\t";
strValues += "\t";
}
if (oParam.bFieldNames)
strNames += strFieldName;
// ALL OF THESE FIELDS ARE BEING DUPLICATED FOR SOME REASON...CAN YOU TELL ME WHY?
if(strFieldName == '001_SSN') {
strValues += oParam.oDoc.getField(strFieldName).valueAsString;
}
if(strFieldName == '009_Mailing Address Zip Code') {
strValues += oParam.oDoc.getField(strFieldName).valueAsString;
}
if(strFieldName == '015_Home Address Zip') {
strValues += oParam.oDoc.getField(strFieldName).valueAsString;
}
if(strFieldName == '017_Home Phone') {
strValues += oParam.oDoc.getField(strFieldName).valueAsString;
}
if(strFieldName == '018_Mobile Phone') {
strValues += oParam.oDoc.getField(strFieldName).valueAsString;
}
if(strFieldName == '019_Home Office Phone') {
strValues += oParam.oDoc.getField(strFieldName).valueAsString;
}
if(strFieldName == '020_Work Phone') {
strValues += oParam.oDoc.getField(strFieldName).valueAsString;
}
if(strFieldName == '021_Other Phone') {
strValues += oParam.oDoc.getField(strFieldName).valueAsString;
}
if(strFieldName == '022_Fax Phone') {
strValues += oParam.oDoc.getField(strFieldName).valueAsString;
} else {
strValues += oParam.oDoc.getField(strFieldName).value;
}
bNeedTab = true;
}
}
if (oParam.bFieldNames)
return strNames + "\n" + strValues;
else
return strValues;
} // end strTabDelimited

try
{
if ( app.viewerVersion >= ADBE.PMD_Need_Version )
// enter field names between brackets for aFields parameter
event.value = strTabDelimited({oDoc: this, aFields: ['001_SSN', '002_First_Name', '003_Last Name', '004_Middle Name',
'005_Mailing Address Street 1', '006_Mailing Address Street 2', '007_Mailing Address City', '008_Mailing Address State',
'009_Mailing Address Zip Code', '010_Country Code', '011_Home Address Street 1', '012_Home Address Street 2', '013_Home Address City',
'014_Home Address State', '015_Home Address Zip', '016_Home Address Country Code', '017_Home Phone',
'018_Mobile Phone', '019_Home Office Phone', '020_Work Phone', '021_Other Phone', '022_Fax Phone', '023_Email Address', '024_Marital Status', '025_Birth Date',
'026_Gender', '027_Ethnicity', '028_Disability_Type', '029_Disabled Veteran', '030_Accomodation Needed', '031_Military Status', '032_Race Ethnicity', '033_Preferred Name',
'034_Suffix'], bFieldNames: true});
else event.value = " ";
}
catch (e)
{
event.value = " ";
}
console.println('result:\n\n ' + event.value); // display result


Once again, I'm a newbie so thank you for your help.