barcode制作条形码及破解

Barcode for Java

A leading Java barcode generator to be used in J2EE, J2SE environment and Java Reporting (JasperReports and Eclipse BIRT).

Barcode for Java supports generating high quality barcode images in

  • Java Server Side Environment (JSP, Servlet, J2EE, Web Service)
  • Java Application (Swing, Applet, Java Bean)
  • Java Reporting (Jasper Reports, Eclipse BIRT)

Barcode 所支持的条形码类型(太多我就不一一讲了,大家点进官网看吧)

由于我使用条形码,不是为了机器去读,只是为了好看,看上去报表更专业。

在这么多的条形码类型中,我个人认为code11 不但好用,样子也不错。

 

这里贴点使用和介绍(太简单,我也懒的翻译了)

It is used primarily in labeling telecommunications equipment. The symbology is discrete and is able to encode the numbers 0 through 9, the dash symbol (-), and start/stop characters.
Code 11 is not terribly secure in that printing imperfections can quite easily convert one character into another valid character. Data integrity is obtained by using one, or sometimes two, check characters.
Code 11 Barcode for Java supports:
  • 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
  • - (Dash)

The following code illustrates how to create a barcode in a Java class

 

1            Linear linear = new Linear(); 
2            linear.setData("123456789"); 
3            linear.setType(Linear.CODE11); 
4            linear.renderBarcode("c:/code11.gif"); 


 

 

  • Create a Linear object (line 1)
  • set Linear object properties (line 2 - 3)
  • save into gif file (line 4)

 

There are two ways to create barcode images in your Java web applications.

  1. This is the simplest way to stream barcode image using our provided barcode servlet classes.

    And it will not save barcode images in your server side.

    • Under demo package, copy barcode folder to your java servlet container like tomcat.
    • To test your installation, goto http://YourDomain:Port/barcode/linear?Data=123456789&Type=CODE11
    • To create barcode image in your JSP or html page, you can pass the url to IMG tag src value. For example, <img src="http://YourDomain:Port/barcode/linear?Data=123456789&Type=CODE11" />

  2. The second method is similar with the way to generate barcode in Java applications.

    • Create a barcode image in server side

       

      1            Linear linear = new Linear(); 
      2            linear.setData("123456789"); 
      3            linear.setType(Linear.CODE11); 
      4            linear.renderBarcode("C:/Tools/Tomcat 5.5/webapps/YourWebApp/bimages/barcode.gif"); 
      
      
      

       

    • In your JSP page, you can using IMG tag to display generated image, like <img src="http://YourDomain:Port/YourWebApp/bimages/barcode.gif" />

 

The following jasper xml content illustrates how to insert a barcode into JasperReports

<import value="com.barcodelib.barcode.BarcodeJasperFactory"/> 

Import class BarcodeJasperFactory to report.

<image scaleImage="Clip" hAlign="Center"> 
    <reportElement x="50" y="110" width="515" height="120"/> 
    <graphicElement/> 
    <imageExpression class="net.sf.jasperreports.engine.JRRenderable">
<![CDATA[new com.barcodelib.barcode.BarcodeJasperRenderer(BarcodeJasperFactory.createLinear(1, "47082163"))]]></imageExpression> </image>
大家肯定下个包,搞个十几分钟就搞定一个条形码了
多产生几张你会发现恶心的事情出来了,由于barcode这个包不是免费的
不交钱就只能用体验版,体验版会随机在你的条形码中放入红色的barcodelib.com字样
由于产生的位置靠上,我就用一张白色的图片把上半部遮掉了, 虽然扁了点,但效果还不错
这样就可以免费使用相当于正式版的体验版。
最后如果大家如果有正式版的希望能发我个,省得我那么麻烦了

posted on 2009-06-02 23:18  海南一哥  阅读(553)  评论(0编辑  收藏  举报

导航