國產操作系統的普及離不開軟件的支持。在自動化辦公方面,Dynamic Web TWAIN SDK已經可以支持目前主流的國產系統:銀河麒麟,中標麒麟,統信UOS。支持的CPU架構包括amd64, arm64和mips64。因此,要爲國產系統打造基於Web的電子文檔掃描管理軟件非常方便。
基於Web的文檔掃描應用
國產OS都是基於Linux。Linux通過SANE協議訪問文檔掃描儀。Dynamic Web TWAIN支持Windows, Linux和Mac上的所有掃描協議。
MIPS64 統信UOS
統信UOS必須激活開發者模式。
在線體驗
使用統信自帶瀏覽器訪問在線程序示例:https://demo3.dynamsoft.com/web-twain/。
首次打開會提示下載服務安裝包:
下載deb
文件。並通過命令行安裝:
sudo dpkg -i DynamsoftServiceSetup.deb
安裝之後打開頁面https://127.0.0.1:18623/
確認狀態。如果看到以下頁面,說明安裝成功:
接下來刷新在線示例頁面,可以獲得連接的掃描儀列表:
現在需要一個有效的序列號。可以在線申請一個30天免費試用的。
獲取之後打開開發者控制欄,輸入代碼:
DWObject.ProductKey="序列號"
現在可以點擊按鈕體驗在線文檔掃描了。
手動編寫
開發者可以集成SDK實現自己的Web程序。
下載Dynamic Web TWAIN的完整安裝包。
解壓之後把Resources
目錄整個拷貝出來,放到自己建的工程目錄下。新建一個index.html
文件:
<!DOCTYPE html>
<html>
<head>
<title>Use Dynamic Web TWAIN to Scan</title>
<script type="text/javascript" src="Resources/dynamsoft.webtwain.initiate.js"></script>
<script type="text/javascript" src="Resources/dynamsoft.webtwain.config.js"></script>
</head>
<body>
<select size="1" id="source" style="position: relative; width: 220px;"></select>
<input type="button" value="Scan" onclick="acquireImage();" />
<div id="doc-image"></div>
<script type="text/javascript">
// Get a free trial license key from https://www.dynamsoft.com/customer/license/trialLicense/?product=dwt
Dynamsoft.WebTwainEnv.ProductKey = "序列號";
Dynamsoft.WebTwainEnv.RegisterEvent('OnWebTwainReady', onReady);
var DWObject;
function onReady() {
Dynamsoft.WebTwainEnv.CreateDWTObject(document.getElementById('doc-image'), function (obj) {
DWObject = obj;
var count = DWObject.SourceCount;
for (var i = 0; i < count; i++)
document.getElementById('source').options.add(new Option(DWObject.GetSourceNameItems(i), i));
}, function (errorString) {
console.log(errorString)
});
}
function acquireImage() {
if (DWObject) {
var onSuccess, onFailure;
onSuccess = onFailure = function () {
DWObject.CloseSource();
};
DWObject.SelectSourceByIndex(document.getElementById('source').selectedIndex); //Use method SelectSourceByIndex to avoid the 'Select Source' dialog
DWObject.OpenSource();
DWObject.IfDisableSourceAfterAcquire = true; // Scanner source will be disabled/closed automatically after the scan.
DWObject.AcquireImage(onSuccess, onFailure);
}
}
</script>
</body>
</html>
注意修改序列號:
Dynamsoft.WebTwainEnv.ProductKey = "序列號";
保存之後在瀏覽器中打開就可以運行了:
MIPS64 銀河麒麟
測試用的銀河麒麟也是MIPS64的系統:
銀河麒麟用的是360瀏覽器,和統信UOS使用相同的操作沒有任何問題。
視頻
https://www.bilibili.com/video/BV1yX4y137mg/