TWAIN ActiveX Control, Plug-in, Scanner SDK, Component, HTTP Control/SDK

Dynamsoft TWAIN Products

Support Community for TWAIN Control/Component/SDK for Scanning Solutions
* Login   * Register
* FAQ    * Search

It is currently Sun May 20, 2012 2:02 pm




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Crop Method with Javascript
PostPosted: Mon Aug 30, 2010 5:01 am 
Offline

Joined: Mon Aug 30, 2010 4:14 am
Posts: 2
Hi,

I'm evaluating Dynamic Web Twain 6.0 and I can't get the Crop method to work using Javascript.
My code looks like this:
Code:
try {
   if (!dynamicWebTwain.Crop(0, 20, 20, 20, 20)) {
      alert ("failed: " + dynamicWebTwain.ErrorString + " code: " + dynamicWebTwain.ErrorCode);
   }
} catch (e) {
   alert ("ERROR: " + e);
}

dynamicWebTwain is the proper object for the plug-in or the activeX control and there is an image in buffer.
If I use the Plug-in with Firefox the Crop method returns false and the if-block is entered, but the error string is empty and the error code is 0.
If I use the ActiveX control with IE8 the crop method throws an exception without any description.

Regards,
Marc


Top
 Profile  
 
 Post subject: Re: Crop Method with Javascript
PostPosted: Tue Aug 31, 2010 11:49 am 
Offline
User avatar

Joined: Tue Mar 08, 2005 12:23 am
Posts: 1075
Hi Marc,

For info on how to use the Crop method, please refer to:
http://www.dynamsoft.com/help/TWAIN/Web ... 20Crop.htm

In the method, you need to set different values for the two pairs of parameters below:
Long left and Long right; Long top and Long bottom

To use the method more flexibly, you can call it in the event OnImageAreaSelected as below:
Code:
var index, iLeft, iTop, iRight, iBottom;
function DynamicWebTwain_OnImageAreaSelected(index, iLeft, iTop, iRight, iBottom)
{
   try {
         if (!DynamicWebTwain.Crop(index, iLeft, iTop, iRight, iBottom)) {
         alert ("failed: " + DynamicWebTwain.ErrorString + " code: " + DynamicWebTwain.ErrorCode);
   }
   }
    catch (e) {
         alert ("ERROR: " + e);
   }
}

<script language="javascript" type="text/javascript" event="OnImageAreaSelected(index, iLeft, iTop, iRight, iBottom)" for="DynamicWebTwain">
      <!--
         DynamicWebTwain_OnImageAreaSelected(index, iLeft, iTop, iRight, iBottom);
      //-->
</script>



Best regards.

_________________
Catherine Sea
TWAIN Support Team
TWAIN ActiveX/Plug-in for Web Applications, Scanner COM Control
TWAIN .NET Component/SDK for Desktop Applications

Follow me @Twitter, Facebook
Image


Top
 Profile  
 
 Post subject: Re: Crop Method with Javascript
PostPosted: Wed Sep 01, 2010 12:20 am 
Offline

Joined: Mon Aug 30, 2010 4:14 am
Posts: 2
Hi Catherine,

thanks for the reply. Using the same values for each corner is a bad idea, of course :?.
It works fine with the correct values.

Thanks & best regards.
Marc


Top
 Profile  
 
 Post subject: Re: Crop Method with Javascript
PostPosted: Wed Sep 01, 2010 6:52 pm 
Offline
User avatar

Joined: Tue Mar 08, 2005 12:23 am
Posts: 1075
Hi Marc,

Glad to know the method is working for you! :D

Should you need any further help, you can write us at TWAINSupport@dynamsoft.com

Best regards.

_________________
Catherine Sea
TWAIN Support Team
TWAIN ActiveX/Plug-in for Web Applications, Scanner COM Control
TWAIN .NET Component/SDK for Desktop Applications

Follow me @Twitter, Facebook
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

It is currently Sun May 20, 2012 2:02 pm


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron

Copyright © 2010 Dynamsoft Corporation. All Rights Reserved. | Knowledge Base | Source Control Blog