barcode制作条形码及破解

本文介绍了一款用于Java环境下的条形码生成器——BarcodeforJava。该工具支持多种条形码类型,如Code11、EAN13等,并详细讲解了如何在Java应用、Web应用及JasperReports中生成条形码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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字样
由于产生的位置靠上,我就用一张白色的图片把上半部遮掉了, 虽然扁了点,但效果还不错
这样就可以免费使用相当于正式版的体验版。
最后如果大家如果有正式版的希望能发我个,省得我那么麻烦了

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值