### Serve the Vue Project Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/indepth/development/vue.md Run this command in your project's root directory to start the development server. Ensure you have installed the necessary packages. ```cmd yarn serve ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/deploy-your-own-upload-server-with-jsp.md Install all necessary Node.js packages for the project. This command should be run from the Sample directory. ```bash npm install ``` -------------------------------- ### Basic Web TWAIN Integration with Image Acquisition Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/general-usage/image-processing/buffer-management.md A sample HTML structure demonstrating basic Web TWAIN setup, including event registration, getting the DWT object, and acquiring an image. This serves as a foundation for implementing buffer management features. ```html





``` -------------------------------- ### Install Dynamsoft Service using MSIEXEC Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/service-installation-issue.md This command installs the Dynamic Web TWAIN Service silently using msiexec. Ensure you replace '/path/to/...' with the actual path to your service installer file. This method bypasses the standard installer GUI. ```shell msiexec /i "/path/to/DynamsoftServiceSetup.msi" /qn ``` ```shell msiexec /i "/path/to/DynamicWebTWAINServiceSetup.msi" /qn ``` -------------------------------- ### Install DWT and NCP Packages Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/indepth/development/vue.md Install the Dynamic Web TWAIN SDK package and the ncp package for copying static resources. ```cmd yarn add dwt@19.3.0 ``` ```cmd yarn add ncp ``` -------------------------------- ### 200 Response Example for /api/server Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/restful.md Example of a successful response when updating server settings. ```json { "logLevel": 1 } ``` -------------------------------- ### Request Example for GET /device/scanners/jobs/{jobuid}/next-page Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/restful.md Example JavaScript code to fetch the next page from a scan job using the GET /device/scanners/jobs/{jobuid}/next-page endpoint. Specify the image type as a query parameter. ```javascript const url = new URL("https://127.0.0.1:18623/api"); const jobuid = `B3701DC5-86D3-44B6-A8A1-FF0B5D43FD86`; const pathSegments = ['device', 'scanners', 'jobs', jobuid, 'next-page']; url.pathname = `${url.pathname}/${pathSegments.join('/')}`; const params = new URLSearchParams(); params.append(`type`, 'image/png'); url.search = params.toString(); let requestOptions = { method: 'GET', redirect: 'follow' }; fetch(url, requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` -------------------------------- ### Start Node.js Upload Server Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/deploy-your-own-upload-server-with-node.js.md Execute this command to start the Node.js application and make the upload server accessible. ```bash npm start ``` -------------------------------- ### Install DWT and NCP Dependencies Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/indepth/development/react.md Install the Dynamic Web TWAIN SDK and the ncp package for copying static resources. ```cmd npm install ``` ```cmd npm install dwt@19.3.0 ncp ``` -------------------------------- ### Complete ASP.NET Web.Config Example Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/HTTP-process-error.md An example of a complete Web.Config file for ASP.NET, demonstrating settings for httpRuntime and requestFiltering to manage upload sizes and execution timeouts. ```xml ``` -------------------------------- ### OnGetFilePath Event Example Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/WebTwain_IO.md Example of registering the OnGetFilePath event to display file selection details. ```javascript DWTObject.RegisterEvent("OnGetFilePath", function (isSave, filesCount, index, directory, filename) { alert( "isSave:" + isSave + " fileCount: " + filesCount + " index: " + index + " directory: " + directory + "\" + filename ); }); ``` -------------------------------- ### Acquire Image with WIA/TWAIN Scanner Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/support-wia-scanner-drivers.md This example demonstrates how to get a list of available scanners (both TWAIN and WIA), select the first one, and then acquire an image. Ensure that your application is using Dynamic Web TWAIN v18.0 or later for compatibility. ```javascript DWTObject.GetDevicesAsync(Dynamsoft.DWT.EnumDWT_DeviceType.TWAINSCANNER|Dynamsoft.DWT.EnumDWT_DeviceType.WIASCANNER).then((deviceList)=>{ return DWTObject.SelectDeviceAsync(deviceList[0]) //Select the first device }).then(()=>{ return DWTObject.AcquireImageAsync({}) }).catch((e)=>{ console.error(e) }) ``` -------------------------------- ### OnPostLoad Event Example Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/WebTwain_IO.md Example of registering the OnPostLoad event to display the path and name of the loaded file. ```javascript DWTObject.RegisterEvent("OnPostLoad", function (path, name, type) { alert(path + "\" + name); }); ``` -------------------------------- ### HTTPUpload() Syntax Example Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/WebTwain_IO.md This is a syntax example for the HTTPUpload method, showing the parameters required for uploading images via HTTP POST. ```javascript HTTPUpload( URL: string, indices: number[], type: Dynamsoft.DWT.EnumDWT_ImageType | number, dataFormat: Dynamsoft.DWT.EnumDWT_UploadDataFormat | number, fileName: string, onEmptyResponse: () => void, onServerReturnedSomething: (errorCode: number, errorString: string, response: string) => void ): void; ``` ```javascript HTTPUpload( URL: string, indices: number[], type: Dynamsoft.DWT.EnumDWT_ImageType | number, dataFormat: Dynamsoft.DWT.EnumDWT_UploadDataFormat | number, onEmptyResponse: () => void, onServerReturnedSomething: (errorCode: number, errorString: string, response: string) => void ): void; ``` -------------------------------- ### 200 Response Example for /api/server/version Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/restful.md Example of a successful response when retrieving the server API version. ```json { "version": "20240719", "compatible": true } ``` -------------------------------- ### Install Dynamic Web TWAIN Service (v19.0+) Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/upgrade-end-user-installations.md Use these commands for silent installation of Dynamic Web TWAIN Service version 19.0 and above. Ensure the correct installer path is provided. ```bash msiexec /i "/path/to/DynamicWebTWAINServiceSetup.msi" /qn ``` ```bash // Install sudo installer -pkg /path/to/DynamicWebTWAINServiceSetup.pkg -target / // Stop service sudo launchctl unload /Library/LaunchAgents/com.dynamsoft.dynamicwebtwainservicex64.plist // Start service launchctl load /Library/LaunchAgents/com.dynamsoft.dynamicwebtwainservicex64.plist ``` ```bash sudo dpkg -i /path/to/DynamicWebTWAINServiceSetup.deb // or sudo rpm -i path/to/DynamicWebTWAINServiceSetup.rpm ``` -------------------------------- ### Install Dynamic Web TWAIN Service (Below v19.0) Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/upgrade-end-user-installations.md Use these commands for silent installation of Dynamic Web TWAIN Service versions prior to 19.0. Ensure the correct installer path is provided. ```bash msiexec /i "/path/to/DynamsoftServiceSetup.msi" /qn ``` ```bash // Install sudo installer -pkg /path/to/DynamsoftServiceSetup.pkg -target / // Stop service sudo launchctl unload /Library/LaunchAgents/com.dynamsoft.dynamsoftservicex64.plist // Start service launchctl load /Library/LaunchAgents/com.dynamsoft.dynamsoftservicex64.plist ``` ```bash sudo dpkg -i /path/to/DynamsoftServiceSetup.deb // or sudo rpm -i path/to/DynamsoftServiceSetup.rpm ``` -------------------------------- ### 201 Created Response Example Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/restful.md This is an example of a successful response when a document is created. ```json { "uid": "190807444d76", "pages": [] } ``` -------------------------------- ### WebTwain AcquireImage Examples Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/WebTwain_Acquire.md Provides four distinct examples of using the AcquireImage API, showcasing different configurations and callback implementations. Ensure DWTObject is initialized and sources are selected/opened before calling AcquireImage. ```javascript var deviceConfiguration = { IfShowUI: false, PixelType: Dynamsoft.DWT.EnumDWT_PixelType.TWPT_RGB, Resolution: 300, IfFeederEnabled: true, IfDuplexEnabled: false, IfDisableSourceAfterAcquire: true, IfGetImageInfo: true, IfGetExtImageInfo: true, extendedImageInfoQueryLevel: 0, IfCloseSourceAfterAcquire: true, }; function successCallback() { DWTObject.CloseSource(); console.log("successful"); } function failureCallback(errorCode, errorString) { DWTObject.CloseSource(); alert(errorString); } function AcquireImage1() { DWTObject.SelectSource(function () { DWTObject.OpenSource(); DWTObject.IfShowUI = false; DWTObject.PixelType = Dynamsoft.DWT.EnumDWT_PixelType.TWPT_RGB; DWTObject.Resolution = 300; DWTObject.IfFeederEnabled = true; DWTObject.IfDuplexEnabled = false; DWTObject.IfDisableSourceAfterAcquire = true; DWTObject.AcquireImage(); }, failureCallback); } function AcquireImage2() { DWTObject.SelectSource(function () { DWTObject.OpenSource(); DWTObject.AcquireImage(deviceConfiguration); }, failureCallback); } function AcquireImage3() { DWTObject.SelectSource(function () { DWTObject.OpenSource(); DWTObject.IfShowUI = false; DWTObject.PixelType = Dynamsoft.DWT.EnumDWT_PixelType.TWPT_RGB; DWTObject.Resolution = 300; DWTObject.IfFeederEnabled = true; DWTObject.IfDuplexEnabled = false; DWTObject.IfDisableSourceAfterAcquire = true; DWTObject.AcquireImage(successCallback, failureCallback); }, failureCallback); } function AcquireImage4() { DWTObject.SelectSource(function () { DWTObject.OpenSource(); DWTObject.AcquireImage( deviceConfiguration, successCallback, failureCallback ); }, failureCallback); } ``` -------------------------------- ### Load Image Example Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/WebTwain_IO.md Example of loading an image using the asynchronous LoadImage method with success and failure callbacks. ```javascript DWTObject.LoadImage( "C:\\test\\DWT.jpg", function () { console.log("success"); }, function (errorCode, errorString) { console.log(errorString); }, ); ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/indepth/development/vue.md Navigate to your project directory and run these commands to install the required Node.js packages, including Dynamsoft Web TWAIN. ```cmd cd dwt-vue3 npm install npm install dwt@19.3.0 npm install ncp ``` -------------------------------- ### 400 Response Example for /api/server Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/restful.md Example of a 'Bad Request' response, typically due to invalid parameters. ```json { "code": -2113, "message": "The parameter is not valid.", "statusCode": 400 } ``` -------------------------------- ### 200 OK Response Example Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/restful.md Example of a successful operation response, typically containing base64 encoded settings. ```json { "settings": "Rfj6pIMTNkCu3BfDloGItBAAAAACEAAABgAFAAEAAAAQAAAAExAAAAYABQAAAAAAEAAAAAcQAAAGAAUAAQAAABAAAAArEQAABAAFABgAAAAQAAAAHBEAAAQABQAAAAAAEAAAAAABAAAEAAUAAAAAABwAAAAUEQAACAAFAPgqAAAAAAAANCEAAAAAAAAQAAAADBEAAAQABQACAAAAEAAAAB8RAAAEAAUAAAAAABAAAAABAQAABAAFAAIAAAAQAAAAIBEAAAQABQAAAAAAEAAAACIRAAAEAAUAAwAAABAAAAAQEQAABAAFAAAAAAAQAAAAAgEAAAQABQAAAAAAEAAAABgRAAAHAAUAAABIQxAAAAAZEQAABwAFAAAASEMQAAAAIxEAAAcABQAAAABDEAAAAAMRAAAHAAUAAAAAABAAAAABEQAABwAFAAAAAAAQAAAACBEAAAcABQAAAIA/EAAAAAGAAAAGAAUAAAAAAA==" } ``` -------------------------------- ### Install Linux (v19.0+) Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/can-i-install-dynamsoft-service-silently.md Use these commands to silently install the Dynamic Web TWAIN Service on Linux using dpkg or rpm package managers for versions 19.0 and above. ```shell sudo dpkg -i /path/to/DynamicWebTWAINServiceSetup.deb ``` ```shell sudo rpm -i path/to/DynamicWebTWAINServiceSetup.rpm ``` -------------------------------- ### Install Dynamic Web TWAIN Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/indepth/development/angular.md Install the Dynamic Web TWAIN SDK package using npm. Navigate to your project's root directory first. ```cmd npm install dwt@19.3.0 ``` -------------------------------- ### Install Dependencies for Jekyll Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/README.md Run this command in the docs folder to install the necessary Ruby gems for the Jekyll site. ```bash bundle install ``` -------------------------------- ### Install Dynamic Web TWAIN Service on Fedora Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/extended-usage/dynamsoft-service-configuration.md Use this command to install the Dynamic Web TWAIN Service on Fedora-based Linux distributions. ```bash sudo rpm -ivh DynamicWebTWAINServiceSetup.rpm ``` -------------------------------- ### Silent Install Windows (Below v19.0) Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/can-i-install-dynamsoft-service-silently.md Use this command in an administrator Command Prompt to silently install the service on Windows for versions below 19.0. ```shell msiexec /i "/path/to/DynamsoftServiceSetup.msi" /qn ``` -------------------------------- ### Write.Setup() Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/Addon_PDF.md Sets up the PDF writing engine with specified settings. ```APIDOC ## Write.Setup() ### Description Configures the PDF writing engine with various settings. ### Syntax ```typescript Write.Setup(settings: PDFWSettings): boolean; ``` ### Parameters * **settings** (PDFWSettings) - An object containing configuration options for PDF generation. Refer to the `PDFWSettings` interface for details. ### Example ```javascript DWTObject.Addon.PDF.Write.Setup({ author: "Dynamsoft", compression: Dynamsoft.DWT.EnumDWT_PDFCompressionType.PDF_JPEG, pageType: Dynamsoft.DWT.EnumPDF_Page.Page_A4, creator: "DWT", creationDate: "D:20230101085959", keyWords: "samplepdf", modifiedDate: "D:20230101090101", producer: "Dynamic Web TWAIN", subject: "SamplePdf", title: "SamplePdf", version: "1.5", quality: 90, }); DWTObject.SaveAllAsPDF("DynamicWebTWAIN.pdf", OnSuccess, OnFailure); function OnSuccess() { console.log("successful"); } function OnFailure(errorCode, errorString) { if (errorCode != -2326) alert(errorString); } ``` ### Usage Notes This method should be called before creating a PDF using methods such as HTTPUpload(), SaveAsPDF(), and SaveAllAsPDF(). Only the core module license is required. ``` -------------------------------- ### Get Next Page Info Request Example Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/restful.md Example of a JavaScript fetch request to get information about the next page in a scan job. Ensure the Dynamic Web TWAIN Service is running and accessible. ```javascript const url = new URL("https://127.0.0.1:18623/api"); const jobuid = `B3701DC5-86D3-44B6-A8A1-FF0B5D43FD86`; const pathSegments = ['device', 'scanners', 'jobs', jobuid, 'next-page-info']; url.pathname = `${url.pathname}/${pathSegments.join('/')}`; let requestOptions = { method: 'GET', redirect: 'follow' }; fetch(url, requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` -------------------------------- ### Complete HelloWorld.html Example Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/hello-world/scanning.md This is the complete HTML file integrating DWT initialization and scanning functionality. It includes the necessary scripts, a scan button, the DWT container, and the JavaScript logic for initialization and scanning. ```html
``` -------------------------------- ### Get Installed OCR Info Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/Addon_OCR.md Retrieves information about the installed OCR addon. Throws an error if the OCR module is not installed. Use this to check OCR addon status. ```typescript GetInstalledOCRInfo(): Promise; ``` -------------------------------- ### Install Dynamsoft Service (RPM/DEB) Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/source-not-listed-on-linux.md Use these commands to install the Dynamsoft Service package. Choose the appropriate command based on your Linux distribution's package manager. ```shell sudo rpm -i DynamsoftServiceSetup.rpm ``` ```shell sudo dpkg -i DynamsoftServiceSetup.deb ``` -------------------------------- ### Navigate to Sample Directory Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/deploy-your-own-upload-server-with-jsp.md Change the current directory to the root of the Sample project. This is a prerequisite for installing dependencies and building the project. ```bash cd [path]/Sample ``` -------------------------------- ### Dynamsoft Service HTTP Request: VersionInfo Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/what-does-dynamsoft-service-do-on-end-user-machine.md Example HTTP request to get version information from the Dynamsoft Service. ```http https://127.0.0.1:18623/fa/VersionInfo?ts=1603161807908 ``` -------------------------------- ### macOS Service Management (Below v19.0) Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/can-i-install-dynamsoft-service-silently.md Commands for installing, stopping, and starting the Dynamsoft Service on macOS for versions below 19.0. ```shell // Install sudo installer -pkg /path/to/DynamsoftServiceSetup.pkg -target / // Stop service sudo launchctl unload /Library/LaunchAgents/com.dynamsoft.dynamsoftservicex64.plist // Start service launchctl load /Library/LaunchAgents/com.dynamsoft.dynamsoftservicex64.plist ``` -------------------------------- ### macOS Service Management (v19.0+) Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/can-i-install-dynamsoft-service-silently.md Commands for installing, stopping, and starting the Dynamic Web TWAIN Service on macOS for versions 19.0 and above. ```shell // Install sudo installer -pkg /path/to/DynamicWebTWAINServiceSetup.pkg -target / // Stop service sudo launchctl unload /Library/LaunchAgents/com.dynamsoft.dynamicwebtwainservicex64.plist // Start service launchctl load /Library/LaunchAgents/com.dynamsoft.dynamicwebtwainservicex64.plist ``` -------------------------------- ### OCR Addon Methods Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/index.md Methods for the OCR addon to get installed OCR information, detect page orientation, recognize text, and save results. ```APIDOC ## Addon: OCR ### Methods #### `GetInstalledOCRInfo()` #### `DetectPageOrientation()` #### `Recognize()` #### `SaveToPath()` #### `SaveAsBase64()` #### `SaveAsBlob()` ``` -------------------------------- ### OpenDocument() Example Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/WebTwain_Buffer.md Demonstrates how to create multiple documents and then open a specific one for subsequent operations. Ensure CreateDocument is called before OpenDocument. ```javascript //Save the scanned image(s) under 'Document2'. DWTObject.CreateDocument("Document1"); DWTObject.CreateDocument("Document2"); DWTObject.CreateDocument("Document3"); DWTObject.OpenDocument("Document2"); //Need to call OpenDocument after CreateDocument. DWTObject.AcquireImage(successCallback, failureCallback); function successCallback() { console.log("successful"); } function failureCallback(errorCode, errorString) { alert(errorString); } ``` -------------------------------- ### OpenSource() - Prepare for Acquisition Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/WebTwain_Acquire.md Loads a data source to prepare it for image acquisition. This example demonstrates selecting a source by index, opening it, acquiring an image, and then closing the source upon success or failure. ```javascript DWTObject.GetSourceNames(); // for example ['PaperStream IP fi-7300NX Net', 'TWAIN2 FreeImage Software Scanner'] DWTObject.SelectSourceByIndex(0); // choose scanner with the name "PaperStream IP fi-7300NX Net" DWTObject.OpenSource(); DWTObject.AcquireImage(successCallback, failureCallback); function successCallback() { DWTObject.CloseSource(); console.log("successful"); } function failureCallback(errorCode, errorString) { DWTObject.CloseSource(); alert(errorString); } ``` -------------------------------- ### Check OCR Add-on Installation Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/extended-usage/ocr.md Verifies if the OCR Add-on is installed by attempting to retrieve OCR information. Alerts the user if it's not installed. ```javascript async function CheckIsOCRInstalled(){ try { let info = await DWTObject.Addon.OCRKit.GetInstalledOCRInfo(); console.log(info); if (info.version) { return true; } } catch (error) { alert(error.message); return false; } alert("OCR Add-on is not installed. Please install it to use OCR features."); return false; } ``` -------------------------------- ### CreateScanJobOptions Example Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/restful.md Configuration options for initiating a new scan job, including device settings and capabilities. ```json { "autoRun": false, "device": "{\"deviceInfo\":{\"Manufacturer\":\"VFdBSU4gV29ya2luZyBHcm91cA==\",\"ProductFamily\":\"U29mdHdhcmUgU2Nhbg==\",\"ProductName\":\"VFdBSU4yIEZyZWVJbWFnZSBTb2Z0d2FyZSBTY2FubmVy\",\"ProtocolMajor\":2,\"ProtocolMinor\":1,\"SupportedGroups\":0,\"Version\":{\"Country\":1,\"Info\":\"Mi4xLjMgc2FtcGxlIHJlbGVhc2UgMzJiaXQ=\",\"Language\":2,\"MajorNum\":2,\"MinorNum\":1}},\"deviceType\":16,\"isSystemDefaultPrinter\":false,\"name\":\"VFdBSU4yIEZyZWVJbWFnZSBTb2Z0d2FyZSBTY2FubmVy\"}", "name": "TWAIN2 FreeImage Software Scanner", "checkFeederLoaded": true, "config": { "PixelType": 1, "Resolution": 300, "IfFeederEnabled": true, "IfDuplexEnabled": false, "IfGetImageInfo": true, "IfGetExtImageInfo": true, "extendedImageInfoQueryLevel": 0, "IfCloseSourceAfterAcquire": true, "XferCount": 11 }, "caps": { "exception": "ignore", "capabilities": [ { "capability": 4355, "curValue": 500 } ] }, "settings": "Rfj6pIMTNkCu3BfDloGItBAAAAACEAAABgAFAAEAAAAQAAAAExAAAAYABQAAAAAAEAAAAAcQAAAGAAUAAQAAABAAAAArEQAABAAFABgAAAAQAAAAHBEAAAQABQAAAAAAEAAAAAABAAAEAAUAAAAAABwAAAAUEQAACAAFAPgqAAAAAAAANCEAAAAAAAAQAAAADBEAAAQABQACAAAAEAAAAB8RAAAEAAUAAAAAABAAAAABAQAABAAFAAIAAAAQAAAAIBEAAAQABQAAAAAAEAAAACIRAAAEAAUAAwAAABAAAAAQEQAABAAFAAAAAAAQAAAAAgEAAAQABQAAAAAAEAAAABgRAAAHAAUAAABIQxAAAAAZEQAABwAFAAAASEMQAAAAIxEAAAcABQAAAABDEAAAAAMRAAAHAAUAAAAAABAAAAABEQAABwAFAAAAAAAQAAAACBEAAAcABQAAAIA/EAAAAAGAAAAGAAUAAAAAAA==" } ``` -------------------------------- ### Configure Service Installer Location Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/Dynamsoft_WebTwainEnv.md Specifies the path to the Dynamic Web TWAIN Service installers. This is crucial for the service to be downloaded and installed if not already present. ```typescript Dynamsoft.DWT.ServiceInstallerLocation = "http://localhost:8080/dist/"; ``` -------------------------------- ### Initialize and Use FileUploader Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/general-usage/image-export/server-upload.md This snippet demonstrates the complete process of initializing the FileUploader, generating an upload URL for selected images, configuring an upload job with server details and callbacks, and running the upload job. It includes event handling for upload progress and completion. ```html
``` -------------------------------- ### Load() Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/Dynamsoft_WebTwainEnv.md Initiates the Dynamsoft WebTwain library. If Containers are predefined, it creates a WebTwain instance for each. ```APIDOC ## Load() Initiates the library. If there are predefined [`Containers`](#containers), one `WebTwain` instance will be created for each `Container`. **Syntax** ```typescript Load(): Promise; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.2+ v11.0+ v11.0+ v12.1+
**Example** ```javascript Dynamsoft.DWT.Load(); ``` **Usage Note** - Only used if [`AutoLoad`](#autoload) is set to `false`. ``` -------------------------------- ### Check OCR Add-on Installation Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/extended-usage/ocr.md Verify if the OCR add-on is installed correctly by calling `GetInstalledOCRInfo()`. This function returns installation details or throws an error if not found. ```javascript async function CheckIsOCRInstalled(){ try { let info = await DWTObject.Addon.OCRKit.GetInstalledOCRInfo(); console.log(info); if (info.version) { return true; } } catch (error) { alert(error.message); return false; } alert("OCR Add-on is not installed. Please install it to use OCR features."); return false; } ``` -------------------------------- ### Build the Client-Side Project Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/deploy-your-own-upload-server-with-jsp.md Compile and bundle the client-side application assets. This command should be executed after installing dependencies. ```bash npm run build ``` -------------------------------- ### DocumentInfo Response Example Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/restful.md Example structure of a DocumentInfo response. ```APIDOC ## DocumentInfo Response ### Response Example ```json { "uid": "190807444d76", "pages": [ { "uid": "190817548d70" } ] } ``` ``` -------------------------------- ### PageInfo Response Example Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/restful.md Example structure of a PageInfo response. ```APIDOC ## PageInfo Response ### Response Example ```json { "uid": "190817548d70" } ``` ``` -------------------------------- ### ScannerJobInfo Response Example Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/restful.md Example structure of a ScannerJobInfo response. ```APIDOC ## ScannerJobInfo Response ### Response Example ```json { "status": "pending", "code": "0", "message": "Successful" } ``` ``` -------------------------------- ### ScannerJob Response Example Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/restful.md Example structure of a ScannerJob response. ```APIDOC ## ScannerJob Response ### Response Example ```json { "jobuid": "B3701DC5-86D3-44B6-A8A1-FF0B5D43FD86", "status": "pending", "scanner": { "name": "TWAIN2 FreeImage Software Scanner", "type": 16, "device": "{\"deviceInfo\":{\"Manufacturer\":\"VFdBSU4gV29ya2luZyBHcm91cA==\",\"ProductFamily\":\"U29mdHdhcmUgU2Nhbg==\",\"ProductName\":\"VFdBSU4yIEZyZWVJbWFnZSBTb2Z0d2FyZSBTY2FubmVy\",\"ProtocolMajor\":2,\"ProtocolMinor\":1,\"SupportedGroups\":0,\"Version\":{\"Country\":1,\"Info\":\"Mi4xLjMgc2FtcGxlIHJlbGVhc2UgMzJiaXQ=\",\"Language\":2,\"MajorNum\":2,\"MinorNum\":1}},\"deviceType\":16,\"isSystemDefaultPrinter\":false,\"name\":\"VFdBSU4yIEZyZWVJbWFnZSBTb2Z0d2FyZSBTY2FubmVy\"}" } } ``` ``` -------------------------------- ### Complete Image Editor Customization Example Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/customize-ui-elements-of-image-editor.md Initialize and display the image editor with custom settings. This includes defining element, dimensions, colors, button visibility, and dialog text. ```javascript // Customize the editor var editorSettings = { /* Show the editor within the DIV 'imageEditor'*/ element: document.getElementById("imageEditor"), width: 600, height: 400, border: "10px solid rgb(0,128,0)", topMenuBorder: "", innerBorder: "", background: "rgb(255, 255, 255)", promptToSaveChange: true, buttons: { titles: { previous: "Previous Image", next: "Next Image", print: "Print Image", scan: "Scan Documents", load: "Load Local Images", rotateleft: "Rotate Left", rotate: "Rotate", rotateright: "Rotate Right", deskew: "Deskew", crop: "Crop Selected Area", cut: "Cut Selected Area", changeimagesize: "Change Image Size", flip: "Flip Image", mirror: "Mirror Image", zoomin: "Zoom In", originalsize: "Show Original Size", zoomout: "Zoom Out", stretch: "Stretch Mode", fit: "Fit Window", fitw: "Fit Horizontally", fith: "Fit Vertically", hand: "Hand Mode", rectselect: "Select Mode", zoom: "Click to Zoom In", restore: "Restore Original Image", save: "Save Changes", close: "Close the Editor", removeall: "Remove All Images", removeselected: "Remove All Selected Images", }, visibility: { scan: true, load: true, print: true, removeall: true, removeselected: true, rotateleft: true, rotate: true, rotateright: true, deskew: true, crop: true, cut: true, changeimagesize: true, flip: true, mirror: true, zoomin: true, originalsize: true, zoomout: true, stretch: true, fit: true, fitw: true, fith: true, hand: true, rectselect: true, zoom: true, restore: true, save: true, close: true, }, }, dialogText: { dlgRotateAnyAngle: [ "Angle :", "Interpolation:", "Keep size", " OK ", "Cancel", ], dlgChangeImageSize: [ "New Height :", "New Width :", "Interpolation method:", " OK ", "Cancel", ], saveChangedImage: [ "You have changed the image, do you want to keep the change(s)?", " Yes ", " No ", ], selectSource: [ "Select Source:", "Select", "Cancel", "There is no source available", ], }, }; var imageEditor = DWTObject.Viewer.createImageEditor(editorSettings); imageEditor.show(); ``` -------------------------------- ### Relocate Resources and Service Installers Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/general-usage/server-deployment.md Customize the location of the Resources folder and the Dynamic Web TWAIN Service installer files. This allows for more flexible project structures and external hosting of installers. ```javascript Dynamsoft.DWT.ResourcesPath = "../projectfiles/DWTResources"; Dynamsoft.DWT.ServiceInstallerLocation` = "https://example.com/DWTInstallers"; ``` -------------------------------- ### CapabilitySetup Interface Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/interfaces.md Defines the setup for a single capability, including the capability identifier, value, and specific exception handling. ```APIDOC ## CapabilitySetup Interface ### Description Defines the setup for a single capability, including the capability identifier, value, and specific exception handling. ### Syntax ```typescript interface CapabilitySetup { /** * Specify a capability */ capability: Dynamsoft.DWT.EnumDWT_Cap | number; /** * The value to set to the capability or the value of the capability after setting. * Except TWON_ARRAY type whose current values are set via the attribute values. */ curValue?: number | string | object; /** * The value array to set to the capability or the value array of the capability after setting. * Only available for TWON_ARRAY type. */ values?: any[]; errorCode?: number; errorString?: string; /** * Whether to "ignore" or "fail" the request if an exception occurs when setting this specific capability. */ exception? : string; } ``` ``` -------------------------------- ### initRuntimeSettingsWithString() Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/Addon_BarcodeReader.md Initializes the barcode reader with advanced settings provided as a string. Returns a promise that resolves with the RuntimeSettings. ```APIDOC ## initRuntimeSettingsWithString() ### Description Set up the barcode reader with advanced settings. ### Method ```typescript initRuntimeSettingsWithString( settings: string ): Promise ; ``` ### Parameters #### Path Parameters - **settings** (string) - Required - The runtime setting in the form of a string. ### Return value Please refer to [`RuntimeSettings`](/_articles/info/api/interfaces.md#runtimesettings). ``` -------------------------------- ### 410 Gone Response Example Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/restful.md Example of a gone response, indicating the job was deleted. ```json { "code": -1034, "message": "Invalid Value.", "statusCode": 410 } ``` -------------------------------- ### 405 Response Example for /api/server/version Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/restful.md Example of a 'Method Not Allowed' response for the /api/server/version endpoint. ```json { "code": -2112, "message": "This endpoint only supports GET.", "statusCode": 405 } ``` -------------------------------- ### 405 Response Example for /api/server Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/restful.md Example of a 'Method Not Allowed' response for the /api/server endpoint. ```json { "code": -2112, "message": "This endpoint only supports GET, PATCH.", "statusCode": 405 } ``` -------------------------------- ### Dynamsoft.FileUploader.Init() Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/Dynamsoft_FileUploader.md Initializes the FileUploader component and creates an instance. It requires a URL to the library, and success and failure callback functions. ```APIDOC ## Dynamsoft.FileUploader.Init() ### Description Initializes and creates a FileUploader instance. ### Syntax ```typescript Init( URL: string, successCallback: (uploadManager: UploadManager) => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` ### Parameters - **URL** (string): Specify a path to retrieve the FileUploader library. Can be left empty "" as the library is installed by default. - **successCallback** (function): A callback function executed upon successful initialization. It receives an `UploadManager` instance. - **uploadManager** (`UploadManager`): An instance of the FileUploader. - **failureCallback** (function): A callback function executed if initialization fails. It receives an error code and error string. - **errorCode** (number): The error code. - **errorString** (string): The error string. ### Example ```javascript var dsUploadManager; Dynamsoft.FileUploader.Init( "", function (obj) { dsUploadManager = obj; }, function () {}, ); ``` ``` -------------------------------- ### Instantiate WebTwain On Demand Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/extended-usage/advanced-initialization.md This HTML snippet demonstrates how to instantiate a WebTwain object when a button is clicked. It configures the resource path, product key, and container before loading the WebTwain instance and registering an event to retrieve the object. ```html
``` -------------------------------- ### 200 Response Example for Next Page Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/restful.md Example of a successful response when retrieving a scanned page. ```json [ { "extendedImageInfo": {}, "imageId": 1, "imageInfo": { "BitsPerPixel": 24, "BitsPerSample": [ 8, 8, 8, 0, 0, 0, 0, 0 ], "Compression": 0, "ImageLayout": { "DocumentNumber": 1, "Frame": { "Bottom": 11, "Left": 0, "Right": 8.5, "Top": 0 }, "FrameNumber": 0, "PageNumber": 1 }, "ImageLength": 2200, "ImageWidth": 1700, "PixelType": 2, "Planar": false, "SamplesPerPixel": 3, "XResolution": 200, "YResolution": 200 }, "imageuid": "1951d65a72b1", "url": "https://127.0.0.1:18623/api/device/scanners/jobs/510dadf2-7e29-4172-80f1-49fa5d2ea0bf/next-page?page=1951d65a72b1" } ] ``` -------------------------------- ### Example: Setting and Saving TIFF with Custom Tags Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/WebTwain_IO.md Demonstrates clearing existing TIFF custom tags, setting a new custom tag, and then saving an image as a TIFF file. ```javascript DWTObject.ClearTiffCustomTag(); DWTObject.SetTiffCustomTag(700, "Created By DWT", false); DWTObject.SaveAsTIFF("C:\\DWT.tiff", 0); ``` -------------------------------- ### GetInstalledOCRInfo() Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/Addon_OCR.md Returns the info of the installed OCR addon. It will throw an error if the OCR module is not installed. ```APIDOC ## GetInstalledOCRInfo() ### Description Return the info of the installed OCR addon. It will throw an error if the OCR module is not installed. ### Method ```typescript GetInstalledOCRInfo(): Promise; ``` ### Return Values Promise of an [`OCRInfo`](/_articles/info/api/interfaces.md#ocrinfo) object. ``` -------------------------------- ### Instantiate WebTwain with HTML Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/extended-usage/advanced-initialization.md This HTML snippet demonstrates how to load the WebTwain library and instantiate a WebTwain object using the `Dynamsoft.DWT.CreateDWTObject` method. Ensure the `dwtcontrolContainer` div exists and the `Dynamsoft.DWT.ResourcesPath` and `Dynamsoft.DWT.ProductKey` are correctly set. ```html
``` -------------------------------- ### 404 Not Found Response Example for Document Info Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/restful.md This is an example of a not found response when the document UID is invalid. ```json { "code": -1040, "message": "The provided UID is invalid.", "statusCode": 404 } ``` -------------------------------- ### Navigate to First Page - JavaScript Source: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/WebTwain_Viewer.md Example of calling the first() method to display the first page of the viewer. ```javascript DWTObject.Viewer.first(); ```