Skip to content

Anyline/anyline-ocr-anylinejs-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

160 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Anyline Web SDK

npm version License

Anyline Web SDK enables OCR and barcode scanning directly in the browser.

Live Demo | Documentation | API Reference

Supported Use Cases

  • Barcode - QR Code, Data Matrix, Aztec, PDF417, Code 128, EAN, UPC, and more
  • ID Scanning - MRZ (passports, ID cards) and driving licenses
  • Tire & Automotive - VIN, TIN, tire size, license plates
  • Meters - Analog, digital, and dial meters
  • OCR - Shipping containers and custom OCR

See the documentation for the full list of supported formats and regions.

Installation

npm install @anyline/anyline-js

Or via CDN:

<script src="https://cdn.jsdelivr.net/npm/@anyline/anyline-js/anyline.js"></script>

Quick Start

HTML:

<div id="scanner-root" style="width: 100%; height: 100vh;"></div>

TypeScript/JavaScript:

import { init } from '@anyline/anyline-js';

// Initialize the scanner
const anyline = init({
  // Your Anyline license key (obtain at anyline.com/request/contact)
  license: 'YOUR_LICENSE_KEY',
  // DOM element where the scanner will be mounted
  element: document.getElementById('scanner-root'),
  // Preset for the scan type (see documentation for all presets)
  preset: 'vin',
});

// Handle scan results
anyline.onResult = ({ result }) => {
  console.log('Scanned:', result);
};

// Start the camera and begin scanning
anyline.startScanning().catch((error) => {
  console.error('Failed to start:', error);
});

// Clean up resources when done
window.addEventListener('beforeunload', () => {
  anyline.dispose();
});

Note: Web SDK requires HTTPS (except localhost) and camera permissions. The browser will prompt the user to allow camera access.

For available presets and configuration options, see the Getting Started Guide.

Self-Hosting Assets

By default, the SDK loads assets from Anyline's CDN. To self-host these assets for better performance or to comply with network restrictions:

  1. Copy the anylinejs/ folder to your web server
  2. Set the anylinePath option to point to the folder location
const anyline = init({
  license: 'YOUR_LICENSE_KEY',
  element: document.getElementById('scanner-root'),
  preset: 'vin',
  anylinePath: '/path/to/anylinejs',
});

See Performance Optimization for CDN configuration and caching details.

Documentation

Try it Locally

The package includes a demo application. To run it:

  1. Request a test license for your domain
  2. Edit your hosts file to route your domain to localhost (licenses are domain-restricted)
  3. Run the demo:
npm run demo
  1. Visit http://yourdomain.com:8080/demo

For smartphone testing over the network (HTTPS on port 8443):

npm run demo:network

Open https://<your-ip>:8443/ on your phone and accept the self-signed certificate warning, then choose the demo folder for running demo.

Package Contents

  • anylinejs/ - Assets for self-hosting
  • docs/ - API documentation
  • types/ - TypeScript type definitions
  • anyline.js - Main SDK library
  • LICENSE.md - Third-party license agreements

Resources

License

This SDK requires a commercial license from Anyline. Request a trial license to get started.

See LICENSE.md for third-party license agreements.

About

AnylineJS

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors