Dynamsoft / Dynamic-Web-TWAIN

Dynamic Web TWAIN for package managers
Other
66 stars 24 forks source link

GetWebTwain returns null if Load isn't used before #6

Closed occult closed 4 years ago

occult commented 4 years ago

If I use the code example on your site such as

handleClick() {

    Dynamsoft.WebTwainEnv.ProductKey="BB5378854D6D60CF72FD5D6EB92FB925A9204E14C7E80A7E504E707255412B0E90042463C14F5EB3BF4060D7ABE5ED65F60419A097E8B9DF29DE644BB84E68AC6720F03518D5B8AE794DE04BB0E22FB5ABB2982DDA0E2D9CB0236A286977A11762C537F9CBC6F4F707C60E92";

    var dwObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');

    var bSelected = dwObject.SelectSource();

    if (bSelected) {

      var onAcquireImageSuccess = function() { dwObject.CloseSource(); };

      var onAcquireImageFailure = onAcquireImageSuccess;

      dwObject.OpenSource();

      dwObject.AcquireImage({}, onAcquireImageSuccess, onAcquireImageFailure);

    }

  }

dwObject will return null. However, if I run Dynamsoft.WebTwainEnv.Load(); before clicking on the button, it will work.

I found the Dynamsoft.WebTwainEnv.Load(); on another website and have only seen it once in the documentation.

Why doesn't the official documentation include the load? or am I missing something?

Thank you so much!! Besides that, this SDK is excellent.

yushulx commented 4 years ago

@occult thanks for your feedback. Can you provide the web page in which you found the code?

I've looked up the issue. Please check out my comments.

When should you use Dynamsoft.WebTwainEnv.Load();?

If Dynamsoft.WebTwainEnv.AutoLoad = false;, you need to manually load the TWAIN component.

Dynamsoft.WebTwainEnv.Load()

The default AutoLoad property value

If you install Dynamic Web TWAIN locally, you will get the resource folder.

Annotation 2019-12-06 075946

In dynamsoft.webtwain.config.js, you can see Dynamsoft.WebTwainEnv.AutoLoad = true;.

Annotation 2019-12-06 081816

In our official documentation, the SDK is used as follows:

<head>
    <script type="text/javascript" src="Resources/dynamsoft.webtwain.initiate.js"></script>
    <script type="text/javascript" src="Resources/dynamsoft.webtwain.config.js"></script>
</head>

Alternatively, you can import the online JS source if you don't want to download the installer:

<head>
    <script type="text/javascript" src="https://unpkg.com/dwt/dist/dynamsoft.webtwain.min.js"> </script>
</head>

Open the JS file to check the AutoLoad status:

Annotation 2019-12-06 081200

The value is false.

Currently, I don't know why they are different. I'll confirm the issue with our R&D team.

occult commented 4 years ago

Thank you so much! You’re correct. I had this setting, but I thought it was for something else.


From: Xiao Ling notifications@github.com Sent: Thursday, December 5, 2019 9:30 PM To: Dynamsoft/Dynamic-Web-TWAIN Cc: Felipe Braga; Mention Subject: Re: [Dynamsoft/Dynamic-Web-TWAIN] GetWebTwain returns null if Load isn't used before (#6)

@occulthttps://github.com/occult thanks for your feedback. Can you provide the web page in which you found the code?

I've looked up the issue. Please check out my comments.

When should you use Dynamsoft.WebTwainEnv.Load();?

If Dynamsoft.WebTwainEnv.AutoLoad = false;, you need to manually load the TWAIN component.

Dynamsoft.WebTwainEnv.Load()

The default AutoLoad property value

If you install Dynamic Web TWAIN locally, you will get the resource folder.

[Annotation 2019-12-06 075946]https://user-images.githubusercontent.com/2202306/70284497-2a2e5400-17ff-11ea-934f-d319639ff4ee.png

In dynamsoft.webtwain.config.js, you can see Dynamsoft.WebTwainEnv.AutoLoad = true;.

[Annotation 2019-12-06 081816]https://user-images.githubusercontent.com/2202306/70285003-0409b380-1801-11ea-8a5b-f85622ebb9c3.png

In our official documentation, the SDK is used as follows:

Alternatively, you can import the online JS source if you don't want to download the installer:

Open the JS file to check the AutoLoad status:

[Annotation 2019-12-06 081200]https://user-images.githubusercontent.com/2202306/70284972-e9cfd580-1800-11ea-9098-45f74748e7d0.png

The value is false.

Currently, I don't know why they are different. I'll confirm the issue with our R&D team.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Dynamsoft/Dynamic-Web-TWAIN/issues/6?email_source=notifications&email_token=ABXLBQO5MKV6WWR6Q44RLBDQXGMLRA5CNFSM4JV2ESW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGCTWVI#issuecomment-562379605, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABXLBQJVTSR5BLZSMH2726TQXGMLRANCNFSM4JV2ESWQ.