Create, test, and edit barcode fields

One of the ways in which you can improve a PDF form barcode is by creating custom scripts. Writing such scripts requires a basic competency with JavaScript and a familiarity with Acrobat-specific JavaScript. For information, see the Acrobat JavaScript Scripting Guide on the JavaScript support page (English only) of the Adobe website. For information about basic JavaScript, refer to any of the many resources available on that subject.

After inserting a barcode of maximum size, changing the cell size or decode condition may cause the barcode to cross the page borders. Avoid this behavior by selecting the appropriate cell size and decode conditions for the barcode.

Add a barcode field

  1. Open the form in Acrobat, choose Edit > Preferences and select Forms on the left. Then select Automatically Calculate Field Values.
  2. Click the Barcode tool  on the Forms toolbar, or choose Tools > Forms > Barcode Tool.
  3. Drag a rectangle to define the barcode area. The Barcode Field Properties dialog box opens.
  4. On the Value tab, do one of the following:
    • Select Encode Using, and then select a format (XML or Tab Delimited). Click the Pick button and select the fields that you want to be encoded in the barcode field. If you don’t want to include the field names in the barcode data, deselect Include Field Names.

    • Select Custom Calculation Script, click Edit, and then enter your custom JavaScript code in the JavaScript Editor dialog box.

  5. On the Options tab, do all of the following:
    • Select a Symbology option: PDF417, QR Code, or Data Matrix.

    • Select Compress Data Before Encoding To Barcode if you want to apply this compression. Do not select this option if a handheld scanner will be used to capture data from returned forms.

    • In Decode Condition, choose the type of hardware that will process returned forms: Handheld Barcode Scanner, Fax Server, Document Scanner, or Custom.

    • If necessary, click Custom and enter values for X Dimension, Y/X Ratio, and Error Correction Level.

  6. Make any other changes on the General and Actions tabs. Then click OK to close the Barcode Field Properties dialog box.

    JavaScript code is generated automatically to encode the selected fields in the XML or Tab Delimited format, the Barcode Field Properties dialog box closes, and the barcode for which you specified values appears on the form.

    Note: If you add a new field to a form after you have created the barcode, the new field will not automatically be included in the data for existing barcodes. However, you can manually include additional data fields in the barcode.

Test a barcode field

  1. Choose Forms > Edit Form In Acrobat to deselect it, or click the Preview button on the Forms toolbar.
  2. Fill in the form, using sample data that represents the maximum amount of information that a each field allows or that you expect any user might enter.
  3. If the barcode field is grayed out, follow either the procedure for resizing the barcode field or for adjusting the content data. (See additional tasks, below.)
  4. When you are sure that the barcode field area is large enough to contain all of the incoming data, choose Forms > Clear Form, to remove the sample data, and then choose File > Save.

The barcode form field is now ready for distribution.

Include additional data fields in the barcode

  1. Using either the Barcode tool or the Select Object tool, select the barcode field and choose Forms > Edit Field Properties.
  2. On the Value tab, do one of the following:
    • If Encode Using is selected, click Pick, and select additional form fields to be encoded.

    • If Custom Calculation Script is selected, click Edit, and write additional JavaScript to include the additional fields.

After including new data fields in the barcode, be sure that the barcode area is large enough by testing sample data. If the barcode area is grayed out, adjust the barcode size, barcode properties, or text field properties so that the data content fits into the barcode area.

Resize a barcode field

The most common error when authoring barcoded forms is when the barcode area is too small to accommodate the data. If this occurs during your test of sample data, the barcode appears as a solid gray rectangle instead of showing its coding pattern.

  1. Select the Barcode tool , and select the barcode field.
    Important: Be sure to use only the Barcode tool to resize a barcode. If you resize a barcode using the Text Field Tool or the Select Object Tool, the barcode can be distorted and becomes unusable.
  2. Drag a handle along the edges or corners of the barcode field frame.
  3. If necessary, drag the barcode from inside its frame to move it to another location on the page.

Adjust data content to fit in a barcode field

  1. To edit the barcode properties so that it can accommodate more data, select it, choose Forms > Show Field Properties, and do any of the following:
    • On the Options tab, click the Custom button and enter lower values for Error Correction Level and Y/X Ratio.

    • On the Options tab, select Tab Delimited rather than XML as the data-encoding format. XML requires more barcode area to encode information than Tab Delimited does.

    • On the Options tab, select Compress Data Before Encoding To Barcode, but only if you will be using an Adobe software decoder (available separately).

    • On the Options tab, select a different Symbology option.

    • On the Value tab, click the Pick button, and deselect any fields that you don’t need to encode. For example, don’t include fields with redundant information

    • On the Value tab, enter a custom script that converts user-entered text to either all lowercase or all uppercase characters during the encoding process.

      Note: The National Association of Computerized Tax Processors (NACTP) guidelines, used by the United States Internal Revenue Service and state tax agencies, recommend using all uppercase characters for 2D barcode data
  2. To edit a text field to minimize the amount of barcode area needed to contain the data, select the text field, choose Forms > Edit Field Properties, and do either of the following:
    • On the Options tab, enter a value (or reduce the existing value) for Limit Of Characters

    • On the Validate tab, write a custom script that restricts data to alphanumeric characters and to a single case. (Text that is either all uppercase or all lowercase requires less barcode area than the same text written in a mixture of uppercase and lowercase characters.)

Consider creating additional barcode fields in the form and mapping different data to each barcode field.