Thursday, August 19, 2021

Barcode Font formatting in Oracle XML Publisher / BI Publisher

Before going to the barcode implementation in XML Publisher, let's understand what is a Barcode?

A barcode consists of bars and spaces of varying width that can be read with an optical barcode scanner. When we go to a supermarket or a convenient store, to bill a product we need to scan the barcode of the product using a barcode scanner and the billing systems identify the product based on the barcode. What if there are no barcodes? e need to manually enter the product name or product number in the system to identify the exact product and its price and if you are buying many items, it takes very long time to enter each product number or name. Hence the barcodes and barcode readers came to solve this problem.

What are the components of a barcode?

As shown in the barcode components link, in general, there are 4 components to a barcode.

  1. Quiet Zone - Blank Margin located on either sides of barcode
  2. Start / Stop Characters - Represents the start and end of data
  3. Data - The actual data for which the barcode is generated
  4. Check Digit - Digit for checking if the encoded barcode data is correct

Now that we have seen the components of a barcode, the next thing is how do we convert the data into barcode format?

There are font encoders that reads the data and converts them into barcode format. Font encoder is the code (for simplicity, let's assume it as a java class) that reads the data and encodes it i.e. add start/stop characters and check digit. Usually the barcode font encoders i.e. java classes are provided by the barcode vendors.

Since barcodes are such an import functionality, XML Publisher also offers the ability to display data in barcode fonts in the report output.

Now let's see how to implement this barcode font formatting in XML Publisher.

The implementation requires 4 steps:

  1. Define Barcode Font Mapping (In this post, I am showing the steps for IDAutomationC128M Barcode font family which is of code128a barcode type.
  2. Place the encoding class file in the application server that can be used by XML Publisher at runtime to carry out the encoding at runtime
  3. In the form field of a template 
    1. register barcode encoding class - <?register-barcode-vendor:'java_class_name';'barcode_vendor_id'?>
    2. encode data - <?format-barcode:data;'barcodetype';'barcode_vendor_id'?> 
  4. Provide the font mapping defined in step1 under template configuration.
Define Barcode Font:
Navigation: XML Publisher Administration > Home > Administration

Click on Font Mappings > Create Font Mapping set











Place the encoding java class file in Application Server.


Tags to be added in the form field of template

<?register-barcode-vendor:'oracle.apps.xdo.template.rtf.util.BarcodeUtil';'XMLPBarVendor'?><?format-barcode:ORDER_NUMBER;'code128a';'XMLPBarVendor'?>

Once we complete the above steps, whenever XML publisher see the format-barcode tag, it will encode the data by using the encoding method (code128a in this case) in the class file that we mentioned in the register-barcode tag and generates the barcode format.








Note: As shown in the below screenshot, the language and territory of the template file should be same as that of the font mapping set. If they don't match, then XML Publisher will not encode the data into barcode format.





No comments:

Post a Comment