A few weeks back I wrote about the barcode encoding solution thats now available for use with XML Publisher for advanced barcode encoding calculations prior to applying the bar code font to the output. I found some time to take a look at some of the 2D barcodes and their requirements for encoding and rendering. Once you have the encoding class set up in your environment its pretty simple to add the 2D barcode encoding code.
XML Publisher does not yet license fonts for ... they're coming, although no 2D barcodes. So I have been working with the PDF417 and Data Matrix fonts available from IDAutomation, along with the fonts they also provide neat java classes to do all the encoding you need. Its just a case of making their classes available in your environment and calling them in your encoding class. Then with a neat trick in your RTF template et voila you can have funky 2D barcodes in your output.
Step 1: Get the barcodes and encoding classes
So you'll need to license the fonts from the vendor, in this example I worked with the sample fonts available from the IDAutomation site.
PDF417 Font - http://www.advancemeants.com/downloads/IDAutomation_PDF417FontEncoderDEMO.zip - you'll get a zip file with the font and java class plus a bunch of other useful integration tools. All you need is the PDF417Encoder.class and the IDAutomationPDF417nX.ttf font from the AdditionalFonts.zip where 'X' is the X to Y ratio of the font shape, 3 is the standard.
This is explained better on the web site, http://www.idautomation.com/fonts/pdf417/faq.html#Specifications
Step 2: Update your XMLP encoding class
Now you need to add the encoding code to your encoding class, take a look at our entry from a while back on Advanced Barcode Support.
In the encoder class we created we import the font vendors encoding class and add an entry for the pdf417 font
import IDautomationPDFE.PDF417Encoder;
...
...
ENCODERS.put("pdf417",mUtility.getClass().getMethod("pdf417", clazz));
and create a pdf417 method that just calls the class provided by the font vendor:
public static final String pdf417( String DataToEncode )
{
PDF417Encoder pdfe = new PDF417Encoder();
return ( pdfe.fontEncode(DataToEncode) );
}
Compile and deploy to the server as normal.
Step 3: Use the font in your template
Install your font into the <<WINDOWS_HOME>>/fonts directory and fire up MSWord. Create your template and for the data that you wish to use the barcode for:
(a) Use a formfield or raw text
<?format-barcode:ITEM_DESCRIPTION ;'PDF417';'XMLPBarVendor'?>
where ITEM_DESCRIPTION is the data to be encoded
PDF417 is the name of the encoding method to be used
XMLPBarVendor is the name of our encoder
(b) Mark the formfield or text with the PDF417 font
Now save your template and deploy.
Now when you run the template the data will be encoded and the font applied.
I have uploaded a sample encoding class and template to help you out.
The same process can be applied to the Datamatrix barcode to generate that output. We had a customer test the result of the PDF417 and Datamatrix barcodes and their 2D barcode hardware read the resulting barcodes perfectly.
Comments (4)
Hello Tim, We have been trying to implement barcodes in our XML Publisher Reports. We have tried several options but nothing works out. In most cases the scanner is not able to read the barcodes correctly. We had picked up the IDAutomationSC128M.ttf font from their site. If you want I can mail my RTF template to you so that you can have a look at it and let mw know where I am wrong. We want to print Code 128a barcode fonts. Request you to please tell me where can I get this font from, along with the encoder class. For your information, we are the version we have is as below: java -version java version "1.5.0_06" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05) jre -version Java(tm) Runtime Loader Version 1.1.8 You may get back to me at bulbul.saha@ge.com Can I have your email ID please? Thanks regards Bsaha
Posted by bsaha | July 3, 2006 2:14 AM
Posted on July 3, 2006 02:14
Hi Bsaha
The IDAutomation font should be fine ... we have other customers using them successfully. You can send me your template, font and sample data to tim.dexterAToracleDOTcom.
Tim
Posted by Tim Dexter | July 13, 2006 2:17 PM
Posted on July 13, 2006 14:17
I have been trying to use this on the PC side to test the barcoding and cannot get the new class to 'find' the IDautomation class. What do I need to do to get the class to compile?
Posted by Mike Parr | April 2, 2009 3:40 AM
Posted on April 2, 2009 03:40
Hello!
I should use pdf417 font on dispatch labels, but I have not got it working properly. The encoder is invoked, but the output of the 2D barcode is not correct. There is horizontal white space in the code. I have allready logged two service requests (last one:3-1075385333) regarding. We are using the code from IDAutomation. Where and how to format the output?
Best regards,
Lüüli
Posted by Lüüli | November 23, 2009 6:37 AM
Posted on November 23, 2009 06:37