Home Page Barcodes for Apache FOP
                                          • Introduction
                                          • Features
                                          • Jasper Reports
                                          • Jaspersoft Studio
                                          • Eclipse Birt
                                          • Apache FOP Plugin
                                          • Web Frameworks
                                          • Web Services
                                          • Documentation
                                          • GS1 Barcodes
                                          • Customers
                                          • Download
                                          • Pricing & Purchase
                                          • License

                                          • For other languages
                                          • AJAX/Javascript
                                          • XOJO & Realbasic
                                          • Ruby

                                          • Related products
                                          • RBarcode Vision
                                          • FOP Plugin Guide
                                            J4L-Barcode for FOP

                                            J4L Barcodes plugin for Apache FOP (generation of PDF files)

                                            Copyright J4L Components (http://www.java4less.com) 2013.



                                            Apache FOP is an implementation of the XSL formatting objects (XSL-FO) which takes an input XML file and creates PDF files. It can also create other output formats but the most popular is PDF.

                                            The J4L Barcode plugin for Apache FOP allows you to add barcodes to the Apache FOP documents. This allows you to create PDF files which contain the following types of barcodes:

                                            The plugin not a standalone product but isincluded in the regular J4L Barcoding components license, if you need general information about the barcode itself (meaning of format , encoding ...) please refer to the documentation of the barcoding components.


                                            In order to use the plugin in your FOP documents you need to add the following jars to your classpath:

                                            • rbarcode-fop.jar
                                            • rbarcode.jar
                                            • qrcode.jar ( if you need to create QRCode barcodes)

                                            Sample application

                                            We deliver a simple application which creates PDF files using as input a FOP file:

                                            • In the examples subdirectory you will find a set of *.fo files used as template for creating the PDF files
                                            • The file ExampleFO2PDF.java is the sample application which will take the *.fo files and will create the PDF files.

                                            How to run the sample application:

                                            1. Create a Java Project with your favorite IDE tool (Eclipse, Netbeans ...)
                                            2. Add ExampleFO2PDF.java to your project
                                            3. Add rbarcode-fop.jar, lib/rbarcode.jar and lib/qrcode.jar to the project´s classpath
                                            4. Download Apache FOP (we tested 0.93 and 0.95) and add all fop jar files to your classpath
                                            5. Set the working directory of your project to be the examples subdiretory (so that the *.fo files can be read by the application)
                                            6. Run the application, it will create a set of pdf files in the working directory


                                            How to add barcode to a FOP / PDF file

                                            If you are not familiar with FOP, please read this tutorial first. If you are familiar with FOP, you know FOP files are XML files which describe the content of the target PDF file. In order to add a barcode to a FOP file you use these element:


                                            <fo:instream-foreign-object >

                                            <j4lbarcode xmlns="http://java4less.com/j4lbarcode/fop" mode="inline">


                                            <value>This is a code128</value>
                                            <text>Readable text</text>




                                            The blue elements are always the same for any type of barcode, the green elements will change depending on the kind of barcode you want to create (barcode 1D, pdf417 , datamatrix or qrcode). The example above creates a Barcode 1D.

                                            For Datamatrix you would use:

                                            <fo:instream-foreign-object >
                                            <j4lbarcode xmlns="http://java4less.com/j4lbarcode/fop" mode="inline">


                                            <code>This is a Datamatrix</code>




                                            For PDF417:

                                            <fo:instream-foreign-object >
                                            <j4lbarcode xmlns="http://java4less.com/j4lbarcode/fop" mode="inline">


                                            <code>This is a PDF417</code>



                                            for QRCode:


                                            <fo:instream-foreign-object >
                                            <j4lbarcode xmlns="http://java4less.com/j4lbarcode/fop" mode="inline">


                                            <code>This is a QRCode</code>




                                            for Maxicode:


                                            <fo:instream-foreign-object >
                                            <j4lbarcode xmlns="http://java4less.com/j4lbarcode/fop" mode="inline">




                                            and for AztecCode:


                                            <fo:instream-foreign-object >
                                            <j4lbarcode xmlns="http://java4less.com/j4lbarcode/fop" mode="inline">

                                            <!-- <CODEBINARY>BASE64 value</CODEBINARY>  -->



                                            This section provides now a short description of the meaning of the elements that define the barcode:

                                            • Barcode 1D:
                                              • type: type of barcode to create. Valid values are: BAR39, BAR38EXT, CODE128, CODE11, CODABAR,CODE93, CODE93EXT, MSI, IND25, MAT25, INTERLEAVED25, EAN13, EAN8, EAN128, UPCA, UPCE or POSTNET.
                                              • value: value to be encoded
                                              • set: value A, B or C (for type CODE128 only)
                                              • processTilde.See J4L Barcodes documentation
                                              • text: value to be displayed below the barcode.
                                              • barHeight: height of bars in pixels
                                              • X: width of narrow bars in pixels
                                              • N: multiplier for wide bars. A value of 2, means that wide bars will be 2 times the width of narrow bars. The default vaue is 2
                                              • barCodor. Color of bars. Valid values are RED, BLACK, BLUE, CYAN, DARKGRAY, GRAY, GREEN, LIGHTGRAY, MAGENTA, PINK, WHITE or YELLOW. You can also use the RGB value.
                                              • fontColor: color of the text.
                                              • backColor: background color.
                                              • font: font of the text, for example "ARIAL|BOLD|10", the format is <family|style|size>
                                              • leftMargin: margin in pixels
                                              • topMargin: margin in pixels

                                            • QRCode

                                              • code: value to be encoded.
                                              • moduleSize: size (pixels) of the modules (dots) of the matrix.
                                              • margin: margin in pixels.
                                              • ecLevel: can be H, L, M or Q.
                                              • encoding: can be ALPHA, BYTE, NUMERIC, KANJI or AUTO.
                                              • configuration: the configuration is the size of the qrcode. Valid values are 1 to 40, set 1 for automatic configuration selection.

                                            • Datamatrix

                                              • code: value to be encoded.
                                              • processTilde: See QRCode documentation in evaluation version.
                                              • moduleSize: size (pixels) of the modules (dots) of the matrix.
                                              • margin: margin in pixels
                                              • encoding: The default is ASCII. Posible values are ASCII, C40, TEXT, BASE256 and AUTO.
                                              • format: If empty the format will be selected automatically, if not you can specify the format (e.g. C24X24).

                                            • PDF417

                                              • code: value to be encoded
                                              • rows: number of rows
                                              • maxRows: maximum number of rows
                                              • cols: number of columns
                                              • ecLevel: error correction level
                                              • compaction: can be NUMERIC, TEXT or BINARY
                                              • X: width of narrows bars in pixels
                                              • H: height of bars
                                              • margin: margin in pixels

                                            • Maxicode

                                              • code: data to be encoded. In modes 2 and 3 if the postal code is empty it will be extracted from the begining of this string (see maxicode specifications). Use ~d029 as GS separator, ~d030 as EOT character, ~d062 as RS character and [) for code begin.
                                              • mode: maxicode mode. Values range from 2 to 6.
                                              • resolution: resolution of the printer in dpi, Default is 200. Other valid vaues are 300,400,500 and 600.
                                              • processTilde.
                                              • country: country code (modes 2 and 3.
                                              • serviceClass: service class (modes 2 and 3). In mode 2 it can be an alphanumeric of length 5. In mode 3 can be a numeric of length 9.
                                              • zipCode: postal code (modes 2 and 3).
                                              • L: Set length of length symbol. The default is 25.5 millimeters.

                                            • Azteccode

                                              • code: value to be encoded
                                              • CODEBINARY: binary value to be encoded
                                              • moduleSize: size (pixels) of the modules (dots) of the matrix.
                                              • processTilde: see AztecCode documentation
                                              • margin: margin in pixels.
                                              • ecLevel: default is 23 (23%)
                                              • encoding: can be NORMAL and BINARY
                                              • type: 0-any, 1-compact, 2-full 

                                            Getting help

                                            Send an email to java4lessATconfluencia.net if you have questions.