
1.如何获取黑白图像?
DWObject.OpenSource(); DWObject.IfShowUI = false; DWObject.IfDisableSourceAfterAcquire = true; DWObject.PixelType = EnumDWT_PixelType.TWPT_BW; //Black - White image : EnumDWT_PixelType.TWPT_BW, GRAY image: EnumDWT_PixelType.TWPT_GRAY, RGB image: EnumDWT_PixelType.TWPT_RGB DWObject.AcquireImage();
2.如何在没有用户界面的情况下运行?
function BeginScan(){
DWObject.OpenSource();
DWObject.IfShowUI = false; //set without user interface
DWObject.IfDisableSourceAfterAcquire = true;
DWObject.AcquireImage();
}
function DWObject_OnPostTransfer(){
DWObject.SaveAsBMP("C:\\temp.bmp",0);
}3.如何只扫描纸张的某一部分?
DWObject.SelectSource(); DWObject.OpenSource(); DWObject.IfShowUI = false; //Set Image Layout DWObject.Unit = EnumDWT_UnitType.TWUN_INCHES; DWObject.SetImageLayout(0, 0, 5, 5); DWObject.AcquireImage();
4.如何在不显示设备选择对话框的情况下选择设备?
DWObject.OpenSourceManager();
for(i = 0, i<=DWObject.SourceCount - 1,i++){
if (DWObject.GetSourceNameItems(i) == "Specified device name")
DWObject.SelectSourceByIndex (i);
}
//if can't find the specified source, it'll select default source
DWObject.AcquireImage(); 5.如何在不使用UI获取图像时禁用进度指示器对话框?
DWObject.IfShowUI = false; DWObject.IfDisableSourceAfterAcquire = true; DWObject.OpenSource(); DWObject.IfShowIndicator = false; DWObject.AcquireImage();
6.如何分别设置水平和垂直分辨率?
DWObject.SelectSource();
DWObject.OpenSource();
//Set XRESOLUTION current value.
DWObject.Capability = 0x1118; //ICAP_XRESOLUTION
DWObject.CapType = 5; //TWON_ONEVALUE
DWObject.CapValue = 300;
if (DWObject.CapSet == false){
alert( "Failed to set the x-resolution. " + DWObject.ErrorString);
}
//Set YRESOLUTION current value.
DWObject.Capability = 0x1119; //ICAP_YRESOLUTION
DWObject.CapType = 5; //TWON_ONEVALUE
DWObject.CapValue = 200;
if (DWObject.CapSet == false){
alert( "Failed to set the y-resolution." + DWObject.ErrorString);
}
DWObject.AcquireImage();7.如何上传到Web服务器?
DWObject = document.getElementById("dwtcontrolContainer");
//dwtcontrolContainer is the id of the Dynamic Web TWAIN on the page (An object or an embed).
function btnScan_onclick()
{
DWObject.SelectSource();
DWObject.OpenSource();
DWObject.AcquireImage();
}
function btnUpload_onclick()
{
var strActionPage;
var strHostIP;
var CurrentPathName = unescape(location.pathname); // get current PathName in
plain ASCII
var CurrentPath = CurrentPathName.substring(0, CurrentPathName.lastIndexOf("/")
+ 1);
strActionPage = CurrentPath + "SaveToFile.aspx"; //the ActionPage's file path
strHostIP = "localhost"; //The host's IP or name
DWObject.HTTPPort = 80;
DWObject.HTTPUploadThroughPost(strHostIP,0,strActionPage,"imageData.tif");
if (DWObject.ErrorCode != 0)
alert(DWObject.ErrorString);
else //succeed
alert("Image Uploaded successfully");
}8.如何使用ADF?希望将每个文档保存在一个单独的文件中。
var iDocumentCounter =0;
function BeginScan(){
DWObject.OpenSource();
DWObject.IfShowUI = false;
DWObject.IfDisableSourceAfterAcquire = true;
if(DWObject.Duplex != TWDX_NONE)
DWObject.IfDuplexEnabled = true; //enable duplex
DWObject.IfFeederEnabled = true;
if (DWObject.IfFeederEnabled == true){
DWObject.XferCount = -1;
if(DWObject.IfFeederLoaded == True)
DWObject.AcquireImage();
}
}
function DWObject_OnPosttransfer(){
iDocumentCounter = iDocumentCounter + 1;
if(DWObject.SaveAsBMP("C:\\Image\\" + iDocumentCounter + ".bmp", 0) == false)
alert( DWObject.ErrorString);
}9.我如何使用SSL?
您可以使用IfSSL属性。下面的JavaScript示例将显示如何使用IfSSL属性。
function btnUpload_onclick()
{
DWObject.HTTPPort = 80;
DWObject.IfSSL = false; // if 80 is the port number of
non-secure port
/*
DWObject.HTTPPort = 443;
DWObject.IfSSL = true; // if 443 is the port number of secure
port
*/
DWObject.HTTPUploadThroughPost("127.0.0.1", 0,
"/SaveToFile.php", "imageData.jpg");
if (DWObject.ErrorCode != 0)
alert(DWObject.ErrorString);
else //succeed
alert("Successful");
}10.如何将新扫描的图像添加到现有的多页TIFF文件中?
function Scan_Click(){
DWObject.AcquireImage();
}
function DWObject_OnPostTransfer(){
DWObject.CloseSource();
DWObject.IfTiffMultiPage = true;
DWObject.SaveAsTIFF("SaveAsTIFF.tif", 0);
if (DWObject.ErrorCode != 0)
alert (DWObject.ErrorString);
else //succeed
alert ("Successful");
}11.如何在保存之前旋转图像?
您可以使用RotateLeft方法和RotateRight方法。
12.如果缓冲区中有多个图像,如何查看指定的图像?
您可以通过更新API CurrentImageIndexInBuffer的值来查看指定的图像或浏览缓冲区中的所有图像。
function NextImage_Click(){
if (DWObject.HowManyImagesInBuffer == 0)
alert ("There is no image in buffer");
DWObject.CurrentImageIndexInBuffer += 1;
}
13.如何进行双面扫描?
function DuplexScan_Click(){
DWObject.SelectSource();
DWObject.OpenSource();
DWObject.IfShowUI = false;
DWObject.IfDuplexEnabled = true; //enable duplex
DWObject.AcquireImage();
} 14.如何以反转颜色扫描图像?
您可以使用PixelFlavor属性。
回复 (0)
微信扫码 立即评论


