How to customize Dynamic Web TWAIN objects

Naming Dynamic Web TWAIN objects

By default, the (first) Dynamic Web TWAIN object named "DWObject". You should use Dynamic Web TWAIN any other property or method set before. A good place to do this is built-in functions Dynamsoft_OnReady . For example, in our Hello World example:

<html>
<head>
<title>Hello World</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>
<input type="button" value="Scan" onclick="AcquireImage();" />
<div id="dwtcontrolContainer"> </div>
<script type="text/javascript">
        var DWObject;
        function Dynamsoft_OnReady(){
            DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
        }
        function AcquireImage(){
            if(DWObject) {
                DWObject.IfDisableSourceAfterAcquire = true;
                DWObject.SelectSource();
                DWObject.OpenSource();
                DWObject.AcquireImage();
            }
        }
    </script>
</body>
</html>

id is 'dwtcontrolContainer' Dynamic Web TWAIN is the div placeholder. Its name and file size dynamsoft.webtwain.config.js definition, as shown below. If necessary, you can change it.

Dynamsoft.WebTwainEnv.Containers = [{ContainerId:'dwtcontrolContainer',Width:270,Height:350}];

Changing the size of the viewer

All you need to dynamsoft.webtwain.config.js change the vessel (built-in viewer) in size can be. Here you can use numbers or percentages. E.g

Dynamsoft.WebTwainEnv.Containers = [{ContainerId:'dwtcontrolContainer',Width: '50%',Height:350}];

Changing the appearance of installation tips

If Dynamic Web TWAIN is not installed, you will see this built-in interface that prompts the user to install the SDK

image015

In most cases, you may want to change the "Dynamsoft" brand logo. Here's how to achieve this goal:

'branding' in the file \ Resources \ reference \ hint.css definition.

.DYNLogo
    {
    background:url(logo.gif) left top no-repeat; 
    width:159px; 
    height:39px;
    }

As you can see, the following figure ( \ Resources \ Reference \ logo.gif ) is the file that you want to change. The easiest way is to replace it with their own flag, but keeping the same name and size.

image016

If you would like to change the style of this prompt, please feel free to change the CSS referred to above or change the file \ Resources \ dynamsoft.webtwain.install.js code.

function OnWebTwainNotFoundOnWindowsCallback(ProductName, InstallerUrl, bHTML5, bIE, bSafari, bSSL, strIEVersion) { }
    /* This callback is triggered when Dynamic Web TWAIN is not installed on a PC running Windows */
    function OnWebTwainNotFoundOnMacCallback(ProductName, InstallerUrl, bHTML5, bIE, bSafari, bSSL, strIEVersion) { }
    /* This callback is triggered when Dynamic Web TWAIN is not installed on a MAC */
    function OnWebTwainOldPluginNotAllowedCallback(ProductName) { }
    /* This callback is triggered when Dynamic Web TWAIN is disabled by a non-IE browser */
    function OnWebTwainNeedUpgradeCallback(ProductName, InstallerUrl, bHTML5, bMac, bIE, bSafari, bSSL, strIEVersion) { }
    /* This callback is triggered when Dynamic Web TWAIN installed on the machine is older than the //one on the server and upgrade is needed */

 

Released two original articles · won praise 4 · Views 4062

Guess you like

Origin blog.csdn.net/weixin_42320186/article/details/81134292