BarScanner"

From Documentation
Line 9: Line 9:
  
 
= Employment/Purpose =
 
= Employment/Purpose =
A <tt>barcode</tt> component is used to generate a barcode at the browser, and decode the barcode on the server side. There are many properties to dealing with the barcode component. First, you could use the <tt>type</tt> property to specify the type of barcode, for example: qrcode, code128, code 128A...., after choose the type you want, you could generate the barcode of the code. And every barcode image could response to a certain value, the property <tt>value</tt> is for barcode image which wants to stand for.
+
A <tt>barScanner</tt> component is used to scan and decode the barcode on the client side. There are many properties to dealing with the barScan component. First, you could use the <tt>type</tt> property to specify the type of barcode, for example: qr, code128, ..., after choose the type you want, you could scan the barcode by the scanner. You can choose the continue scanning by setting contScan="true", and setting the scan rate by setting scanRate="1", the unit of scanRate is sec/time. You can turn on the scanner switch by setting open="true", or close it by open="false".  
  
 
= Example =
 
= Example =
Line 15: Line 15:
 
[[Image:qrcode.png]]
 
[[Image:qrcode.png]]
 
<source lang="xml" >
 
<source lang="xml" >
  <barcode type="qr" value="https://www.zkoss.org/" height="100px"/>
+
  <barScanner type="qr,code128" contScan="true" scanRate="0.5" height="100px"/>
</source>
 
 
 
[[Image:code128.png]]
 
<source lang="xml" >
 
<barcode type="code128" value="https://www.zkoss.org/" height="100px"/>
 
 
</source>
 
</source>
  
 
= type =
 
= type =
The Barcode has 18 types for 1D and 1 type for 2D by default. After choosing the type of barcode, and you can render the barcode as the type you choose.
+
The BarScanner has 9 types for 1D and 1 type for 2D by default. After choosing the type of barcode, and you can scan the barcode as the type you choose. You also can scan multiple types at one time, just setting type="xxx1,xxx2". For example
  
 
<source lang="xml">
 
<source lang="xml">
  <barcode type="qr"/>
+
  <barScanner type="qr,code128"/>
 
</source>
 
</source>
Note: the type that barcode supported can be referenced as Supported Barcode Type (Default).
+
Note:  
 +
(1) The type that barScanner supported can be referenced as Supported Barcode Type (Default).
 +
(2) Warn: if too many types are set for the widget, it may reduce the detecting accuracy.
  
= value =
+
= contScan =
value is a string attribute that barcode component want to render.
+
contScan is a boolean attribute to let the barScanner can continue scan or not.
  
 
<source lang="xml">
 
<source lang="xml">
  <barcode type="qr" value="https://www.zkoss.org"/>
+
  <barScanner type="qr" contScan="true"/>
 
</source>
 
</source>
Note: Some of the type only support a specific format of value.
 
  
= height =
+
= scanRate =
height is a string attribute to define the height of barcode component.
+
The scanRate is a subsidiary, integer attribute for contScan. The scanRate="0.5" means the scanner will scan once every 0.5 sec.  
  
 
<source lang="xml">
 
<source lang="xml">
  <barcode type="qr" value="https://www.zkoss.org" height="100px"/>
+
  <barScanner type="code128" contScan="true" scanRate="0.5"/>
 
</source>
 
</source>
  
Note:
+
= open =
 +
The open is boolean attribute to switch the barScanner. You can use the zk mvvm mechanism to to switch the barScanner. 
  
(1) height is a string as a format of "number+px"
+
<source lang="xml">
 
+
<window viewModel="@id('vm')@init('xxxVM')">
(2) In type of qr, the width is as same as the height.  
+
<barScanner type="code128" open= "@bind('vm.open')"/>
 +
</source>
  
= displayValue =
+
= height, width =
The displayValue is the boolean attribute to decide whether the show the value under the barcode or not.  
+
Height and width are string attributes to define the height and width of barScanner component.
  
 
<source lang="xml">
 
<source lang="xml">
  <barcode type="code128" displayValue="true"/>
+
  <barcode type="qr" height="100px", width="200px"/>
 
</source>
 
</source>
Note: This displayValue attribute is only implement for 1D format.
 
  
= fontSize =
+
Note:
The fontSize is a integer attribute that decides the text font size under the 1D barcode.
 
  
<source lang="xml">
+
(1) height is a string as a format of "number+px"
<barcode type="code128" barWidth="2"/>
 
</source>
 
Note: This attribute is only implement for 1D format.
 
  
= barWidth =
+
(2) Because of some browsers issue, the ratio of camera screen can only show as default value. The camera screen would fill up the space as user defined.  
The barWidth is a integer attribute that deciding the single bar width of barcode image.  
 
  
<source lang="xml">
 
<barcode type="code128" barWidth="2"/>
 
</source>
 
Note: This attribute is only implement for 1D format.
 
  
 
= registerLibrary =
 
= registerLibrary =
Line 106: Line 94:
 
         }, 'library-name', ['type1', 'type2', ...]);
 
         }, 'library-name', ['type1', 'type2', ...]);
 
     });
 
     });
