java ireport 打印_如何利用ireport实现打印条码标签

/*

2 * Copyright (C) 2005 - 2006 JasperSoft Corporation. All rights reserved.

3 * http://www.jaspersoft.com.

4 *

5 * Unless you have purchased a commercial license agreement from JasperSoft,

6 * the following license terms apply:

7 *

8 * This program is free software; you can redistribute it and/or modify

9 * it under the terms of the GNU General Public License version 2 as published by

10 * the Free Software Foundation.

11 *

12 * This program is distributed WITHOUT ANY WARRANTY; and without the

13 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

14 * See the GNU General Public License for more details.

15 *

16 * You should have received a copy of the GNU General Public License

17 * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt

18 * or write to:

19 *

20 * Free Software Foundation, Inc.,

21 * 59 Temple Place - Suite 330,

22 * Boston, MA USA 02111-1307

23 *

24 *

25 *

26 *

27 * BcImage.java

28 *

29 * Created on 20. April 2004, 13:21

30 *

31 */

32

33packageit.businesslogic.ireport.barcode;

34

35/**

36 *

37 * @author Heiko

38 */

39

40importjava.awt.image.*;

41importnet.sourceforge.barbecue.*;

42importnet.sourceforge.barbecue.linear.ean.UCCEAN128Barcode;

43

44publicclassBcImage {

45privatestaticnet.sourceforge.barbecue.Barcode bc =null;

46

47publicstaticnet.sourceforge.barbecue.Barcode getBarcode() {

48returnbc;

49}

50

51publicstaticBufferedImage getBarcodeImage(inttype,Object0c10910d8958b1f80b31d16bf2a737af.gifaText,booleanshowText,booleancheckSum) {

52returngetBarcodeImage(type, aText, showText, checkSum,"",0,0);

53}

54

55publicstaticBufferedImage getBarcodeImage(inttype,Object0c10910d8958b1f80b31d16bf2a737af.gifaText,booleanshowText,booleancheckSum,String0c10910d8958b1f80b31d16bf2a737af.gifapplicationIdentifier,intwidth,intheight) {

56// 2of7, 3of9, Bookland, Codabar, Code128, Code128A, Code128B, Code128C, Code39, EAN128, EAN13, GlobalTradeItemNumber, Int2of5, Int2of5, Monarch, NW7, PDF417, SCC14ShippingCode, ShipmentIdentificationNumber, SSCC18, Std2of5, Std2of5, UCC128, UPCA, USD3, USD4, USPS

57

58String0c10910d8958b1f80b31d16bf2a737af.giftext =newStringBuffer0c10910d8958b1f80b31d16bf2a737af.gif().append(aText).toString();

59

60try{

61switch(type) {

62case0:returnnull;

63case1: bc = BarcodeFactory.create2of7(text);break;

64case2: bc = BarcodeFactory.create3of9(text, checkSum);break;

65case3: bc = BarcodeFactory.createBookland(text);break;

66case4: bc = BarcodeFactory.createCodabar(text);break;

67case5: bc = BarcodeFactory.createCode128(text);break;

68case6: bc = BarcodeFactory.createCode128A(text);break;

69case7: bc = BarcodeFactory.createCode128B(text);break;

70case8: bc = BarcodeFactory.createCode128C(text);break;

71case9: bc = BarcodeFactory.createCode39(text, checkSum );break;

72case10: bc = BarcodeFactory.createEAN128(text);break;

73case11: bc = BarcodeFactory.createEAN13(text);break;

74case12: bc = BarcodeFactory.createGlobalTradeItemNumber(text);break;

75case13: bc = BarcodeFactory.createInt2of5(text, checkSum);break;

76case14: bc = BarcodeFactory.createMonarch(text);break;

77case15: bc = BarcodeFactory.createNW7(text);break;

78case16: bc = BarcodeFactory.createPDF417(text);break;

79case17: bc = BarcodeFactory.createSCC14ShippingCode(text);break;

80case18: bc = BarcodeFactory.createShipmentIdentificationNumber(text);break;

81case19: bc =newUCCEAN128Barcode(UCCEAN128Barcode.SSCC_18_AI, text, checkSum);break;//BarcodeFactory.createSSCC18(text); break;

82case20: bc = BarcodeFactory.createStd2of5(text, checkSum);break;

83case21: bc =newUCCEAN128Barcode(applicationIdentifier, text, checkSum);break;//BarcodeFactory.createUCC128(applicationIdentifier, text); break;

84case22: bc = BarcodeFactory.createUPCA(text);break;

85case23: bc = BarcodeFactory.createUSD3(text, checkSum);break;

86case24: bc = BarcodeFactory.createUSD4(text);break;

87case25: bc = BarcodeFactory.createUSPS(text);break;

88case26: bc =newnet.sourceforge.barbecue.linear.code39.Code39Barcode(text, checkSum,true);break;

89}

90

91if(width >0) bc.setBarWidth(width);

92if(height >0) bc.setBarHeight(height);

93bc.setDrawingText(showText);

94returnnet.sourceforge.barbecue.BarcodeImageHandler.getImage(bc);

95}

96catch(Exception0c10910d8958b1f80b31d16bf2a737af.gife) {

97e.printStackTrace();

98//generate a runtime exception, invalid value passed.

99//the user must be notified if fail

100thrownewRuntimeException0c10910d8958b1f80b31d16bf2a737af.gif(e.getMessage());

101//return null;

102}

103}

104}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值