VintaSoft Twain .NET SDK Discussions

Questions, comments and suggestions concerning VintaSoft Twain .NET SDK.

Board index < VintaSoft Twain < VintaSoft Twain .NET SDK Discussions

We are migrating to new forums engine, no new registration or posting currently available. TIA for your patience.

How to specifiy dimensions for scanning in ASP.NET MVC + HTML5 (using Local Service)



How to specifiy dimensions for scanning in ASP.NET MVC + HTML5 (using Local Service)

Post by varalonga »

Hi,


I'm having some troubles so I thought I could reach you guys for some help.
I've been using theTWAIN .NET SDK product on a ASP.NET MVC project using the
ASP.NET MVC + HTML5 approach (using Local Service) and I'm having some troubles with
the scanning process.
If I choose to scan using the Scanner native UI, I have always the preview tool and I always
have the chance to define the scan area. Our scanner allows to scan documents up to A3 size.
Still, when I try to scan documents withou the scanner UI, it seems that the documents are
always scanned in the A4 portrait size; therefore if I try to scan a document in A4 landscape
or A3, it will always end up being cropped.
I've noticed in the online documentation (e.g., https://www.vintasoft.com/docs/vstwain- ... _Disk.html) these two lines of code:

' set the inches as unit of measure
device.UnitOfMeasure = UnitOfMeasure.Inches
' set the desired resolution of acquired images
device.Resolution = New Resolution(300.0F, 300.0F)

Using the ASP.NET MVC + HTML5 approach is there any way of specifying these same properties
(or any other way) in javascript?
Thanks in advance.


kind regards,

VГ­tor Varalonga
Ciberbit, S.A.


Re: How to specifiy dimensions for scanning in ASP.NET MVC + HTML5 (using Local Service)

Post by Alex »

Hello VГ­tor,

You can get the capability value using the WebTwainDeviceJS.getDeviceCapability function, please see example here:
https://www.vintasoft.com/docs/vstwain- ... ility.html

You can set the capability value using the WebTwainDeviceJS.setDeviceCapability function, please see example here:
https://www.vintasoft.com/docs/vstwain- ... ility.html

For setting the unit of measure and image resolution you need to use the following JavaScript code:
function setUnitOfMeasureAndResolution(openedDevice, unitOfMeasure, resX, resY) {
    // success callback
    function __success(data) {
        // capability
        var capability = data.capability;
        // new value of capability
        var newValue = capability.currentValue.value;
        // log information about new value
        console.log("Capability '" + capability.name + "' new value - " + newValue);
    }

    // error callback
    function __error(data) {
        // message
        var message = "";
        // if capability exists
        if (data.capability != undefined)
            // add information about capability name
            message += "Capability '" + data.capability.name + "':";
        // add information about error
        message += data.errorMessage;
        // show message
        alert(message);
    }

    // change unit of measure
    openedDevice.setCapability(new Vintasoft.Twain.WebDeviceCapabilityIdJS("IUnits"), unitOfMeasure, __success, __error);
    // change horizontal resolution
    openedDevice.setCapability(new Vintasoft.Twain.WebDeviceCapabilityIdJS("IXResolution"), resX, __success, __error);
    // change vertical resolution
    openedDevice.setCapability(new Vintasoft.Twain.WebDeviceCapabilityIdJS("IYResolution"), resY, __success, __error);
}
Also please see code of Twain Device Capabilities dialog in source codes of AspNetMvc5Demos project:
"[InstallPath]\VintaSoft Imaging .NET v8.6\Examples\CSharp\AspNetMvc5Demos\Scripts\UI\Dialogs\Twain\twainDeviceCapabilitiesDialog.js"

Best regards, Alexander


Re: How to specifiy dimensions for scanning in ASP.NET MVC + HTML5 (using Local Service)

Post by LutherCo »

Hi,


I'm having some troubles so I thought I could reach * for some help.
I've been using theTWAIN .NET SDK product on a ASP.NET MVC project using the
ASP.NET MVC + HTML5 approach (using Local Service) and I'm having some troubles with
the scanning process.
If I choose to scan using the Scanner native UI, I have always the preview tool and I always
have the chance to define the scan area. Our scanner allows to scan documents up to A3 size.
Still, when I try to scan documents withou the scanner UI, it seems that the documents are
always scanned in the A4 portrait size; therefore if I try to scan a document in A4 landscape
or A3, it will always end up being cropped.
Hi Alex, I can't seem to set the capability value. When I do what is described, nothing happens. Any idea what my problem may be?


Re: How to specifiy dimensions for scanning in ASP.NET MVC + HTML5 (using Local Service)

Post by Alex »

Hello,
I can't seem to set the capability value. When I do what is described, nothing happens. Any idea what my problem may be? I have updated the example in previous post. Also we added example to documentation: https://www.vintasoft.com/docs/vstwain- ... ility.html

Please see the example, try to use it in your code and let me know if you will have any question or problem.

Best regards, Alexander


Page 1 from 1: 1