Skip to main content
Participant
June 23, 2022
Question

Code 39 Barcode - Automatically add required "*" digits

  • June 23, 2022
  • 2 replies
  • 1387 views

Hello, 

 

I need to create a code 39 barcode on a PDF document. It will be pulling data from a number field we manually enter data into. Let's call that field "ID".

 

I have the barcode font installed - however I can't figure out how to automatically append the data source number and wrape it with the * required in front and behind of the number in the barcode field "BARCODE". 

 

So, ultimately I wish to type 123 into ID field and have barcode field pull this and wrap it to read *123* so it will scan correctly. 

This topic has been closed for replies.

2 replies

Thom Parker
Community Expert
Community Expert
June 23, 2022

My mistake, Code 39 is a 1d barcode. Not subject to the same rules as the 2d barcode field.  

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Community Expert
June 23, 2022

Code 39 barcode does not require a check sum or correction digit, but does require a start and end code, which is the asterik in most 39 barcode fonts.

Community Expert
June 23, 2022

You can use this calculation script where "Barcode" is name of field

// Get the value of the field
var v = getField("Barcode").valueAsString;
// Add leading/trailing asterisks if not blank
event.value = v ? "*" + v + "*" : "";