mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 04:01:52 +00:00
Dynamic Web TWAIN
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
function dwtOnReady() {
|
||||
let DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer'); // Get the Dynamic Web TWAIN object that is embeded in the div with id 'dwtcontrolContainer'
|
||||
if (DWObject) {
|
||||
var count = DWObject.SourceCount;
|
||||
if(count == 0)
|
||||
{
|
||||
DWObject.CloseSourceManager();
|
||||
DWObject.ImageCaptureDriverType = 0;
|
||||
DWObject.OpenSourceManager();
|
||||
count = DWObject.SourceCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function acquireImage() {
|
||||
let DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
|
||||
if (DWObject) {
|
||||
var OnAcquireImageSuccess, OnAcquireImageFailure;
|
||||
OnAcquireImageSuccess = OnAcquireImageFailure = function (){
|
||||
DWObject.CloseSource();
|
||||
};
|
||||
|
||||
DWObject.SelectSourceByIndex(0); //Use method SelectSourceByIndex to avoid the 'Select Source' dialog
|
||||
DWObject.OpenSource();
|
||||
DWObject.IfDisableSourceAfterAcquire = true; // Scanner source will be disabled/closed automatically after the scan.
|
||||
DWObject.AcquireImage(OnAcquireImageSuccess, OnAcquireImageFailure);
|
||||
}
|
||||
}
|
||||
|
||||
function registerEvent() {
|
||||
let DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
|
||||
if (DWObject) {
|
||||
// The event OnPostTransfer fires after each image is scanned and transferred
|
||||
DWObject.RegisterEvent("OnPostTransfer", function () {});
|
||||
|
||||
// The event OnPostLoad fires after the images from a local directory have been loaded into the control
|
||||
DWObject.RegisterEvent("OnPostLoad", function () {});
|
||||
|
||||
// The event OnMouseClick fires when the mouse clicks on an image on Dynamic Web TWAIN viewer
|
||||
DWObject.RegisterEvent("OnMouseClick", function () {});
|
||||
|
||||
// The event OnTopImageInTheViewChanged fires when the top image currently displayed in the viewer changes
|
||||
DWObject.RegisterEvent("OnTopImageInTheViewChanged", function (index: number) {
|
||||
DWObject.CurrentImageIndexInBuffer = index;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function editImage() {
|
||||
let DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
|
||||
if (DWObject) {
|
||||
if (DWObject.HowManyImagesInBuffer > 0)
|
||||
DWObject.RotateLeft(DWObject.CurrentImageIndexInBuffer);
|
||||
|
||||
if (DWObject.HowManyImagesInBuffer > 0)
|
||||
DWObject.RotateRight(DWObject.CurrentImageIndexInBuffer);
|
||||
|
||||
if (DWObject.HowManyImagesInBuffer > 0)
|
||||
DWObject.Mirror(DWObject.CurrentImageIndexInBuffer);
|
||||
|
||||
if (DWObject.HowManyImagesInBuffer > 0)
|
||||
DWObject.Flip(DWObject.CurrentImageIndexInBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
function showImageEditor() {
|
||||
let DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
|
||||
if (DWObject) {
|
||||
DWObject.ShowImageEditor();
|
||||
}
|
||||
}
|
||||
|
||||
function saveImage() {
|
||||
let DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
|
||||
if (DWObject) {
|
||||
DWObject.ConvertToGrayScale(DWObject.CurrentImageIndexInBuffer);
|
||||
DWObject.SaveAsJPEG("DynamicWebTWAIN.jpg", DWObject.CurrentImageIndexInBuffer);
|
||||
DWObject.SaveAllAsMultiPageTIFF("DynamicWebTWAIN.tiff", () => {}, (errorCode, errorString) => {});
|
||||
DWObject.SaveAllAsPDF("DynamicWebTWAIN.pdf", () => {}, (errorCode, errorString) => {});
|
||||
}
|
||||
}
|
||||
|
||||
function updateLargeViewer() {
|
||||
let DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
|
||||
let DWObjectLargeViewer = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainerLargeViewer');
|
||||
if (DWObject) {
|
||||
DWObject.CopyToClipboard(DWObject.CurrentImageIndexInBuffer); // Copy the current image in the thumbnail to clipboard in DIB format.
|
||||
DWObjectLargeViewer.LoadDibFromClipboard(); // Load the image from Clipboard into the large viewer.
|
||||
}
|
||||
}
|
||||
|
||||
function uploadImage() {
|
||||
let DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
|
||||
if (DWObject) {
|
||||
DWObject.HTTPPort = 80;
|
||||
DWObject.IfSSL = false;
|
||||
DWObject.HTTPUploadThroughPost("www.dynamsoft.com", DWObject.CurrentImageIndexInBuffer, "upload", "tmp.jpg", () => {}, (errorCode, errorString) => {});
|
||||
}
|
||||
}
|
||||
|
||||
function downloadImage() {
|
||||
let DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
|
||||
if (DWObject) {
|
||||
DWObject.HTTPPort = 80;
|
||||
DWObject.HTTPDownload("www.dynamsoft.com", "img.png", () => {}, (errorCode, errorString) => {});
|
||||
}
|
||||
}
|
||||
Vendored
+3457
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"dwt-tests.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user