PDF Editing Issues

How to Add Asterisks Around a Value in an Adobe Acrobat Code 39 Barcode

Tauseeq MagsiTauseeq Magsi Nov 5, 2026 869 views

Question details

The user needs to format a text value entered in a PDF form by automatically appending an asterisk to both the beginning and the end, and then display this combined string in a read-only Code 39 barcode field.

How to Add Asterisks Around a Value in an Adobe Acrobat Code 39 Barcode
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Creating or modifying an interactive PDF document where a Code 39 barcode must dynamically pull data from a source field and format it with mandatory start/stop characters.
Observed behavior
The Code 39 barcode needs a reliable script to fetch the source field's input, combine it with the required asterisks, and output the readable barcode.
Before you start

Ensure you have access to the 'Prepare Form' tool in Adobe Acrobat and make a note of the exact field name of your source text box before applying the custom script.

Solution 1Recommended

Apply a Custom JavaScript Calculation to the Barcode Field

Use Adobe Acrobat's built-in calculation properties to automatically pull the text field value, append the asterisks, and generate the correct Code 39 barcode.

Code 39 barcodes require asterisks (*) at the beginning and end of the data string to act as start and stop characters for the scanner. You can automate this insertion using a simple JavaScript calculation applied directly to the barcode field.

1
Enter Prepare Form Mode

Open your PDF document in Adobe Acrobat, navigate to the Tools menu, and select 'Prepare Form' to enable form field editing.

2
Access Barcode Properties

Right-click on the read-only Code 39 barcode field you wish to update and select 'Properties' from the context menu.

3
Add the Custom Calculation Script

Navigate to the 'Calculate' tab inside the Properties dialog. Select the 'Custom calculation script' radio button and click 'Edit'. In the JavaScript Editor, paste the following code: event.value = "*" + this.getField("A").valueAsString + "*";

4
Update the Source Field Name

In the pasted script, replace the letter "A" with the exact name of the text field where users will enter their data. Click 'OK' to save the script.

5
Test the Barcode Output

Close the Properties dialog and exit Prepare Form mode. Type a sample value into your source text field and click outside the box to verify that the barcode updates with the appended asterisks.

Apply a Custom JavaScript Calculation to the Barcode Field
Case Sensitivity: JavaScript is strictly case-sensitive. Ensure that the field name you type inside the getField() parameters matches your actual source field name exactly, including any capitalizations.
Efficient PDF Form Editing

Manage and Fill Interactive PDF Forms with WPS Office

If you need a fast and reliable tool to fill, edit, and manage interactive PDF documents, WPS Office offers a comprehensive PDF editor. It streamlines form handling and provides seamless document management in a single, unified application.

  1. 1. Download the Software: Visit the official WPS Office website to download and install the free software on your device.
  2. 2. Open Your PDF Form: Launch WPS Office and open your interactive PDF document using the built-in PDF reader.
  3. 3. Fill and Save: Click on the form fields to input your data easily, then save the completed document for sharing or printing.
Easily view, fill, and sign interactive PDF forms without complex setups.Highly compatible with Adobe PDF standards and all Microsoft Office formats (Word, Excel, PowerPoint).Lightweight, fast-loading software with an intuitive, familiar interface.Built-in PDF conversion tools to instantly transform documents between PDF and other formats.
microsoft office alternative - wps office

Frequently Asked Questions

Why does a Code 39 barcode require asterisks?

The Code 39 standard utilizes asterisks as distinct start and stop characters. They signal to the hardware barcode scanner exactly where the encoded data sequence begins and ends, preventing reading errors.

Why isn't my PDF barcode updating automatically when I enter text?

Calculation scripts typically run when a field loses focus. Ensure you click outside the text box or press 'Enter' after typing. You can also open the source field's Properties, go to the 'Options' tab, and check 'Commit selected value immediately' for real-time updates.

How do I find the exact name of my source text field in Acrobat?

In Adobe Acrobat's 'Prepare Form' mode, double-click the target text field to open its Properties dialog. The exact field name is displayed at the top of the 'General' tab.

Can I use this same script for other barcode formats like QR codes?

No. This specific string manipulation that appends asterisks is unique to the Code 39 format requirements. Other formats, such as Code 128 or QR codes, have different start/stop mechanisms and do not require manual asterisk insertion.