Java Open Source Barcode generation component Barcode4j__java

Source: Internet
Author: User

Original link: http://hi.baidu.com/282518588/item/d026413db0fac6b2124b147d#713670-tqq-1-62579-73c8c094f3d19c62454c09579207fe3e


Barcode Generation uses a lot of barbecue and barcode4j. I first use the barbecue, bar code can be displayed, but the following corresponding numbers can not be shown, of course, manually plus to go, but that is not a picture inside, typesetting is not very good-looking. So I tried a barcode4j, the effect is very good, so put the use of the method, to just contact the Java friends a little reference.
1, Google or ferry a barcode4j to use the Dongdong, download the compression package Barcode4j-2.0alpha2-bin.zip and Barcode4j-2.0alpha2-src.zip.
2, decompression Barcode4j-2.0alpha2-bin.zip This package, in the build directory has Barcode4j.jar, in the Lib directory has Avalon-framework-4.2.0.jar, Add Barcode4j.jar and Avalon-framework-4.2.0.jar to the project's LIB, refresh the project, and then add the two jar packages to the CLASSPATH in the project configuration.
3, decompression will be barcode4j-2.0alpha2-src.zip, will src/java/org/krysalis/barcode4j/ The code for the Barcodeservlet.java class in the servlet directory is copied, the default picture display is modified, and the default picture display format for line 168th is changed to JPEG (since not all browsers support SVG format, and not all viewers are willing to Add one such plugin to your browser.
4, the following section of the servlet configuration in the Web.xml
<servlet>
<servlet-name>BarcodeServlet</servlet-name>
<servlet-class>com.yourname.BarcodeServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>BarcodeServlet</servlet-name>
<url-pattern>/barcode</url-pattern>
</servlet-mapping>
4. Add /barcode?msg=12345678" height= "50px" to the page width=130px/>
5, view the page can be found in the bar code for "12345678" picture, of course, the size of the picture on their own set up.
Oh, although it is very simple things, but I hope to be able to help friends need.
Barcode Function Description Update: 2007-05-31-13:45:48 Version: 1.0 Barcode1.0 Function Description
First, barcode project description:
Develop a barcode printing function for Java BS using barcode4j Open Source project.
Second, the Barcode project function:
1, the use of BARCODE4J project to achieve 8 types of bar code.
2, through the URL call to implement the Web page display bar code.
3, through the XML file configuration to achieve predefined bar code type.
4, the realization of the results of the bar code debugging, configuration functions.
Third, barcode implementation steps
1, the Barcode4j.jar, Barcode.jar copy to the/webroot/web-inf/lib directory.
2. Add Barcodeservlet in/webroot/web-inf/web.xml
<servlet>
<servlet-name>barcode-invoker</servlet-name>
<servlet-class>barcode.servlet.BarCodeServlet</servlet-class>
<init-param>
<param-name>conf</param-name>
<param-value>/conf/barcode_conf.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>barcode-invoker</servlet-name>
<url-pattern>*.barcode</url-pattern>
</servlet-mapping>
Barcodeservlet Description:
1, the Conf parameter is used to set predefined bar code type, do not set no predefined type.
2./conf/barcode_conf.xml is a predefined barcode type configuration file. The files are placed in the/webroot/web-inf/classes/conf/directory.
3, *.barcode for the bar code to display the URL identification.
3, call the URL in the Web page.
Case:
1,
2,
URL Description:
[Type *]. Barcode?code**= ... Other Parameters * * *
*: Types are fixed types (10 types) and predefined types (type before _).
**:code is a necessary parameter.
: Other parameters to enrich the bar code display effect.
Four, parameter description:
Name Type default Value description
Resolution: the DPI int 150 values the larger the bar code the longer, the higher the resolution.
Leave blank Quietzone boolean false bar code ends with blank
Take counter AntiAlias Boolean false Barcode internal fetch counter, specific function unknown
Picture inversion orientation int 0 Rotate barcode, optional [0, 90, 180, 270,-90,-180,-270]
Height Barheight Double 15 code display height, proportional number
The font displays the HRP int 2 font display position for 0 time shielding FontName, fontsize parameters.
0=hrp_none
1=hrp_top
2=hrp_bottom
Font name FontName String Helvetica the font type followed by the barcode, such as: XXFarEastFont-Arial, blackbody, etc.
Font size fontsize Double 2.8 follows the barcode font size, proportional to the number
Five, XML file description:
<?xml version= "1.0" encoding= "GBK"?>
<barcode_conf>
&LT;A3 fontsize= "4" fontname= "bold" hrp= "0" barheight= "" orientation= "0" antialias= "false" Quietzone= "false" dpi= "200" Type= "CODE39"/>
&LT;A2 type= "CODE39"/>
&LT;A1 type= "CODE39"/>
</barcode_conf>
The A1, A2, A3 three predefined types are defined in the case. You can set 9 parameters, where
Type is the necessary parameter and corresponds to 10 basic bar code types.
Note the case of URLs, parameters, and XML file node properties!
Six, barcode Debugging program function Description:
1, display Picture: According to fill in 10 parameters dynamic display bar code. The printing code and type are required criteria.
2, Save settings: To debug the bar code style is more satisfied, given the number saved in the following list for later call display or build configuration. Note that numbers cannot be duplicated.
3. List display: The saved configuration can be displayed again.
4, List deletion: Delete the row configuration.
5, display all: will save all the barcode configuration display, for printing check use.
6. Display configuration: Displays all the saved barcode configurations as predefined XML formats.
7, Resources download: For BS Project Integration Barcode provide resources sample download.
8, copy URL: The current display bar code URL path to copy the system paste board (only IE).
9, the original ratio: the bar code graphics scaling back to 100% (only IE).
10, bar code scaling: In the case of selected bar code Zoom box, click on the barcode picture can use the mouse wheel to achieve 20%-500% image zoom function (only IE).
The above function in IE, Firefox debugging success.
Seven, The legend
Type Barcode type PNG graphic
CODE39 Code 39
CODE128 Code 128
Int2of5 Interleaved 2 of 5
Codabar Codabar
UPCA upc-a
Upce UPC-E
EAN13 EAN-13
EAN8 EAN-8
PDF417 PDF417
Datamatrix Datamatrix

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.