Dynamic Web TWAINTWAIN掃描識別工具添加文本到圖像
Dynamic Web TWAIN 是應用於Web應用程序的TWAIN掃描識別工具,只需在TWAIN接口寫幾行代碼,就可以用兼容TWAIN的掃描儀掃描文檔或從數碼相機/採集卡中獲取圖像,並對採集下來的圖像進行處理。
版本支持
Dynamic Web TWAIN各版本v7及以上
語法
Boolean ObjectName.AddText(Short ImageIndex, Int x, Int y, String Text, Int TextColor, Int
BackgroundColor, float BackgroundRoundRadius, float BackgroundOpacity)
參數
Short ImageIndex:目標圖像索引
Int x:文本的X座標
Int y:文本的Y座標
String Text:要添加的文本
Int TextColor:文本顏色
Int BackgroundColor:背景色
float BackgroundRoundRadius:範圍是0到0.5;注:Mac版不支持這個參數。
float BackgroundOpacity:指定添加文本背景的不透明度,範圍是0到1.0;注意:Mac版支持0到1。
返回值
Boolean:True表示成功,FALSE表示失敗
標記
IfThrowException屬性爲True時,發生錯誤時會拋出一個異常。當返回FALSE或拋出異常時,檢查 ErrorCode 屬性和ErrorString屬性獲取錯誤信息。
示例
下面是一個JavaScript示例:
<script language="javascript"type="text/javascript">
DWObject = document.getElementById("iDynamicWebTwain");//iDynamicWebTwain is the id of the Dynamic Web TWAIN on the page (An object or an embed).
functionbtnAddText_ {
DWObject.AddText(
DWObject.CurrentImageIndexInBuffer,
document.getElementById("addText_Left").value,//Value for setting the x coordinate for the text
document.getElementById("addText_Top").value,//Value for setting the y coordinate for the text
document.getElementById("addText_Text").value,//The text to be added
document.getElementById("addText_TxtColor").value,//The color of the text
document.getElementById("addText_BgColor").value,//The background color of the text
document.getElementById("addText_BGRoundRadius").value,//The value for the background radius
document.getElementById("addText_BGOpacity").value//The value for the background opacity
);
}
</script>