Oracle provides two methods to implement 128 code encoding
The first method is to use reports builder to encode the 128 code. In Metalink 305090.1 [1 ],
The idautomation. PLL includes the methods code128a and code128b.
And code128c respectively implement the encoding of Class A, Class B, and class C 128 codes. For more information, see Metalink.
305090.1.
The second method is to use XML Publisher to encode 128 codes. Because more than 128 ASCII code pairs
Special characters cannot be displayed in PL/SQL, but these characters are used as 128 characters in code 128
Start and end bits and check bits. The encoding process is implemented on the PL/SQL side and the XML data combination template is generated.
It is difficult to generate a bar code. To change our thinking, we put the Encoding Process in the Java class by combining the Template
128 codes can be generated and printed. In Oracle XML Publisher
Advanced barcode font formatting in administration and developer's Guide
Implementation provides the implementation of this method. Provide Java in Metalink 782809.1 [2]
Download the code 128 implementation class (barcodeutil. Java), and test the corresponding template file.
(Testbarcodeutil. rtf)
The following content uses the font idautomationc128m for demonstration.
1. Windows Local font configuration
Download the barcode font, copy it to the system font folder, and install it automatically.
2. Upload Java to the server
1. view the path in Java, for example, package oracle. Apps. xdo. template. rtf. util. barcoder;
Upload the Java file barcodeutil. Java to the $ java_top/Oracle/apps/xdo/template/RTF/util/barcoder directory.
Compile a Java File
The Java file is as follows:
/* Code extracted from Oracle?XML Publisher Core Components Guide Release 10.1.3.3 Pages 8-60 to 8-64*/package oracle.apps.xdo.template.rtf.util.barcoder;import java.util.Hashtable;import java.lang.reflect.Method;import oracle.apps.xdo.template.rtf.util.XDOBarcodeEncoder;import oracle.apps.xdo.common.log.Logger;// This class name will be used in the register vendor// field in the template.public class BarcodeUtil implements XDOBarcodeEncoder// The class implements the XDOBarcodeEncoder interface{ // This is the barcode vendor id that is used in the // register vendor field and format-barcode fields public static final String BARCODE_VENDOR_ID = "XMLPBarVendor"; // The hashtable is used to store references to // the encoding methods public static final Hashtable ENCODERS = new Hashtable(10); // The BarcodeUtil class needs to be instantiated public static final BarcodeUtil mUtility = new BarcodeUtil(); // This is the main code that is executed in the class, // it is loading the methods for the encoding into the hashtable. // In this case we are loading the three code128 encoding // methods we have created. static { try { Class[] clazz = new Class[] { "".getClass() }; ENCODERS.put("code128a",mUtility.getClass().getMethod("code128a", clazz)); ENCODERS.put("code128b",mUtility.getClass().getMethod("code128b", clazz)); ENCODERS.put("code128c",mUtility.getClass().getMethod("code128c", clazz)); } catch (Exception e) { // This is using the XML Publisher logging class to push // errors to the XMLP log file. Logger.log(e,5); } } // The getVendorID method is called from the template layer // at runtime to ensure the correct encoding method are used public final String getVendorID() { return BARCODE_VENDOR_ID; } //The isSupported method is called to ensure that the // encoding method called from the template is actually // present in this class. // If not then XMLP will report this in the log. public final boolean isSupported(String s) { if(s != null) return ENCODERS.containsKey(s.trim().toLowerCase()); else return false; } // The encode method is called to then call the appropriate // encoding method, in this example the code128a/b/c methods. public final String encode(String s, String s1) { if(s != null && s1 != null) { try { Method method = (Method)ENCODERS.get(s1.trim().toLowerCase()); if(method != null) return (String)method.invoke(this, new Object[] { s }); else return s; } catch(Exception exception) { Logger.log(exception,5); } return s; } else { return s; } } /** This is the complete method for Code128a */ public static final String code128a( String DataToEncode ) { char C128_Start = (char)203; char C128_Stop = (char)206; String Printable_string = ""; char CurrentChar; int CurrentValue=0; int weightedTotal=0; int CheckDigitValue=0; char C128_CheckDigit='w'; DataToEncode = DataToEncode.trim(); weightedTotal = ((int)C128_Start) - 100; for( int i = 1; i <= DataToEncode.length(); i++ ) { //get the value of each character CurrentChar = DataToEncode.charAt(i-1); if( ((int)CurrentChar) < 135 ) CurrentValue = ((int)CurrentChar) - 32; if( ((int)CurrentChar) > 134 ) CurrentValue = ((int)CurrentChar) - 100; CurrentValue = CurrentValue * i; weightedTotal = weightedTotal + CurrentValue; } //divide the WeightedTotal by 103 and get the remainder, //this is the CheckDigitValue CheckDigitValue = weightedTotal % 103; if( (CheckDigitValue < 95) && (CheckDigitValue > 0) ) C128_CheckDigit = (char)(CheckDigitValue + 32); if( CheckDigitValue > 94 ) C128_CheckDigit = (char)(CheckDigitValue + 100); if( CheckDigitValue == 0 ){ C128_CheckDigit = (char)194; } Printable_string = C128_Start + DataToEncode + C128_CheckDigit + C128_Stop + " "; return Printable_string; } /** This is the complete method for Code128b ***/ public static final String code128b( String DataToEncode ) { char C128_Start = (char)204; char C128_Stop = (char)206; String Printable_string = ""; char CurrentChar; int CurrentValue=0; int weightedTotal=0; int CheckDigitValue=0; char C128_CheckDigit='w'; DataToEncode = DataToEncode.trim(); weightedTotal = ((int)C128_Start) - 100; for( int i = 1; i <= DataToEncode.length(); i++ ) { //get the value of each character CurrentChar = DataToEncode.charAt(i-1); if( ((int)CurrentChar) < 135 ) CurrentValue = ((int)CurrentChar) - 32; if( ((int)CurrentChar) > 134 ) CurrentValue = ((int)CurrentChar) - 100; CurrentValue = CurrentValue * i; weightedTotal = weightedTotal + CurrentValue; } //divide the WeightedTotal by 103 and get the remainder, //this is the CheckDigitValue CheckDigitValue = weightedTotal % 103; if( (CheckDigitValue < 95) && (CheckDigitValue > 0) ) C128_CheckDigit = (char)(CheckDigitValue + 32); if( CheckDigitValue > 94 ) C128_CheckDigit = (char)(CheckDigitValue + 100); if( CheckDigitValue == 0 ){ C128_CheckDigit = (char)194; } Printable_string = C128_Start + DataToEncode + C128_CheckDigit + C128_Stop + " "; return Printable_string; } /** This is the complete method for Code128c **/ public static final String code128c( String s ) { char C128_Start = (char)205; char C128_Stop = (char)206; String Printable_string = ""; String DataToPrint = ""; String OnlyCorrectData = ""; int i=1; int CurrentChar=0; int CurrentValue=0; int weightedTotal=0; int CheckDigitValue=0; char C128_CheckDigit='w'; DataToPrint = ""; s = s.trim(); for(i = 1; i <= s.length(); i++ ) { //Add only numbers to OnlyCorrectData string CurrentChar = (int)s.charAt(i-1); if((CurrentChar < 58) && (CurrentChar > 47)) { OnlyCorrectData = OnlyCorrectData + (char)s.charAt(i-1); } } s = OnlyCorrectData; //Check for an even number of digits, add 0 if not even if( (s.length() % 2) == 1 ) { s = "0" + s; } //<<<< Calculate Modulo 103 Check Digit and generate // DataToPrint >>>>//Set WeightedTotal to the Code 128 value of // the start character weightedTotal = ((int)C128_Start) - 100; int WeightValue = 1; for( i = 1; i <= s.length(); i += 2 ) { //Get the value of each number pair (ex: 5 and 6 = 5*10+6 =56) //And assign the ASCII values to DataToPrint CurrentChar = ((((int)s.charAt(i-1))-48)*10) + (((int)s.charAt(i))-48); if((CurrentChar < 95) && (CurrentChar > 0)) DataToPrint = DataToPrint + (char)(CurrentChar + 32); if( CurrentChar > 94 ) DataToPrint = DataToPrint + (char)(CurrentChar + 100); if( CurrentChar == 0) DataToPrint = DataToPrint + (char)194; //multiply by the weighting character //add the values together to get the weighted total weightedTotal = weightedTotal + (CurrentChar * WeightValue); WeightValue = WeightValue + 1; } //divide the WeightedTotal by 103 and get the remainder, //this is the CheckDigitValue CheckDigitValue = weightedTotal % 103; if((CheckDigitValue < 95) && (CheckDigitValue > 0)) C128_CheckDigit = (char)(CheckDigitValue + 32); if( CheckDigitValue > 94 ) C128_CheckDigit = (char)(CheckDigitValue + 100); if( CheckDigitValue == 0 ){ C128_CheckDigit = (char)194; } Printable_string = C128_Start + DataToPrint + C128_CheckDigit + C128_Stop + " "; Logger.log(Printable_string,5); return Printable_string; }} /*End BarcodeUtil class */
3. generate an XML Data Source
Example:
<? XML version = "1.0" encoding = "UTF-8"?> <Receipt_applied> <lines> <item_code> f4990010010 </item_code> <item_name> <! [CDATA [CDATA software V1.0]> </item_name> <barcode> 912014266 </barcode> </lines> <item_code> f4990010010 </item_code> <item_name> <! [CDATA [CDATA software V1.0]> </item_name> <barcode> 912014265 </barcode> </lines> </receipt_applied>
4. Create a template based on the data source
Note: <? Register-barcode-vendor: 'oracle. Apps. xdo. template. rtf. util. barcoder. barcodeutil '; 'xmlpbarvendor'?> Register the barcode encoding class
<? Format-barcode: barcode; 'code128a'; 'xmlpbarvendor'?> Data formatting
5. register the data source and template
Omitted
6. Upload Fonts
Under the duties of XML Publisher administrator, first upload the font file
7. Configure font ing
Define the font conversion ing set under the duties of XML Publisher Administrator
Because our template uses the RTF format, you need to select the typeFO to PDF
Define the font conversion ing relationship under the duties of XML Publisher Administrator
Enter font family to open the font file.
Select style and Weight Based on the font used in the template
If you need to use the font ing Based on locale, fill in the language and territory. If you do not enter it, it indicates that all speech environments are applicable.
8. template and font ing Association
After the font ing is defined, modify the configuration of the bip template file.
After querying the bip template definition, clickEdit ConfigurationButton
Search for templates
Expand the fo Processing Section and setFont mapping setFont ing set defined above
Finally, submit the request to view the output