adf-plugin-hwsheet

1.0.0 • Public • Published

ADF HWSheet Plugin

スマートデバイスの画面にユーザーが筆記した文字を認識し、データとして画面上に反映する機能を提供します。

導入方法

cordova plugin add adf-plugin-hwsheet

対応OS

  • Android
  • iOS
  • Windows

使用例

index.html

<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

<body>
    <div id="hw-sheet-parent" style="width:800px;height:450px"></div>
    <script type='text/javascript' src='cordova.js'></script>
    <script type='text/javascript' src='index.js'></script>
</body>

</html>

index.js

document.addEventListener('deviceready', function () {
    var hwSheetDivElement = document.getElementById('hw-sheet-parent');
    readBackgroundImage('img/bgImage.png', function (backgroundImageElement) {
        var xhr = new XMLHttpRequest();
        xhr.open('get', 'json/hw_sheet.conf', true);
        xhr.send();
        xhr.onload = function () {
            // レイアウト定義ファイルに記載されたJSONをオブジェクト化
            var hwSheetConf = JSON.parse(xhr.responseText);
            // 文字認識エンジンの初期化
            HWSheet.Engine.init(function () {
                // ライブラリの初期化
                hw = new HWSheet(hwSheetDivElement, backgroundImageElement, hwSheetConf);
                window.addEventListener('resize', function () {
                    hw.resize();
                });
            }, error);
        };
    });

    function error(msg) {
        console.log(msg);
    }
});

function readBackgroundImage(imageUrl, successCallback, errorCallback) {
    'use strict';
    var image = new Image();

    image.onload = function () {
        successCallback(image);
    };
    image.onerror = function () {
        errorCallback('Image file "' + imageUrl + '" is not found.');
    };
    image.src = imageUrl;
}

json/hw_sheet.conf

{
    "layout": {
        "Field1": {
            "top": 50,
            "bottom": 100,
            "left": 50,
            "right": 250,
            "fieldType": "text",
            "recognizeType": "text_all",
            "maxChar": 10
        }
    }
}

Readme

Keywords

none

Package Sidebar

Install

npm i adf-plugin-hwsheet

Weekly Downloads

2

Version

1.0.0

License

EULA

Unpacked Size

50.3 kB

Total Files

6

Last publish

Collaborators

  • hashimotoyuta