JavaScript控制打印机打印条形码

您所在的位置:网站首页 python连接条码打印机 JavaScript控制打印机打印条形码

JavaScript控制打印机打印条形码

2024-03-11 20:19| 来源: 网络整理| 查看: 265

  

    appId: 只有 UCC128 格式需要.

    width: 最小的 bar 寬度 pixels.

    height: 輸出的圖檔高度 pixels.

    resolution: 輸出的圖檔解析度 dpi.

    headless: 預設為 true, 當設為 false 時將不會同時繪出文字, 但是有些 type 即使設為 true 也不會繪出文字. (1.0.6RC1 此處有bug)

    drawText: 預設為 false, 當設為 true 時將增加一個檢查碼, 只有 Code39 格式有用.

  優點:比較輕量。

  缺點:按照上面的解釋,好像當headless=false時,drawText為true時可以在條形碼下顯示對應的值可是沒顯示,不知道原因

下面是英文的说明:

  Servlet class: net.sourceforge.barbecue.BarcodeServlet

Required parameters: --------------------

data     the data to encode

Optional parameters: --------------------

type    the barcode type - see below width    the width of the smallest bar in the barcode in pixels height    the height of the barcode in pixels resolution   the output resolution in DPI checksum   true to include a calculated checksum, false to omit (only used by Code39 and derivatives) headless   true for headless mode (default value), false to force non-headless mode drawText   (only takes effect if headless = false) true to draw text of barcode, false to omit

Types: ------

Valid barcode types are (case insensitive):

Code128 Code128A Code128B Code128C EAN128 USPS ShipmentIdentificationNumber SSCC18 SCCC14ShippingCode GlobalTradeItemNumber UCC128      Note: UCC128 requires an additional parameter: appid PDF417 Code39 3of9 USD3 Codabar Std2of5 Int2of5 USD4 NW7 Monarch 2of7 PostNet UPCA RandomWeightUPCA

Note that if the type is omitted then the type will default to Code128 (optimal).

Examples: ---------

BarcodeServlet?data=12345 BarcodeServlet?data=12345&width=3&height=100&resolution=100 BarcodeServlet?data=12345&drawText=yes BarcodeServlet?data=12345&type=Code128B BarcodeServlet?data=12345&type=UCC128&appid=402 BarcodeServlet?data=12345&type=PDF417 BarcodeServlet?data=12345&headless=false&drawText=true

Servlet Container Configuration: --------------------------------

When running the servlet in headless mode (the default) you must also set the Java VM running the servlet to use headless mode, by setting the following VM parameter:

-Djava.awt.headless=true

第二种:barcode4j

下載barcode4j-2.0-bin.zip,這個估計有7M多

需要用到的包有avalon-framework-4.2.0.jar,barcode4j.jar,commons-cli-1.0.jar

在web.xml中添加代碼

    barbecueServlet   net.sourceforge.barbecue.BarcodeServlet         barbecueServlet   /barbecue  

在jsp頁面中添加

  

參數說明

msg:打印的數據

type:類型

fmt:打印是以什麽格式打印

還有很多參數,網上可以找到解釋

上面兩種方式都是通過后台执行产生条形码的。在前台产生的可以使用jquery-barcode

第三种:jquery-barcode方式

首先下载jquery-barcode

http://barcode-coder.com/en/barcode-jquery-plugin-201.html

添加

      

在body中添加

 

$("#barcodeTarget").barcode("1234567", "ean8");

注意:顺序不能变

具体的使用可以看上面的链接

三种方式比较:

前两种都是以图片方式显示的,所以打印机可以打印出来,后面一种是通过css样式定义出来的,所以不能通过打印机打印(其实可以以bmp方式打印,但是官网上说不能在IE下使用,无语,期待升级)。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3