</source>
 
 
WEB-INF/lang-addon.xml
 
<source lang="xml">
 
    <javascript src="mybarcodeLibrary.js">
 
    <javascript src="myRegister.js">
 
 
</source>
 
</source>
  
Line 118: Line 100:
 
{| border="1" | width="100%"
 
{| border="1" | width="100%"
 
! <center>Name</center>
 
! <center>Name</center>
! <center>Barcode Type</center>
+
! <center>BarScanner Type</center>
 
|-
 
|-
 
| 1D   
 
| 1D   
 
|  
 
|  
CODE39, CODE128, CODE128A, CODE128B, CODE128C, EAN13, EAN8, EAN5, EAN2, UPC, ITF14,ITF, MSI, MSI10, MSI11, MSI1010, MSI1110, PHARMACODE, CODABAR
+
CODE128, EAN, EAN8, CODE39, CODE39VIN, CODEBAR, UPC, UPC_E, I2OF5
  
 
|-
 
|-
Line 151: Line 133:
 
! Version !! Date !! Content
 
! Version !! Date !! Content
 
|-
 
|-
| 8.5.2
+
| 8.6
| Apirl, 2018
+
| May, 2018
| <javadoc>org.zkoss.zkmax.barcode.Barcode</javadoc>
+
| <javadoc>org.zkoss.zkmax.barcode.BarScanner</javadoc>
 
|}
 
|}
  
 
{{ZKComponentReferencePageFooter}}
 
{{ZKComponentReferencePageFooter}}

Revision as of 03:58, 14 May 2018

BarScanner

Employment/Purpose

A barScanner component is used to scan and decode the barcode on the client side. There are many properties to dealing with the barScan component. First, you could use the type property to specify the type of barcode, for example: qr, code128, ..., after choose the type you want, you could scan the barcode by the scanner. You can choose the continue scanning by setting contScan="true", and setting the scan rate by setting scanRate="1", the unit of scanRate is sec/time. You can turn on the scanner switch by setting open="true", or close it by open="false".

Example

Qrcode.png

 <barScanner type="qr,code128" contScan="true" scanRate="0.5" height="100px"/>

type

The BarScanner has 9 types for 1D and 1 type for 2D by default. After choosing the type of barcode, and you can scan the barcode as the type you choose. You also can scan multiple types at one time, just setting type="xxx1,xxx2". For example

 <barScanner type="qr,code128"/>

Note: (1) The type that barScanner supported can be referenced as Supported Barcode Type (Default). (2) Warn: if too many types are set for the widget, it may reduce the detecting accuracy.

contScan

contScan is a boolean attribute to let the barScanner can continue scan or not.

 <barScanner type="qr" contScan="true"/>

scanRate

The scanRate is a subsidiary, integer attribute for contScan. The scanRate="0.5" means the scanner will scan once every 0.5 sec.

 <barScanner type="code128" contScan="true" scanRate="0.5"/>

open

The open is boolean attribute to switch the barScanner. You can use the zk mvvm mechanism to to switch the barScanner.

 <window viewModel="@id('vm')@init('xxxVM')">
 <barScanner type="code128" open= "@bind('vm.open')"/>

height, width

Height and width are string attributes to define the height and width of barScanner component.

 <barcode type="qr" height="100px", width="200px"/>

Note:

(1) height is a string as a format of "number+px"

(2) Because of some browsers issue, the ratio of camera screen can only show as default value. The camera screen would fill up the space as user defined.


registerLibrary

registerLibrary(function () {}, library_name, [array of types] ) is a client-side, class-level method to register a custom library into barcode widget. If you register the own custom library into Barcode, every single widget can use the custom library. The way to registering is zkmax.barcode.Barcode.registerLibrary(...). For example: you can register the library as the <zscript> below.

<?script src="mybarcodeLibrary.js"?>
<script>
    ...
    zk.afterLoad('zkmax.barcode', function () {
        zkmax.barcode.Barcode.registerLibrary(function mybarcode(wgt) {
            ...
             };
         }, 'library-name', ['type1', 'type2', ...]);
    });
    ...
</script>

Note:

(1) registerLibrary is the pure-client-side method.

(2) If you want to register the custom library for all the web application, you can add <javascript src="mybarcodeLibrary.js"/>the source file at WEB-INF/lang-addon.xml.

myRegister.js

    zk.afterLoad('zkmax.barcode', function () {
        zkmax.barcode.Barcode.registerLibrary(function mybarcode(wgt) {
            ...
             };
         }, 'library-name', ['type1', 'type2', ...]);
    });

Supported Barcode Type (Default)

Name
BarScanner Type
1D

CODE128, EAN, EAN8, CODE39, CODE39VIN, CODEBAR, UPC, UPC_E, I2OF5

2D

QR

Supported Children

*NONE

Use Cases

Version Description Example Location
     

Version History

Last Update : 2018/05/14


Version Date Content
8.6 May, 2018 BarScanner



Last Update : 2018/05/14

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.