Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Barcodes

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 24th, 2015, 01:41 AM
milind.vaze milind.vaze is offline
Forum n00b
 
Join Date: Jun 2013
Posts: 9
Default 3 of 9 barcode (HR) with checkdigit

Hello:
In address labels - we have to insert a 3 of 9 barcode (human readable) with check digit. Client has told us to start barcode number series beginnning with 200,00,000. Printing has to be done daily lots with barcode numbering continuing from the earlier lot.

Each barcode has to have 13 characters:
First 2 characters - alphabets 'EA'
Next 8 characters - number digits
Next 1 character - check digit
Next 2 characters - alphabets 'IN'

Other fields for address details are in Excel format.

Please guide.

Regards.

Milind Vaze.
Reply With Quote
  #2  
Old December 22nd, 2015, 02:43 AM
milind.vaze milind.vaze is offline
Forum n00b
 
Join Date: Jun 2013
Posts: 9
Default Re: 3 of 9 barcode (HR) with checkdigit

Quote:
Originally Posted by milind.vaze View Post
Hello:
In address labels - we have to insert a 3 of 9 barcode (human readable) with check digit. Client has told us to start barcode number series beginnning with 200,00,000. Printing has to be done daily lots with barcode numbering continuing from the earlier lot.

Each barcode has to have 13 characters:
First 2 characters - alphabets 'EA'
Next 8 characters - number digits
Next 1 character - check digit
Next 2 characters - alphabets 'IN'

Other fields for address details are in Excel format.

Please guide.

Regards.

Milind Vaze.
Hello:

Formula in excel is available to generate the check digit for 3 of 9 barcode. Can this formula be converted for use in javascript to generate the barcode data (including prefix, check digit and suffix)?

Thanks with regards.

Milind Vaze
Reply With Quote
  #3  
Old December 22nd, 2015, 07:17 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: 3 of 9 barcode (HR) with checkdigit

Quote:
Originally Posted by milind.vaze View Post
Hello:

Formula in excel is available to generate the check digit for 3 of 9 barcode. Can this formula be converted for use in javascript to generate the barcode data (including prefix, check digit and suffix)?
Can it be converted to JavaScript from Excel? I don't think so. But if you know what the formula is, you can write it in JavaScript for FusionPro to use. I googled "3 of 9 barcode formula" and came across this website.

By referencing that website, I was able to come up with this function to create a human-readable barcode with a check digit:
Code:
function Encode(barcode) {    
    var map = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','-','.',' ','$','/','+','%'];
    var check = 0;
    barcode = ToUpper(barcode);
    for (i in barcode)
        check += map.indexOf(barcode[i]);
    check %= 43;
    return barcode + map[check];
}
You can place it in your JavaScript Globals and call it from any rule in your template like so:
Code:
return Encode('20000000'); // returns 200000002
In regards to your original question, if you're creating a sequential batch of barcodes, you could assign a starting point in JavaScript Globals or OnJobStart like this:
Code:
var start = 20000000 - 1; // Minus one so the first record will be 20000000
Then your text rule would look like this:
Code:
var seq = FusionPro.Composition.inputRecordNumber + start;
return 'EA' + Encode(seq) + 'IN'; // returns EA200000002IN
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #4  
Old December 22nd, 2015, 08:01 AM
Leosmith Leosmith is offline
Junior Community Member
 
Join Date: Jun 2015
Location: Saint Paul
Posts: 41
Default Re: 3 of 9 barcode (HR) with checkdigit

Hi Milind,
example attached.
I googled for an excel forumula for Mod43 check digit and got this. http://www.excelbanter.com/showthread.php?t=426855
The excel formula was applied to the eight digit number a check digit and the results were concatenated with the alpha characters.

In FusionPro the building block was used to create the 3of9 barcode and applied to the field. The second barcode is the same except the alphas were applied in a FusionPro rule.

Not sure if any of it is correct or what you are trying to achieve but the barcodes do scan.

Note: I haven't tried Steve's solution yet but I believe it would be a more exceptional solution to have the work/process all done in FusionPro.

Leo
Attached Files
File Type: zip 3_of_9_Label_Test_3x4_FP.zip (2.89 MB, 2 views)
__________________
Leo Smith - Novice
FusionPro VDP Creator 10
Adobe Pro CC
Windows 7
Reply With Quote
  #5  
Old December 22nd, 2015, 08:32 AM
Leosmith Leosmith is offline
Junior Community Member
 
Join Date: Jun 2015
Location: Saint Paul
Posts: 41
Default Re: 3 of 9 barcode (HR) with checkdigit

Hi Ste,
Thanks for your step by step reply. Worked great.
It is very helpful for learning and understanding Javascript and FusionPro.
Leo
__________________
Leo Smith - Novice
FusionPro VDP Creator 10
Adobe Pro CC
Windows 7
Reply With Quote
  #6  
Old December 22nd, 2015, 08:44 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: 3 of 9 barcode (HR) with checkdigit

Quote:
Originally Posted by Leosmith View Post
The excel formula was applied to the eight digit number a check digit and the results were concatenated with the alpha characters.
This is exactly what my 'Encode' function is doing.
Quote:
Originally Posted by step View Post
By referencing that website, I was able to come up with this function to create a human-readable barcode with a check digit:
Code:
function Encode(barcode) {    
    var map = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','-','.',' ','$','/','+','%'];
    var check = 0;
    barcode = ToUpper(barcode);
    for (i in barcode)
        check += map.indexOf(barcode[i]);
    check %= 43;
    return barcode + map[check];
}
I probably should have mentioned this before, but here's the actual breakdown of how the function works:
  • An array ('map') is used to hold the values of the possible check digits and barcode characters – I pulled these from the website I referenced in my previous post.
  • The 'check' variable is initialized at 0 and will be incremented to determine the check sum
  • The value of the barcode is set to uppercase
  • Each character in the barcode is referenced against the 'map' array to determine how much to increment the check sum ('check').

    For example: if the 'barcode' input is "EA", the for loop uses the 'map' array to determine the position of 'E' (map.indexOf('E') == 14) and adds 14 to the check sum. Then it gets the value of 'A' (map.indexOf('A') == 10) and adds 10 to the check sum. So the check sum for "EA" is "24".
  • Then you need to do a mod 34 of the check sum:
    Code:
    check = check % 34;
    or
    Code:
    check %= 34
    In the case of the "EA" example, 24 % 34 is 24
  • Finally the mod34 is referenced against the 'map' array to determine with value to return for the "check character" and appended to the end of the barcode.

    Code:
    // map[24] == 'O'
    return barcode + map[check]; // returns EAO
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #7  
Old December 27th, 2015, 10:37 PM
milind.vaze milind.vaze is offline
Forum n00b
 
Join Date: Jun 2013
Posts: 9
Default Re: 3 of 9 barcode (HR) with checkdigit

Hello and wishing all a Happy New Year.

Many thanks for your replies and help. I am presently on leave. After I am back I will work on the solutions given by all and reply.

Regards.

Milind Vaze.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:24 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.