Overview
Web API Barcode Reader (WaBR) extends Inlite’s ClearImage barcode recognition technology to cloud-based imaging applications.
WaBR Server implements server-side RESTful API for barcode reading.
It is pre-configured Web site, licensed by Inlite, for deployment on a customer-owned Windows Server with IIS
Step-by-Step
1- Install WaBR Server and Evaluation license
- Download and install the latest ClearImage SDK from http://www.inliteresearch.com/cisdk
- Install the WaBR server using these instructions
- Request a WaBR evaluation license from support@inliteresearch.com
2 – Test your images on the WaBR Server
- Go to WaBR Server test page http://localhost/wabr
- Use the
file
orurl
as image source to read barcodes from your images. Start with sample image listed below.
- If WaBR fails to read your barcode try, try uploading your image to Inlite’s Online Barcode Reader. If that reader succeeds, then set the
tbr
field to value 103, and read again. .
If the barcode is still unreadable or you want read barcodes faster or you have any other questions send the image file or image URL to support@inliteresearch.com and we will advise further.
3 – Develop client-side code or use Command Line EXE
- Use JavaScript sample or one of client SDK ( .NET, Java, Node JS, PHP, Python and Ruby) to develop your client side code. Each SDK comes with source code that can be adopted to your requirements.
- Send requests to your WaBR Server endpoint
Alternatively use BarcodeReaderCL.exe. This is a Windows command line application client to any WaBR Server. Download BarcodeReaderCL.zip from here.
4 – Start Production use
- Purchase a WaBR Server License and the appropriate SDK Server License (1D, 2D, 1D+2D, or DL/ID)
- Install ClearImage PDK and register the purchased product certificates (both will be supplied in an e-mail after the purchase)
- Restart IIS Server
WaBR API
Endpoints
The following endpoints read barcodes from various sources. All optional reader parameters can be used with each endpoint.
/barcodes |
POST request using any combination of url , file and image parameters as an image source |
/barcodes/url | GET request using url parameter as an image source |
/barcodes/file |
POST request using file parameter as an image source |
/barcodes/base64 | POST request using image parameter as an image source |
Image source parameters
At least one image source should be specified. Most popular image formats are acceptable as image source, including PDF, TIF, JPEG etc. Multi-page PDF and TIF files are supported
url
– URL of an image file. The name should start with http:// , https:// or file://. Examples:
https://wabr.inliteresearch.com/SampleImages/1d.pdf https://upload.wikimedia.org/wikipedia/commons/0/07/Better_Sample_PDF417.png
url
value supplied as query parameter if GET request should be url-encoded. (e.g. use encodeURIComponent() in JavaScript)
file
– Local file supplied in POST request . JavaScript examples:
formData.append('file[]', "\\COMPUTER_NAME\another_folder\another_file.pdf","another_file.pdf"); formData.append('file[]', "c:/image_folder/some_image_file.tif","some_image_file.tif")
image
– Base64-encoded string representing content of an image file. Example:
data:application/pdf;base64,WTTVKM3OWFKFMERCMT5... :::IMAGE_FILE.PDFFormat :
[data:[MIME-type][;base64],]content[:::filename]
Only content
, representing file content encoded as base64, is required. The values in [ ] are optional.
The values in italic are variables.
MIME-type
identifies file format. e.g. application/pdf or image/tiff. The value is only for compatibility with data URI scheme.
The barcode reader will automatically identify file format based on data in content
.
Optional reader parameters
String parameters are not case-sensitive and might contain the list of comma-separated values. If parameter not specified, default value is used.types
- Barcode types to read. Default value is 1d
, 2d
. Valid values are:
1d | same as code39 , code128 , code93 , ucc128 , codabar , interleaved2of5 , upca , upce , ean8 , ean13 |
code39 | Code 39 Full ASCII |
code128 | Code 128 |
code93 | Code 93 |
codabar | Codabar |
ucc128 | GS1-128 |
interleaved2of5 |
Interleaved 2 of 5 |
ean13 | EAN-13 |
ean8 | EAN-8 |
upca | UPC-A |
upce | UPC-E |
2d | same as pdf417 , datamatrix , qr |
pdf417 | PDF417 code |
datamatrix | DataMatrix code |
qr | QR code |
drvlic | Driver License, ID Cards and military CAC ID |
postal | same as imb , bpo , aust , sing , postnet |
imb | US Post Intelligent Mail Barcode |
bpo | UK Royal Mail barcode (RM4SCC) |
aust | Australia Post barcode |
sing | Singapore Post barcode |
postnet | Postnet, Planet |
code39basic | Code 39 Basic |
patch | Patch code |
format
- Identifies output format. Default value is json
. Valid values:
xml | XML-formatted result |
json |
JSON-formatted result (default) |
fields
- Identifies elements of barcode information present in output. Default: value is all fields except meta
. Valid values:
text | Barcode value as text (UTF-8 formatted) |
data | Un-formatted barcode value as Base64 string. This value should be used to obtain binary content of barcode. |
values | List of values obtain after parsing barcode content. For example Driver License fields |
length | Length of un-formatted barcode value |
type | Barcode type (also called symbology) |
rectangle | Position of barcode on a page (in pixels) |
rotation | Barcode orientation |
file | Name of the file |
page | Page number in a file |
meta | Technical information about barcode |
options
- Additional options: Default: no options
horz | read only horizontal barcodes. |
vert | read only vertical barcodes. |
info | return additional information about WaBR server |
tbr
- Target Barcode Reader code(s). Default: no TBR code
tbr
value 103 (used by Inlite’s Online Barcode Reader).
If your barcode is still unreadable, you want read barcodes faster or you have any other questions send the image file or image URL to support@inliteresearch.com and we will advise further.
JavaScript WaBR example
The following examples demonstrate the basic techniques to read barcodes from an image file or URL page. Try it here
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
<!DOCTYPE html><html><head> <script type="text/javascript" src="https://code.jquery.com/jquery-latest.min.js"></script> <title>WaBR Javascript API</title></head> <body><p/> URL<input id="url" size=80 type="text" value="https://wabr.inliteresearch.com/SampleImages/1d.pdf" /><input id="read_url" type="button" value="Submit" onclick="read_url_onclick()" /><p/> FILE(s):<input id="files" type="file" name="file[]" multiple /><input id="read_file" type="button" value="Submit" onclick="read_files_onclick()" /><p/> base64:<input id="file_base64" type="file" /><input id="read_base64" type="button" value="Submit as Base64" onclick="read_base64_onclick()" /><p/><textarea id="result" rows="10" cols="90">Result will be displayed here</textarea> <script type='text/javascript'>// WaBR server endpoint// For Inlite's WaBR Test Server: "https://wabr.inliteresearch.com/barcodes"// For production: Replace with your in-house WaBR server endpoint or Inlite's WaBR SaaS server enddpointvar server = "https://wabr.inliteresearch.com/barcodes"; // Optional. Required to read all barcode data using WaBR Test Server and aBR SaaS Server var auth = "YOUR_AUTHORIZATION_CODE"; // Optional. List of barcode types to read// Selecting specific values optimizes WaBR performance// Valid values are listed at http://how-to.inliteresearch.com/web-api-barcode-reader/#typesvar types = ""; // e.g. "Code39,Code128" reads only Code39 and Code128 barcodes// Optional. Other WABR options listed at http://how-to.inliteresearch.com/web-api-barcode-reader/#Optional-reader-parametersvar tbr = "";var options = "";var format = ""; function formDataOptions() { var formData = new FormData(); if (types !== "") formData.append("types", types); if (tbr !== "") formData.append("tbr", tbr); if (options !== "") formData.append("options", options); if (format !== "") formData.append("format", format); return formData;} function queryOptions() { var s = ""; if (types !== "") s += "&types=" + types; if (tbr !== "") s += "&tbr" + tbr; if (options !== "") s += "&options" + options; if (format !== "") s += "&format" + format; return s;} function parseJson(obj) { if (obj.Barcodes.length === 0) return "No barcodes found"; var result = "", tab = " ", nl = "\n"; for (var i = 0; i < obj.Barcodes.length; i++) { var objBarcode = obj.Barcodes[i]; result += "Barcode # " + (i + 1) + nl; result += tab + "Text = " + objBarcode.Text + nl; result += tab + "Type = " + objBarcode.Type + tab + "Length = " + objBarcode.Length + tab + "Rotation = " + objBarcode.Rotation + nl; result += tab + "Data (base64) = '" + objBarcode.Data + "'" + nl; result += tab + "Rect (l:t-r:b) = " + objBarcode.Left + ":" + objBarcode.Top + " - " + objBarcode.Right + ":" + objBarcode.Bottom + nl; result += tab + "File = " + objBarcode.File + tab + "Page = " + objBarcode.Page + nl; if (objBarcode.Meta !== undefined) result += tab + "Meta = " + objBarcode.Meta + nl; if (objBarcode.Values !== undefined) { result += tab + "Values" + nl; var objValues = objBarcode.Values; var keys = Object.keys(objValues); if (keys.length == 1) { var obj2 = objValues[keys[0]]; var keys2 = Object.keys(obj2); for (var j = 0; j < keys2.length; j++) { var obj3 = obj2[keys2[j]]; result += tab + tab + keys2[j] + " = " + obj3 + nl; } } } } return result;} function proc_error(jqXHR, textStatus, errorThrown) { if (jqXHR.status === 0) return "CORS error or server URL is not resolved: " + server; var tab = " "; return "STATUS: " + jqXHR.status + tab + textStatus + tab + errorThrown + tab + jqXHR.responseText;} function read_url_onclick() { try { var result = document.getElementById('result'); result.value = "Processing 'read_url_onclick'"; var url = document.getElementById('url').value; if (url.length === 0) { alert('Set valid URL value'); return; } $.ajax({ url: server + "?url=" + encodeURIComponent(url) + queryOptions(), headers: { // Optional. Required to read all barcode data using WaBR Test Server 'Authorization': auth } }).success(function(json) { result.value = parseJson(json); }) .fail(function(jqXHR, textStatus, errorThrown) { result.value = proc_error(jqXHR, textStatus, errorThrown); }); } catch (err) { result.value = "ERROR: " + err.message; }} function read_files_onclick() { try { var result = document.getElementById('result'); result.value = "Processing 'read_files_onclick'"; var files = document.getElementById('files').files; if (files.length === 0) { alert('Select files'); return; } var formData = formDataOptions(); for (var i = 0; i < files.length; i++) { var file = files[i]; formData.append('file[]', file, file.name); } $.ajax({ url: server, type: "post", data: formData, headers: { // Optional. Required to read all barcode data using WaBR Test Server 'Authorization': auth }, processData: false, contentType: false }).success(function(json) { result.value = parseJson(json); }) .fail(function(jqXHR, textStatus, errorThrown) { result.value = proc_error(jqXHR, textStatus, errorThrown); }); } catch (err) { result.value = "ERROR: " + err.message; }} function read_base64_onclick() { try { var result = document.getElementById('result'); result.value = "Processing 'read_files_onclick'"; // see http://blog.teamtreehouse.com/uploading-files-ajax var file = document.getElementById('file_base64').files[0]; if (file === undefined) { alert('Select file'); return; } var fileReader = new FileReader(); fileReader.onload = function(e) { var base64 = "data:" + file.type + e.target.result + ":::" + file.name; var formData = formDataOptions(); formData.append('image', base64); $.ajax({ url: server, type: "post", data: formData, headers: { // Optional. Required to read all barcode data using WaBR Test Server 'Authorization': auth }, processData: false, contentType: false }).success(function(json) { result.value = parseJson(json); }) .fail(function(jqXHR, textStatus, errorThrown) { result.value = proc_error(jqXHR, textStatus, errorThrown); }); }; fileReader.readAsDataURL(file); } catch (err) { result.value = "ERROR: " + err.message; }}</script> </body></html>
Sample Images
In order to simplify your rapid WaBR evaluation, development, deployment and testing Inlite provides a set of sample Images (see list below) with multiple symbologies and content.
The images can be used from either your client-side code or from the Inlite Test Web Page.
The same images are included in your Web Server installation Kit to facilitate testing in your secure environment.
- To test a URL, include the link in your GET or POST request
- To test a file or base64 upload, first download the images to your client, then use them in the POST request.
https://www.dropbox.com/s/qcd8zfdvckwwdem/img39.pdf?dl=1
https://wabr.inliteresearch.com/SampleImages/1d.pdf
https://wabr.inliteresearch.com/SampleImages/2d.pdf
https://wabr.inliteresearch.com/SampleImages/postal.pdf
https://wabr.inliteresearch.com/SampleImages/drvlic.ca.jpg
https://wabr.inliteresearch.com/SampleImages/c39.multipage.tif
https://wabr.inliteresearch.com/SampleImages/I25.tbr132.jpg
https://wabr.inliteresearch.com/SampleImages/pdf417.adobe.pdf
https://wabr.inliteresearch.com/SampleImages/pdf417.utf8.pdf
https://wabr.inliteresearch.com/SampleImages/pdf417.ЙшзщЪфг_Russian.pdf
https://wabr.inliteresearch.com/SampleImages/pdf417.بساطة لأنه الأل_Arabic.pdf
Output Examples
Reading 1D barcode with with types
set to code39,code128
:
{ "Barcodes": [ { "Text": "Code 39", "Data": "Q29kZSAzOQ==", "Type": "Code39", "Length": 7, "Page": 1, "Rotation": "none", "Left": 895, "Top": 124, "Right": 1839, "Bottom": 384, "File": "https://wabr.inliteresearch.com/SampleImages/1d.pdf" }, { "Text": "Code 128", "Data": "Q29kZSAxMjg=", "Type": "Code128", "Length": 8, "Page": 1, "Rotation": "none", "Left": 91, "Top": 128, "Right": 762, "Bottom": 388, "File": "https://wabr.inliteresearch.com/SampleImages/1d.pdf" } ] }
Reading Pdf417 with UTF-8 encoded data with with types
set to pdf417
:
{ "Barcodes": [ { "Text": "Lorem Ipsum - это текст-\"рыба\", часто используемый в печати и вэб-дизайне. Lorem Ipsum является стандартной \"рыбой\" для текстов на латинице с начала XVI века. В то время некий", "Data": "TG9yZW0gSXBzdW0gLSDRjdGC0L4g0YLQtdC60YHRgi0i0YDRi9Cx0LAiLCDRh9Cw0YHRgtC+INC40YHQv9C+0LvRjNC30YPQtdC80YvQuSDQsiDQv9C10YfQsNGC0Lgg0Lgg0LLRjdCxLdC00LjQt9Cw0LnQvdC1LiBMb3JlbSBJcHN1bSDRj9Cy0LvRj9C10YLRgdGPINGB0YLQsNC90LTQsNGA0YLQvdC+0LkgItGA0YvQsdC+0LkiINC00LvRjyDRgtC10LrRgdGC0L7QsiDQvdCwINC70LDRgtC40L3QuNGG0LUg0YEg0L3QsNGH0LDQu9CwIFhWSSDQstC10LrQsC4g0JIg0YLQviDQstGA0LXQvNGPINC90LXQutC40Lk=", "Type": "Pdf417", "Length": 290, "Page": 1, "Rotation": "none", "Left": 23, "Top": 21, "Right": 959, "Bottom": 523, "File": "https://wabr.inliteresearch.com/SampleImages/pdf417.ЙшзщЪфг_Russian.pdf" } ] }
Reading driver license barcode with fields
set to values
:
{ "Barcodes": [ { "Values": { "AAMVA": { "last": "Sample", "first": "Samantha", "middle": "Jane", "dob": "1974-01-01", "eyes": "BLU", "hair": "BN", "sex": "F", "height": "5'7\"", "weight": "135 lbs", "street": "1801 W Jefferson St", "city": "Phoenix", "state": "AZ", "postal": "85007-3289", "id": "D01404860", "issued": "2001-06-28", "expires": "2039-01-01" } } } ] }
Reading driver license barcode with fields
set to values
and format
set to xml
:
<Results xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Barcodes>
<Barcode>
<Values>
<AAMVA>
<last>Sample</last>
<first>Susan</first>
<dob>1970-12-12</dob>
<eyes>BR</eyes>
<hair>BR</hair>
<sex>F</sex>
<height>5'11"</height>
<weight>121 lbs</weight>
<street>P.O. Box 1272 Room 2120</street>
<city>Little Rock</city>
<state>AR</state>
<postal>72205</postal>
<id>999000680</id>
<issued>2003-01-30</issued>
<expires>2006-12-12</expires>
</AAMVA>
</Values>
</Barcode>
</Barcodes>
</Results>
WaBR Server System Requirements
- OS: Windows 7 or later, Windows Server 2008 or later.
Preferred: Windows Server 2012 r2 or later - Architecture: x86 or x64
Preferred: x64 - CPU: 1GHz or faster
Preferred: 3GHz or faster, 4 CORE - RAM Memory: 4GB or more
Preferred: 8GB or more - IIS: v7.5 or later