--- title: Dynamic Web TWAIN SDK Support description: Dynamic Web TWAIN SDK Documentation Support Page source_url: html: https://www.dynamsoft.com/web-twain/docs/about/getsupport.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/about/getsupport.md --- # How to get support If you encounter any issues or have any suggestions while using Dynamic Web TWAIN, please feel free to [contact us](https://www.dynamsoft.com/company/contact/) via email, livechat or phone call. --- title: Dynamic Web TWAIN SDK Resources – Guides & Tools description: Dynamic Web TWAIN SDK Documentation Resources Page source_url: html: https://www.dynamsoft.com/web-twain/docs/about/resources.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/about/resources.md --- # Resources ## Where to get Dynamic Web TWAIN * Official installer > This official package is meant for developers to evaluate the SDK. When the package is installed, you get all the resource files, documentation, and samples. A 30-day free trial is included when evaluating our SDK. * NPM package > All the files in the DWT package will help you include `Dynamic Web TWAIN` in your web application both as a regular library and as a module. To try our SDK and included samples, a [trial license](#how-do-i-get-a-trial-license) is required. * YARN package > Similar to using NPM, you will get all the files in the DWT package. ## Sample code * Official samples > We have many prebuilt samples to demonstrate common user scenarios. All samples contain the resource files required in your application. If a sample is hosted on the Dynamsoft website (not Github), then the sample comes with a 30-day free trial license as well. Otherwise, you can [get a trial license](#how-do-i-get-a-trial-license). * Github repo > In our repository, we've shared many samples and other projects related to `Dynamic Web TWAIN` . Some of which may be experimental. To try out these samples, a [trial license](#how-do-i-get-a-trial-license) is required. ## How do I get a trial License Please visit our customer portal to request for a trial license. ## Online Demo * Official Demo - See Dynamic Web TWAIN in action ## Useful Links * Price / Online Store * Online Videos ## Blogs * Code Pool * Company Blog --- title: Agent Skills | Dynamic Web TWAIN Documentation description: This post teaches you how to use Dynamic Web TWAIN's official agent skills. source_url: html: https://www.dynamsoft.com/web-twain/docs/ai/agent-skills.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/ai/agent-skills.md --- # Agent Skills Agent Skills are structured instruction files that teach AI agents how to use Dynamic Web TWAIN in your web apps accurately and efficiently. They work with Claude Code, Cursor, Codex, and other AI agents. You can run the following command to install the skills: ```bash npx skills add https://github.com/Dynamsoft/web-twain-samples/ ``` ## Example Prompts Try the following prompts after installing. Your AI agent will automatically use the installed skills: | Prompt | Description | |--------|-------------| | Please create a component to use Dynamic Web TWAIN for document scanning in this angular app. Just a scan button to perform scanning and view the document in a viewer. | Use Web TWAIN in an existing Angular project. | | Please write an html file which loads Web TWAIN via CDN. The page contains a scan button, which triggers scanning with the scanner ui. The scanned images are displayed in Web TWAIN's viewer. | Create a plain JavaScript HTML file to scan documents. | | What is Dynamic Web TWAIN service? | Ask questions about Web TWAIN. | ## Additional Resources * [GitHub repo](https://github.com/Dynamsoft/web-twain-samples/tree/main/skills) * [Agent Skills documentation](https://agentskills.io/home) --- title: AI Overview | Dynamic Web TWAIN Documentation description: Overview of Dynamic Web TWAIN and AI. source_url: html: https://www.dynamsoft.com/web-twain/docs/ai/overview.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/ai/overview.md --- # AI Overview AI can answer questions related to Dynamic Web TWAIN and write codes directly. You can utilize AI in several ways. ## How to Use 1. Use the "Ask AI" buttton to ask questions about the SDK. ![Ask AI Button](/assets/imgs/ask-ai-button.jpg) 2. Use the [agent skills](./agent-skills.md) in your AI agent like Claude Code, Codex and Cursor. Skills teach the agent how to include Web TWAIN in your project and use its APIs correctly. 3. Use [llms.txt](/llms.txt) and [llms-full.txt](/llms-full.txt) to provide documentation for large language models (LLMs) and apps that use them. --- title: Dynamic Web TWAIN Core Concepts - Dynamic Web TWAIN Service description: This page gives a general introduction to Dynamic Web TWAIN Service, which makes it possible to access imaging devices in the browser. source_url: html: https://www.dynamsoft.com/web-twain/docs/core-concepts/Dynamic-Web-TWAIN-Service.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/core-concepts/Dynamic-Web-TWAIN-Service.md --- # Dynamic Web TWAIN Service Dynamic Web TWAIN Service (previously known as Dynamsoft Service prior to version 19) is a local service installed on end-user devices to make it possible to access imaging devices in the browser. It also provides other functions like image processing, caching, barcode reading, OCR and system function calls. ![architecture](/assets/imgs/core-concepts//local-scan-architecture.svg) To use Dynamic Web TWAIN in the browser, you have to install the service beforehand. ## Other Ways of Accessing Scanners in the Browser Previously, technologies like ActiveX for Internet Explorer and NPAPI plugins for older versions of Chrome allowed scanner access directly in the browser. However, these technologies are now deprecated. Modern browsers lack built-in APIs for document scanning. While Chrome offers an experimental WebUSB API, it has limited functionality. Therefore, using a local service is currently the most viable solution. ## Related Articles * [Setting up Dynamic Web TWAIN Service](/_articles/extended-usage/dynamsoft-service-configuration.md) * [FAQs Related to Dynamic Web TWAIN Service](/_articles/faq/index.md#project-deployment-and-end-user-installation) * [End-User Guide](/_articles/end-user/index.md) --- title: Dynamic Web TWAIN Core Concepts - TWAIN description: This page gives a general introduction to TWAIN, the document scanning API that Dynamic Web TWAIN exposes to the browser environment. source_url: html: https://www.dynamsoft.com/web-twain/docs/core-concepts/TWAIN.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/core-concepts/TWAIN.md --- # TWAIN TWAIN is a standard for interacting with image devices, like document scanners and cameras. It was created by a small group of software and hardware companies in response to the need for a proposed specification for the imaging industry. Without TWAIN, we have to program for every device. With TWAIN, we only need to create an application that knows TWAIN and it can have access to thousands of TWAIN-compatible devices. ## Architecture The architecture of TWAIN consists of four layers: * Application - Dynamic Web TWAIN executes at this layer. * Protocol - There is a Source Manager working between the application and the Sources. * Acquisition - The software elements written to control acquisitions are called Sources and reside primarily in this layer. * Device - This is the location of traditional low-level device drivers. ## Files The following files are required to use TWAIN. ### Source Manager The implementation of the Source Manager differs between the supported systems: * On Windows * The Source Manager is a Dynamic Link Library (TWAINDSM.DLL or twain_32.dll for old TWAIN versions). * The Source Manager can manage simultaneous sessions between an application and many Sources. * On Macintosh: The Source Manager is a Mach-O framework (TWAIN.framework, TWAINDSM.framework). * On Linux * The Source Manager is a shared library (/usr/local/lib/libtwaindsm.so). * The Source Manager can manage simultaneous sessions between an application and many Sources. Normally, the system has the libraries built-in. Dynamsoft have the DLLs included in its Windows installer by default. ### Source The implementation of the Source is the same as the implementation of the Source Manager: * On Windows: The Source is a Dynamic Link Library (DLL) with a .ds extension. You can find the files after installing the driver under "C:\Windows\twain_32" and "C:\Windows\twain_64". * On Macintosh: The Source is implemented as a bundle (preferably Mach-O) with a .ds extension. * On Linux: The Source is a shared library (.so) with a .ds extension. ## TWAIN Capabilities One of TWAIN's benefits is it allows applications to easily interact with a variety of acquisition devices. This is done using TWAIN capabilities. TWAIN capabilities are divided into three groups: * **CAP_xxxx**: Capabilities whose names begin with CAP are capabilities that could apply to any general Source. Such capabilities include use of automatic document feeders, identification of the creator of the data, etc. * **ICAP_xxxx**: Capabilities whose names begin with ICAP are capabilities that apply to image devices. The "I" stands for image. * **ACAP_xxxx**: Capabilities whose names begin with ACAP are capabilities that apply to devices that support audio. The "A" stands for audio. Here are some capabilities for example: * **CAP_DEVICEONLINE**: If TRUE, the physical hardware (e.g., scanner, digital camera, image database, etc.) that represents the image source is attached, powered on, and communicating. * **CAP_FEEDERENABLED**: If TRUE, Source must acquire data from the document feeder acquire area and other feeder capabilities can be used. * **ICAP_AUTOMATICBORDERDETECTION**: Turns automatic border detection on and off. You can use this online demo to get and set the capabilities with Dynamic Web TWAIN: . You can learn more about TWAIN by reading its specifications: . ## Other Document Scanning APIs Through time, Dynamic Web TWAIN added support for other APIs as well: WIA, SANE, ICA and eSCL. They can be used with the same set of JavaScript APIs. Here is a table of the APIs and platforms Dynamic Web TWAIN supports. | | Windows | macOS | Linux | |-----------|---------|-----|-------| | **TWAIN** | X | X | | | **WIA** | X | | | | **ICA** | | X | | | **SANE** | | | X | | **eSCL** | X | X | X | --- title: Dynamic Web TWAIN Core Concepts - Resource Files description: This page gives a general introduction to Dynamic Web TWAIN's resource files. source_url: html: https://www.dynamsoft.com/web-twain/docs/core-concepts/resource-files.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/core-concepts/resource-files.md --- # Resource Files Resource files are the files your web application needs to use. There are two formats of resource files. Format 1 is for the traditional vanilla JavaScript development. You can find the files in the [SDK installer](https://www.dynamsoft.com/web-twain/downloads/) or official samples' zip files. ``` Resources │ dynamsoft.webtwain.config.js │ dynamsoft.webtwain.initiate.js │ dynamsoft.webtwain.install.js │ Readme.txt │ ├─addon │ dynamsoft.upload.js │ dynamsoft.webtwain.addon.barcodereader.js │ dynamsoft.webtwain.addon.pdf.js │ dynamsoft.webtwain.addon.webcam.js │ ├─dist │ DynamicWebTWAINServiceSetup-arm64.deb │ DynamicWebTWAINServiceSetup.deb │ DynamicWebTWAINServiceSetup.msi │ DynamicWebTWAINServiceSetup.pkg │ DynamicWebTWAINServiceSetup.rpm │ LICENSE │ └─src dynamsoft.lts.js dynamsoft.webtwain.css dynamsoft.webtwain.viewer.css dynamsoft.webtwain.viewer.js ``` Format 2 is for usage with package managers and frameworks or CDN references. You can obtain the files via `npm install dwt`. ``` dwt │ dwt-openapi.yaml │ legal.txt │ LICENSE.txt │ package.json │ README.md │ └─dist │ dynamsoft.webtwain.min.js │ dynamsoft.webtwain.min.mjs │ ├─dist │ DynamicWebTWAINServiceSetup-arm64.deb │ DynamicWebTWAINServiceSetup.deb │ DynamicWebTWAINServiceSetup.msi │ DynamicWebTWAINServiceSetup.pkg │ DynamicWebTWAINServiceSetup.rpm │ LICENSE │ ├─src │ dynamsoft.lts.js │ dynamsoft.webtwain.css │ dynamsoft.webtwain.viewer.css │ dynamsoft.webtwain.viewer.js │ └─types Addon.BarcodeReader.d.ts Addon.OCR.d.ts Addon.OCRKit.d.ts Addon.OCRPro.d.ts Addon.PDF.d.ts Addon.Webcam.d.ts Dynamsoft.d.ts Dynamsoft.Enum.d.ts Dynamsoft.FileUploader.d.ts index.d.ts RemoteScan.d.ts RemoteScan.Viewer.d.ts tsconfig.json tslint.json WebTwain.Acquire.d.ts WebTwain.Buffer.d.ts WebTwain.d.ts WebTwain.Edit.d.ts WebTwain.IO.d.ts WebTwain.Util.d.ts WebTwain.Viewer.d.ts ``` For more detailed information on these files, please refer to the following articles: * [Loading Library Resources](/_articles/general-usage/resource-loading.md) * [What are the Resources files? ](/_articles/faq/what-are-the-resources-files.md) --- title: Dynamic Web TWAIN Core Concepts - Scanner description: This page gives a general introduction to document scanners, which Dynamic Web TWAIN interacts with. source_url: html: https://www.dynamsoft.com/web-twain/docs/core-concepts/scanner.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/core-concepts/scanner.md --- # Scanner Scanners are the major object which Dynamic Web TWAIN interacts with. We are going to give a brief introduction to it, focusing on what matters to Dynamic Web TWAIN. ## Scanner Types ### Flatbed Scanner A flatbed scanner is a type of scanner that provides a glass bed (platen) on which the object to be scanned lies motionless. The scanning element moves horizontally beneath the glass, capturing either the entirety of the platen or a predetermined portion. ![Epson v850](/assets/imgs/core-concepts/Epson_V850_scanner_open_20230920.jpg) Most flatbed scanners work in a reflective way, which shines white light onto the object and reads the intensity and color of light reflected from it. Some flatbed scanners also have transparency adapters (for scanning films and slides). These work differently: the light passes directly through the scanned object. In the scanning application, you can select whether to use the transparent unit or not. ### Sheetfed Scanner A sheetfed scanner, also known as a document feeder scanner or ADF (Automatic Document Feeder) scanner, uses motor-driven rollers to move individual sheets of paper past a stationary scanning element (or two for duplex scanning). Unlike flatbed scanners, sheetfed scanners are not designed to scan bound materials such as books or magazines, nor are they suitable for materials thicker than standard paper. Their primary advantage is the ability to scan multiple documents quickly and automatically, making them much faster than flatbed scanners for high-volume tasks. ![ScanSnap iX500](/assets/imgs/core-concepts/ScanSnap_iX500.jpg) ### All-in-One Scanner All-in-one scanners, commonly found in Multi-Function Printers (MFPs), integrate both a document feeder and a flatbed, offering the versatility of both scanner types in a single device. ![Ricoh 5055](/assets/imgs/core-concepts/500px-Ricoh_5055_MFP.jpg) ### Camera-Based Scanner Camera-based scanners use one or more digital cameras to capture a document image all at once, typically with an overhead design. ![CZUR ET Series](/assets/imgs/core-concepts/ET_Series_Book_Scanner.png) Unlike traditional scanners that scan line-by-line in a controlled environment, camera-based scanners are faster and can handle various materials, including bound books and fragile documents. However, they may be susceptible to issues like perspective distortion, shadows, and inconsistent lighting. ## Special Scanners There are also scanners designed for specific use cases. ### Check Scanners Check scanners are equipped with a Magnetic Ink Character Recognition (MICR) unit, which reads the magnetic ink characters printed on checks. With Dynamic Web TWAIN, you can not only retrieve the scanned image but also obtain the MICR data from the check. ### Scanners with Imprinter / Endorser Many production scanners can be integrated with a printer or endorser module. This allows them to print text or barcodes directly onto the scanned documents during the scanning process, which is useful for document routing or post-scan sorting. ## Connectivity Most modern scanners use USB for connection, while older models may use SCSI or a parallel port. Network connectivity (Wi-Fi or Ethernet) is also common, especially in office environments. ## Application Programming Interface Standardized Application Programming Interfaces (APIs) enable software to communicate with scanners. The most common ones include: * **TWAIN** – The industry standard API widely used by scanners, especially on Windows. * **WIA** (Windows Image Acquisition) – An API provided by Microsoft for image acquisition. * **SANE** (Scanner Access Now Easy) – A free/open-source API primarily used on Linux and macOS. * **ImageCaptureCore** – A native API provided by Apple for macOS and iOS. * **ISIS** (Image and Scanner Interface Specification) – A high-performance API often used with high-speed production scanners in enterprise environments. * **eSCL** – A vendor-neutral, RESTful-based protocol for driverless scanning over a network, commonly used by modern networked scanners and MFPs. --- title: A connection with the server could not be established description: A connection with the server could not be established source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/connection-couldnt-be-established.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/connection-couldnt-be-established.md --- # Error Troubleshooting ## A connection with the server could not be established ### Symptom When attempting to upload images to your web server, the upload fails and you see this error message. ### Cause This usually means the client cannot reach the server. ### Resolution - Verify the HTTP port in your code matches the server’s listening port. Set it with [`HTTPPort`](/_articles/info/api/WebTwain_IO.md#httpport). - Confirm the server address is reachable (ping it from a client machine). Use either the machine name or IP with `HTTPUpload`. > Note: > Both the machine name and the IP address of the server can be used for the [`HTTPUpload`](/_articles/info/api/WebTwain_IO.md#httpupload) method. --- title: General failure description: General failure source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/general-failure.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/general-failure.md --- # ErrorList ## General failure - Symptom When scanning an image with Dynamic Web TWAIN, you may receive the error message "General failure" in the ErrorString property. - Cause The problem occurs when the source (scanner) is _not_ disabled completely after a scanning session or the source is currently unavailable. - Resolution You can reset the existing connections of the source by calling [CloseSource](/_articles/info/api/WebTwain_Acquire.md#closesource){:target="_blank"} & [CloseSourceManager](/_articles/info/api/WebTwain_Acquire.md#closesourcemanager){:target="_blank"} to close the sources existing connections before calling [SelectSource](/_articles/info/api/WebTwain_Acquire.md#selectsource){:target="_blank"}. ```javascript function AcquireImage() { DWTObject.CloseSource(); DWTObject.CloseSourceManager(); DWTObject.SelectSource(); DWTObject.OpenSource(); DWTObject.AcquireImage(); } ``` --- title: The handle is in the wrong state for the requested operation description: The handle is in the wrong state for the requested operation source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/the-handle-is-in-the-wrong-state-for-the-requested-operation.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/the-handle-is-in-the-wrong-state-for-the-requested-operation.md --- # Error Troubleshooting ## The handle is in the wrong state for the requested operation ### Symptom When you upload images in Dynamic Web TWAIN's buffer, you may receive the following error messages returned by the ErrorString property: ![Requested-Operation](/assets/imgs/Requested-Operation.png) ### Cause 1. The size of the images you are going to upload goes beyond the maximum transferable data size which is defined by the server. 2. The port number of the HTTP server is not defined in your code. 3. The server name is invalid. ### Solution 1. Please reset the maximum transferable data size: If you are using IIS 6: 1. Start -> Run , type "cmd" 2. Go to "C:\Inetpub\AdminScripts" by typing: cd C:\Inetpub\AdminScripts 3. To view the max request entity allowed: cscript adsutil.vbs get w3svc/AspMaxRequestEntityAllowed If you are using IIS: 1. Start -> Run , type "InetMgr" to open IIS 7 Manager 2. {Your WebSite}->Feature View->ASP->Limit Properties 3. Set "Maximum Requesting Entity Body Limit" to a bigger value like "1000000" To set the max request entity allowed property: cscript adsutil.vbs set w3svc/AspMaxRequestEntityAllowed 1000000 (You can change the value by yourself.) If you are using ASP.NET, you can change the value at the following line in the "Web.Config" file. ```javascript //You can change the value by yourself. ``` If you are using PHP, you can change the value at the following line in the php.ini file. ```javascript upload_max_filesize = 2M (You can change the value by yourself.) ``` 2. Please set the port number of the HTTP server in your code. You can use the [HTTPPort](/_articles/info/api/WebTwain_IO.md#httpport) property to set the port number. Click here for more information about this property. 3. The problem may occur when you use "localhost" as the server name in the HTTP Upload method, when actually, you specified the address of your server using an IP address. In this case, please modify the server name to an available IP address in your code and then try again. ![Default-Web-Site-Properties](/assets/imgs/Default-Web-Site-Properties.png) --- title: What are the Resources files? description: What are the Resources files? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/what-are-the-resources-files.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/what-are-the-resources-files.md --- # General ## What are the Resources files? Resources files help you include Dynamic Web TWAIN in your application. The following shows the purpose of these files. You can typically find the `Resources` folder inside the following locations depending on your platform after using the [installer](https://www.dynamsoft.com/web-twain/downloads/): - Windows: `C:\Program Files (x86)\Dynamsoft\Dynamic Web TWAIN SDK {Version Number}\` - Linux: Within the decompressed file `Dynamic Web TWAIN SDK {Version Number}/` - macOS: `/Applications/Dynamsoft/Dynamic Web TWAIN SDK {Version Number}/` > *Resources* is the default name of the folder that contain these files. In the DWT npm package, it's called *dist*.
- [v19.0+](#19plus) - [v18.1+](#18plus) - [From v16.0 to v18.0](#18min)
### Default files * dynamsoft.webtwain.config.js > This file is used to make basic configuration of the Dynamic Web TWAIN library. It's where you enter the product key for the product and to change the initial viewer size, etc. * dynamsoft.webtwain.initiate.js > This file is the core of the Dynamic Web TWAIN library. * dynamsoft.webtwain.install.js > This file is used to configure the dialogs which are shown when the Dynamic Web TWAIN library is not installed or needs to be upgraded. This file is already referenced inside the dynamsoft.webtwain.initiate.js * Readme.txt * addon + dynamsoft.upload.js > This file contains the functionalities of the Dynamsoft Upload Module. + dynamsoft.webtwain.addon.pdf.js > This file contains the functionalities of the PDF Rasterizer addon. + dynamsoft.webtwain.addon.webcam.js > This file contains the functionalities of the Webcam addon. + dynamsoft.webtwain.addon.barcodereader.js > This file contains the functionalities of the Barcode addon. * dist > Under this directory are the installers for the Dynamic Web TWAIN Service which needs to be manually installed on each client machine that uses the Dynamic Web TWAIN library as a service. - DynamicWebTWAINServiceSetup.deb > For Linux (Debian) - DynamicWebTWAINServiceSetup.rpm > For Linux (Redhat) - DynamicWebTWAINServiceSetup.msi > For Windows - DynamicWebTWAINServiceSetup.pkg > For macOS - LICENSE * src > These files contain the following functionalities > - image input & output > - image decode & encode > - PDF read & write > - Viewer & UI - dynamsoft.lts.js - dynamsoft.webtwain.css - dynamsoft.webtwain.viewer.css - dynamsoft.webtwain.viewer.js
### Default files * dynamsoft.webtwain.config.js > This file is used to make basic configuration of the Dynamic Web TWAIN library. It's where you enter the product key for the product and to change the initial viewer size, etc. * dynamsoft.webtwain.initiate.js > This file is the core of the Dynamic Web TWAIN library. * dynamsoft.webtwain.initiate_cus.js > This file is the core of the Dynamic Web TWAIN customized library, please do not use it if there is no requirement. * dynamsoft.webtwain.install.js > This file is used to configure the dialogs which are shown when the Dynamic Web TWAIN library is not installed or needs to be upgraded. This file is already referenced inside the dynamsoft.webtwain.initiate.js * Readme.txt * addon + dynamsoft.upload.js > This file contains the functionalities of the Dynamsoft Upload Module. + dynamsoft.webtwain.addon.pdf.js > This file contains the functionalities of the PDF Rasterizer addon. + dynamsoft.webtwain.addon.webcam.js > This file contains the functionalities of the Webcam addon. + dynamsoft.webtwain.addon.barcodereader.js > This file contains the functionalities of the Barcode addon. * dist > Under this directory are the installers for the Dynamsoft Service which needs to be manually installed on each client machine that uses the Dynamic Web TWAIN library as a service. - DynamsoftServiceSetup.deb > For Linux (Debian) - DynamsoftServiceSetup.rpm > For Linux (Redhat) - DynamsoftServiceSetup.msi > For Windows - DynamsoftServiceSetup.pkg > For macOS - LICENSE * src > These files contain the following functionalities > - image input & output > - image decode & encode > - PDF read & write > - Viewer & UI - dynamsoft.lts.js - dynamsoft.webtwain.activex.js - dynamsoft.webtwain.css - dynamsoft.webtwain.viewer.css - dynamsoft.webtwain.viewer.js
### Default files * dynamsoft.webtwain.config.js > This file is used to make basic configuration of the Dynamic Web TWAIN library. It's where you enter the product key for the product and to change the initial viewer size, etc. * dynamsoft.webtwain.initiate.js > This file is the core of the Dynamic Web TWAIN library. * dynamsoft.webtwain.install.js > This file is used to configure the dialogs which are shown when the Dynamic Web TWAIN library is not installed or needs to be upgraded. This file is already referenced inside the dynamsoft.webtwain.initiate.js * Readme.txt * addon + dynamsoft.upload.js > This file contains the functionalities of the Dynamsoft Upload Module. + dynamsoft.webtwain.addon.camera.js > This file contains the functionalities of the Camera addon. + dynamsoft.webtwain.addon.pdf.js > This file contains the functionalities of the PDF Rasterizer addon. + dynamsoft.webtwain.addon.webcam.js > This file contains the functionalities of the Webcam addon. + dynamsoft.webtwain.addon.barcodereader.js > This file contains the functionalities of the Barcode addon. + dbrjs > These files are meant for the barcode reader addon for using by the Camera addon. - dbr.js - dbr-7.4.0.1.full.wasm - dbr-7.4.0.1.full.wasm.js - dbr-7.4.0.1.worker.js * dist > Under this directory are the installers for the Dynamsoft Service which needs to be manually installed on each client machine that uses the Dynamic Web TWAIN library as a service. - DynamsoftServiceSetup.deb > For Linux (Debian) - DynamsoftServiceSetup.rpm > For Linux (Redhat) - DynamsoftServiceSetup.msi > For Windows - DynamsoftServiceSetup.pkg > For macOS - LICENSE * src > These files contain the following functionalities > - image input & output > - image decode & encode > - PDF read & write > - Viewer & UI - dynamsoft.imageio.js - dynamsoft.imageio_wasm-.js - dynamsoft.imagecore-.wasm - dynamsoft.imageio-.wasm - dynamsoft.imageProc-.wasm - dynamsoft.pdfReader-.wasm - dynamsoft.pdfWriter-.wasm - dynamsoft.viewer.css - dynamsoft.viewer.js - dynamsoft.webtwain.css
### Other Resources files The following two files are present in the [Dynamic Web TWAIN package](https://github.com/Dynamsoft/Dynamic-Web-TWAIN). * dynamsoft.webtwain.min.js > This is an all-in-one JavaScript file that consists of the files dynamsoft.webtwain.initiate.js , dynamsoft.webtwain.config.js , dynamsoft.webtwain.install.js as well as all the add-on JavaScript files. If you include this file in the application, you no longer need to include these constituent files separately. * dynamsoft.webtwain.min.mjs > This file is like dynamsoft.webtwain.min.js but is built by the ECMAScript 6 (ES6) standard. It's used by applications (Angular, React, Vue, etc.) that import the `Dynamic Web TWAIN` package as a module.
--- title: What are the differences between TWAIN and WIA? description: What are the differences between TWAIN and WIA? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/difference-between-Twain-and-wia.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/difference-between-Twain-and-wia.md --- # Capture/Image Source ## What are the differences between TWAIN and WIA drivers? TWAIN is the most widely used protocol for physical document scanners. Almost all scanners in the market come with a TWAIN driver and are supported by TWAIN applications like the Dynamic Web TWAIN SDK. `WIA` stands for Windows Image Acquisition, which is a Microsoft driver model for capturing digital images from various devices, such as scanners, cameras and other imaging devices. The WIA protocol is built-in and supported by Windows OS, so no extra driver installation is required. WIA offers standardized hardware compatibility and a stable driver environment, making it easier to integrate imaging capabilities into web scanning applications. Prior to Dynamic Web TWAIN version 18.2, WIA drivers are not officially supported. But `WIA` devices can be used by `TWAIN` applications like `Dynamic Web TWAIN` through a `TWAIN compatibility layer`. This means `WIA` is not supported natively; therefore, when a device supports both `TWAIN` and `WIA`, `TWAIN` is the better option. As of Dynamic Web TWAIN version 18.2, we officially support WIA 2.0 drivers. To make sure your web application works with WIA scanner drivers, please refer to the article: [How do I support WIA scanner drivers in my application?](/_articles/faq/support-wia-scanner-drivers.md){:target="_blank"} --- title: Download virtual scanner for testing description: Download virtual scanner for testing source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/download-virtual-scanner-for-testing.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/download-virtual-scanner-for-testing.md --- # Capture/Image Source ## Download virtual scanner for testing If you do not have a TWAIN scanner on hand to test the library, you can download and use a virtual scanner created by the TWAIN Working Group. - [32-bit virtual scanner](https://www.dynamsoft.com/download/TWAIN/twainds.win32.installer.2.1.3.msi) - [64-bit virtual scanner](https://www.dynamsoft.com/download/TWAIN/twainds.win64.installer.2.1.3.msi) --- title: How to test if your camera is DirectShow compliant description: How to test if your camera is DirectShow compliant source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/how-to-test-if-your-camera-is-DirectShow-compliant.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/how-to-test-if-your-camera-is-DirectShow-compliant.md --- # Capture/Image Source ## How to test if your camera is DirectShow compliant? - [Recommended] Take advantage of our official demo page - Open the demo page on Windows > If you haven't installed the Dynamic Web TWAIN Service, a dialog will show up for you to download and install it. - Make sure the camera shows up in the device list ![Hardware-Scanners-Cameras-10](/assets/imgs/Hardware-Scanners-Cameras-10.png) - Try showing the video stream and try capturing a frame to see if it works without any errors * You can also test with a DirectShow utility such as Amcap (obtainable from third-party sources) to confirm the camera works correctly. --- title: How to test if your device is SANE compliant description: How to test if your device is SANE compliant source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/how-to-test-if-your-device-is-SANE-compliant.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/how-to-test-if-your-device-is-SANE-compliant.md --- # Capture/Image Source ## How to test if your device is SANE compliant? There are 3 ways to verify whether your scanner is SANE compliant. * [Recommended & Easiest] Take advantage of our official demo page - Open the [demo page](https://demo.dynamsoft.com/dwt/online_demo_scan.aspx) on [Linux]({{site.getstarted}}platform.html#browsers-on-linux) > If you haven't installed the Dynamic Web TWAIN Service, a dialog will show up for you to download and install it. - Make sure the scanner driver shows up in the scanner list ![Hardware-Scanners-Cameras-5](/assets/imgs/Hardware-Scanners-Cameras-5.png) - Try scanning to make sure it works correctly without any errors * [Recommended] Try the scanner with the XSane app on Linux. Check out the [official guide](http://www.fifi.org/doc/xsane/html/sane-xsane-doc.html) > [More info>>](/assets/docs/Scanning_with_XSane.pdf) * Check out the [official list](http://www.sane-project.org/sane-backends-1.0.25.html) of supported scanners. --- title: How to test if your scanner supports ICA scanning on Mac OS description: How to test if your scanner supports ICA scanning on Mac OS source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/how-to-test-if-your-scanner-supports-ICA-scanning-on-Mac-OS.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/how-to-test-if-your-scanner-supports-ICA-scanning-on-Mac-OS.md --- # Capture/Image Source ## How to test if your scanner supports ICA scanning on Mac OS? ![Hardware-Scanners-Cameras-2](/assets/imgs/Hardware-Scanners-Cameras-2.png) `ICA Scanners` refer to image scanners that have drivers designed in accordance with the [ImageCaptureCore Framework](https://developer.apple.com/documentation/imagecapturecore). ### Facts about ICA - ICA is a framework from Apple designed to "Browse for media devices and control them programmatically from your app." - ICA is supported on macOS X. ### Is my Scanner ICA Compliant? There are 3 ways to verify whether your scanner is ICA compliant. - [Recommended & Easiest] Take advantage of our official demo page - Open the [demo page](https://demo.dynamsoft.com/dwt/online_demo_scan.aspx) on [macOS]({{site.getstarted}}platform.html#browsers-on-macos) > If you haven't installed Dynamic Web TWAIN, a dialog will show up for you to download and install it. - Make sure the scanner driver shows up in the scanner list. ![Hardware-Scanners-Cameras-5](/assets/imgs/Hardware-Scanners-Cameras-5.png) - Try scanning to make sure it works correctly without any errors * [Recommended] Try the scanner with the ImageCapture app on macOS. - Find the Image Capture application ![Hardware-Scanners-Cameras-12.png](/assets/imgs/Hardware-Scanners-Cameras-12.png) - Open the application ![Hardware-Scanners-Cameras-13.png](/assets/imgs/Hardware-Scanners-Cameras-13.png) - Acquire an image and see how it works ![Hardware-Scanners-Cameras-14.png](/assets/imgs/Hardware-Scanners-Cameras-14.png) For more info, please check out the [official guide](https://support.apple.com/en-ca/guide/image-capture/imgcp1004/mac). - Check out the [official list](https://support.apple.com/en-us/HT201465) of supported ICA scanners on MacOS. --- title: How to use TWACKER to check if your device is TWAIN Compliant description: How to use TWACKER to check if your device is TWAIN Compliant source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/how-to-use-TWACKER-to-check-if-your-device-is-TWAIN-Compliant.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/how-to-use-TWACKER-to-check-if-your-device-is-TWAIN-Compliant.md --- # Capture/Image Source ## How to use TWACKER to check if your device is TWAIN Compliant? - [Recommended] Use the tool called `Twacker` which is developed by the [TWAIN Working Group](https://www.twain.org/) - Download and install > Please download the version of TWACKER that matches your driver architecture, not your operating system architecture. In most cases, this will be 32-bit. - [32-bit](https://download.dynamsoft.com/tool/Twack_32.msi) - [64-bit](https://download.dynamsoft.com/tool/Twack_64.msi) - Open the program ![Hardware-Scanners-Cameras-6](/assets/imgs/Hardware-Scanners-Cameras-6.png) - Select your device ![Hardware-Scanners-Cameras-7](/assets/imgs/Hardware-Scanners-Cameras-7.png) > If your device is not listed, please check if the driver is installed. Or, try running `Twacker` as admin to see if it shows up. - Choose the settings and click the Acquire to start scanning ![Hardware-Scanners-Cameras-8](/assets/imgs/Hardware-Scanners-Cameras-8.png) > If scanning is successful without any errors, then your device should be TWAIN compliant. You can also try other commands to see how it works. If your scanner doesn't work with `TWACKER` , please check your scanner model online and make sure you have installed the (latest) TWAIN driver from its manufacturer. ![Hardware-Scanners-Cameras-9](/assets/imgs/Hardware-Scanners-Cameras-9.png) - Refer to the official [twain-certified-drivers](https://resource.twain.org/twain-certified-drivers/). > This list is maintained by hardware vendors and may be incomplete. In this case, try the two ways above instead. --- title: The connection with the server was terminated abnormally description: The connection with the server was terminated abnormally source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/the-connection-with-the-server-was-terminated-abnormally.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/the-connection-with-the-server-was-terminated-abnormally.md --- # Error Troubleshooting ## The connection with the server was terminated abnormally ### Symptom When you upload images from Dynamic Web TWAIN's buffer, you may receive the following error message returned by the ErrorString property: ![terminated-abnormally](/assets/imgs/terminated-abnormally.png) ### Cause 1. The problem may occur when a connection with the server is not available. 2. The size of images you are going to upload goes beyond the maximum transferable data size which is defined by the server. ### Solution 1. Please make sure the address of the server is available. To check this, you can ping the address from a client machine. Note: Both the machine name and the IP address of the server can be used for the HTTP Upload method. 2. Please make sure you specify the correct port. The default port is 80. If you are using other port, please use HTTPPort to specify it in code. We recommend you get the Port and Server value this way: ```javascript strHTTPServer = location.hostname; WebTWAIN.HTTPPort = location.port == "" ? 80 : location.port; ``` 3. Please reset the maximum transferable data size: - If you are using ASP.NET, you can change the value at the following line in the Web.Config file. ```javascript //You can change the value by yourself. ``` - If you are using PHP, you can change the value at the following line in the php.ini file ```javascript upload_max_filesize = 2M //You can change the value by yourself. ``` - If you are using ASP Scenario #1: using ASP on IIS 6: 1. Start -> Run, type cmd. 2. Go to C:\Inetpub\AdminScripts by typing: cd C:\Inetpub\AdminScripts 3. To view max request entity allowed: cscript adsutil.vbs set w3svc/AspMaxRequestEntityAllowed Scenario #2: using ASP on IIS 7: 1. Start -> Run , type InetMgr to open IIS 7 Manager 2. {Your WebSite} -> Feature View -> ASP -> Limit Properties 3. Set a bigger value for Maximum Requesting Entity Body Limit, like "1000000" --- title: How can I change the reference path to the Dynamsoft's resources in my project? description: How can I change the reference path to the Dynamsoft's resources in my project? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/change-reference-path.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/change-reference-path.md --- View all FAQs about [Project Deployment and End-user Installation]( https://www.dynamsoft.com/web-twain/docs/faq/#project-deployment-and-end-user-installation) # How can I change the reference path to the Dynamsoft's resources in my project? This also applies if you see the following errors in browser console, please make sure that the ResourcesPath is set correctly in *dynamsoft.webtwain.config.js* (Step 3 Below). >{"code": -2803, "message": "Loading the WebTwain JavaScript source files failed."}
>{"code": -2804, "message": "Loading the WebTwain css files failed."} Scenario: For customers who are using Dynamic Web TWAIN, to change the location of the 'Resources' folder, or to rename it, please following the steps below: Steps: In the below example we will assume the original Resources folder is located at '../{Project Directory}/Resources', and you want to change it to '../{Project Directory}/Newfolder/ResourcesTest'. Step 1. Please make sure the structure inside 'Resources' folder stay unchanged. Step 2. Change the relative path in your page where you reference the js files, for example: ```html ``` Modify as below: ```html ``` Step 3. The same change needs to be done in *dynamsoft.webtwain.config.js* file. Add/uncomment the following line, then change 'Resources' (to 'New folder/ResourcesTest' as in this case): ```javascript Dynamsoft.DWT.ResourcesPath = "Resources"; ``` Modify as below: ```javascript Dynamsoft.DWT.ResourcesPath = "Newfolder/ResourcesTest"; ```
--- title: Is there an easy way to deploy the end-user components to all users? description: Is there an easy way to deploy the end-user components to all users? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/deploy-to-all-users.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/deploy-to-all-users.md --- View all FAQs about [Project Deployment and End-user Installation]( https://www.dynamsoft.com/web-twain/docs/faq/#project-deployment-and-end-user-installation) # Is there an easy way to deploy the end-user components to all users? Yes. The following are the commands for this purpose
- [v19.0+](#19plus) - [Versions below 19.0](#19min)
- Windows ```shell msiexec /i "/path/to/DynamicWebTWAINServiceSetup.msi" /qn ``` - macOS ```shell // Install sudo installer -pkg /path/to/DynamicWebTWAINServiceSetup.pkg -target /Applications // Stop service sudo launchctl unload /Library/LaunchAgents/com.dynamsoft.dynamicwebtwainservicex64.plist // Start service launchctl load /Library/LaunchAgents/com.dynamsoft.dynamicwebtwainservicex64.plist ``` - Linux ```shell sudo dpkg -i /path/to/DynamicWebTWAINServiceSetup.deb ``` or ```shell sudo rpm -i path/to/DynamicWebTWAINServiceSetup.rpm ```
- Windows ```shell msiexec /i "/path/to/DynamsoftServiceSetup.msi" /qn ``` - macOS ```shell // Install sudo installer -pkg /path/to/DynamsoftServiceSetup.pkg -target /Applications // Stop service sudo launchctl unload /Library/LaunchAgents/com.dynamsoft.dynamsoftservicex64.plist // Start service launchctl load /Library/LaunchAgents/com.dynamsoft.dynamsoftservicex64.plist ``` - Linux ```shell sudo dpkg -i /path/to/DynamsoftServiceSetup.deb ``` or ```shell sudo rpm -i path/to/DynamsoftServiceSetup.rpm ```
And in a controlled environment, Dynamic Web TWAIN can be distributed to all clients in one go just like other similar programs. [Group Policy](https://docs.microsoft.com/en-us/troubleshoot/windows-server/group-policy/use-group-policy-to-install-software) is one such technology.
--- title: How to uninstall Dynamic Web TWAIN Service? description: How to uninstall Dynamic Web TWAIN Service? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/how-to-uninstall-dynamsoft-service.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/how-to-uninstall-dynamsoft-service.md --- View all FAQs about [Project Deployment and End-user Installation]( https://www.dynamsoft.com/web-twain/docs/faq/#project-deployment-and-end-user-installation) # How to uninstall Dynamic Web TWAIN Service?
- [v19.0+](#19plus) - [Versions below 19.0](#19min)
### On Windows 1. * Remove Dynamic Web TWAIN Service through Control Panel, if you see anything named along the lines of "Dynamsoft " or "Dynamic Web TWAIN ", remove them as well * Remove the folder `C:\Program Files (x86)\Dynamsoft\Dynamic Web TWAIN Service {version number}` 2. Run 'Command Prompt' as **administrator**, go to C:\WINDOWS\system32, then execute the following line (Not applicable if you installed Dynamic Web TWAIN Service through personal installer): ``` shell wmic product where name="Dynamic Web TWAIN Service" call uninstall /nointeractive ``` ### On macOS * Run the file `Uninstall.pkg` . The file can be found in `Go > Applications > Dynamsoft > Dynamic Web TWAIN Service {version number}` * Remove the folder `Go > Applications > Dynamsoft > Dynamic Web TWAIN Service {version number}` ### On Linux * Run the file `uninstall.sh` . The file can be found in `opt/dynamsoft/Dynamic Web TWAIN Service {version number}` * Remove the folder `opt/dynamsoft/Dynamic Web TWAIN Service {version number}`
### On Windows 1. * Remove Dynamsoft Service through Control Panel, if you see anything named along the lines of "Dynamsoft " or "Dynamic Web TWAIN ", remove them as well * Remove the folders `C:\Windows\SysWOW64\Dynamsoft\DynamsoftService` and `C:\Windows\SysWOW64\Dynamsoft\DynamsoftServicex64_{version number}` 2. Run 'Command Prompt' as **administrator**, go to C:\WINDOWS\system32, then execute the following line (Not applicable if you installed Dynamsoft Service through personal installer): ``` shell wmic product where name="Dynamsoft Service" call uninstall /nointeractive ``` ![How-to-uninstall-the-Dynamsoft-Service-without MSI-installer.png](/assets/imgs/How-to-uninstall-the-Dynamsoft-Service-without MSI-installer.png) ### On macOS * Run the file `Uninstall.pkg` . The file can be found in `Go > Applications > Dynamsoft > DynamsoftService > {installed version No.}` * Remove the folder `Go > Applications > Dynamsoft > DynamsoftService > {installed version No.}` ### On Linux * Run the file `uninstall.sh` . The file can be found in `opt/dynamsoft/DynamsoftService` * Remove the folder `opt/dynamsoft/DynamsoftService`
--- title: Can the Dynamic Web TWAIN SDK automatically remove blank pages during the document scanning process? description: Can the Dynamic Web TWAIN SDK automatically remove blank pages during the document scanning process? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/remove-blank-page-automatically.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/remove-blank-page-automatically.md --- # Capture/Image Source ## Can the Dynamic Web TWAIN SDK automatically remove blank pages during the document scanning process? ### Method One If the TWAIN driver of your device supports discarding blank pages, you can use the driver's built-in feature. 1. You can set the [ `IfShowUI` ](/_articles/info/api/WebTwain_Acquire.md#ifshowui) property to true to display the User Interface (UI) of the source and you can check the option there (It normally reads 'discard blank'.). 2. If you don't want to show the user interface of the source, you can set [ `IfAutoDiscardBlankpages` ](/_articles/info/api/WebTwain_Acquire.md#ifautodiscardblankpages) to true or negotiate the ICAP_AUTODISCARDBLANKPAGES capability to discard blank pages automatically. Please NOTE that this property or capability only works if the scanner itself supports the feature (on the hardware level). ```javascript DWTObject.SelectSource(); DWTObject.OpenSource; DWTObject.IfShowUI = false; //*Use the property DWTObject.IfAutoDiscardBlankpages = true; //*Use capability negotiation DWTObject.Capability = Dynamsoft.DWT.EnumDWT_Cap.ICAP_AUTODISCARDBLANKPAGES; DWTObject.CapType = Dynamsoft.DWT.EnumDWT_CapType.TWON_ONEVALUE; DWTObject.CapValue = -1; //Auto if (DWTObject.CapSet) { alert("Successful!"); } DWTObject.AcquireImage(); ``` ### Method Two If the scanner itself doesn't support discarding blank pages, you can also use the [ `IsBlankImageExpress` ](/_articles/info/api/WebTwain_Buffer.md#isblankimageexpress) method to do this as a workaround. To detect and discard blank pages automatically, you can do it in the [ `OnPostTransfer` ](/_articles/info/api/WebTwain_Acquire.md#onposttransfer) event which fires after each transfer. ```javascript function DWTObject_OnPostTransfer() { DWTObject.BlankImageMaxStdDev = 20; if (DWTObject.IsBlankImageExpress(DWTObject.CurrentImageIndexInBuffer)) { DWTObject.RemoveImage(DWTObject.CurrentImageIndexInBuffer); } } ``` NOTE: In many cases, the scanned blank image may come with some noises which would affect the result returned by IsBlankImageExpress. To improve the result, you may adjust the value of the [ `BlankImageMaxStdDev` ](/_articles/info/api/WebTwain_Buffer.md#blankimagemaxstddev) property. The default value is 1 (0 means single-color image). Thus, by increasing the value a little bit (e.g. to 20), noises on images are ignored so a blank image can be detected faster. --- title: Can I still use Dynamic Web TWAIN on non-HTTPS (insecure HTTP) sites with Chrome? description: Can I still use Dynamic Web TWAIN on non-HTTPS (insecure HTTP) sites with Chrome? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/http-insecure-websites-in-chromium-browser.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/http-insecure-websites-in-chromium-browser.md --- View all FAQs about [Project Deployment and End-user Installation]( https://www.dynamsoft.com/web-twain/docs/faq/#project-deployment-and-end-user-installation) # Can I still use Dynamic Web TWAIN on non-HTTPS (insecure HTTP) sites with Chrome? ### Symptom When users access a public HTTP website that uses the Dynamic Web TWAIN SDK in Chromium-based browsers (for example, Chrome and Edge), they may repeatedly see prompts to install the Dynamic Web TWAIN Service (Dynamsoft Service). In the browser console, you may see the following **error message** ```javascript Access to XMLHttpRequest at 'http://127.0.0.1:****' from origin 'http://yourwebsiteURL' has been blocked by CORS policy: The request client is not a secure context and the resource is in more-private address space `local`. ``` This behavior is primarily tied to Chromium security enforcement and may vary by browser and version. ### Reason This is caused by browser security policy changes, not by a bug in Dynamic Web TWAIN itself. Starting from Chrome 94, Chromium introduced stronger Private Network Access restrictions that block requests from insecure public origins (HTTP) to more private addresses such as `localhost` / `127.0.0.1`. More detail can be found at [https://developer.chrome.com/blog/private-network-access-update/](https://developer.chrome.com/blog/private-network-access-update/) Dynamic Web TWAIN uses a local service to communicate with physical scanners, so your web page must call `localhost` or `127.0.0.1`. When the page itself is served over HTTP, modern Chromium security rules can block that communication path. When the page cannot connect to the local service, the SDK may trigger the service installation prompt repeatedly, which is the symptom users see. ### Resolution The long-term direction from browser vendors is stricter security on insecure origins. Any HTTP workaround should be treated as temporary and may be removed in future browser releases. #### Update your public website from HTTP to HTTPS As suggested by Google and Chromium security guidance, the only durable solution is to migrate your public website from HTTP to HTTPS. Once you update your website to HTTPS, please note that you also need to set [IfSSL](/_articles/info/api/WebTwain_IO.md#ifssl) to 'true' and specify the secure port number for SSL connection via the [HTTPPort](/_articles/info/api/WebTwain_IO.md#httpport) API before calling the HTTP upload method of the SDK. \*_If you are using an older version of Dynamic Web TWAIN (v12.3 or earlier), you need to upgrade your SDK to newer version, please contact for further assistance._ #### Workarounds if you need to keep HTTP for some time If you need limited transition time before migrating to HTTPS, you may try one of the following temporary workarounds: 1. [Current / temporary] In current Chrome versions, you can try the `unsafely-treat-insecure-origin-as-secure` flag as a temporary workaround for specific HTTP origins. Step 1: visit chrome://flags/#unsafely-treat-insecure-origin-as-secure Step 2: in "Insecure origins treated as secure", add your HTTP website origin (for example: `http://yourwebsiteURL`) Step 3: relaunch Chrome > Note: This is a temporary workaround for testing or controlled environments, and this flag may also be deprecated and removed in future Chrome versions. For policy background on insecure origins and powerful features, see Chromium's proposal: [Deprecating Powerful Features on Insecure Origins](https://www.chromium.org/Home/chromium-security/deprecating-powerful-features-on-insecure-origins/). 2. [Archived: Chrome 92-136] If you have administrative control over your end users, older Chrome versions supported re-enabling the deprecated behavior through the following enterprise policies: [InsecurePrivateNetworkRequestsAllowed](https://chromeenterprise.google/policies/#InsecurePrivateNetworkRequestsAllowed) [InsecurePrivateNetworkRequestsAllowedForUrls](https://chromeenterprise.google/policies/#InsecurePrivateNetworkRequestsAllowedForUrls) For more details about managing policies for your users, see Google's [help center article](https://support.google.com/chrome/a/answer/9037717). > Note: These policy-based workarounds are archived for older Chrome versions only. They were removed beginning with Chrome 137. 3. [Archived: Prior to Chrome 117] In older Chrome versions, end users could disable this block through a browser flag. Step 1: visit chrome://flags/#block-insecure-private-network-requests Step 2: set "Block insecure private network requests" to `Disabled` ![block-insecure-private-network-request](/assets/imgs/block-insecure-private-network-request.png) > Note: This workaround is archived for older Chrome versions only. The [`block-insecure-private-network-requests`](https://developer.chrome.com/blog/private-network-access-update) flag was removed beginning with Chrome 117. --- title: How can I extend my free trial? description: How can I extend my free trial? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/extend-free-trial.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/extend-free-trial.md --- # SDK Download/Free Trial ## How can I extend my free trial? You can extend your trial license for free on the license page. Each extension is valid for up to 15 days, with a maximum of two extensions allowed. If you need longer period of trial license, please send your project requirement and timeline to support@dynamsoft.com. You can also contact our support team via the online chat service available on our website. --- title: Do you provide free trial versions of the Dynamic Web TWAIN SDK? description: Do you provide free trial versions of the Dynamic Web TWAIN SDK? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/provide-free-trial-version.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/provide-free-trial-version.md --- # SDK Download/Free Trial ## Do you provide free trial versions of the Dynamic Web TWAIN SDK? Yes. We provide free trial of the Dynamic Web TWAIN SDK. You can simply sign up at this page to get the Dynamic Web TWAIN SDK package with a 30-day free trial license included. If you have downloaded our SDK from an external website like Github, please note it doesn't come with any free trial license. However, you can still request for a 15-day free trial license at the trial license center in the Dynamsoft's customer portal. Note: The customer portal would allow you to extend your free trial for up to two times with each extension limited to 15 days. --- title: Do you also provide an SDK download for Linux and Mac developers? description: Do you also provide an SDK download for Linux and Mac developers? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/sdk-download-for-linux-and-mac.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/sdk-download-for-linux-and-mac.md --- # SDK Download/Free Trial ## Do you also provide an SDK download for Linux and Mac developers? Yes. Our Dynamic Web TWAIN SDK package is available for developers who work on Windows, Linux or macOS machines. Please get them from the download center. --- title: Is the free trial version fully functional? description: Is the free trial version fully functional? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/trial-fully-functional.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/trial-fully-functional.md --- # SDK Download/Free Trial ## Is the free trial version fully functional? Yes. The free trial version of the Dynamic Web TWAIN SDK is fully functional. In other words, there is no feature limitation with the free trial version except that the trial SDK comes with a license expiration date. Also, please note the trial version includes all core modules as well as addon modules (e.g., Barcode Reader, PDF Rasterizer, etc.) of the Dynamic Web TWAIN SDK. Once you install the free trial version, you can generally find the Resources and Samples for core and addons under C:\Program Files (x86)\Dynamsoft\Dynamic Web TWAIN SDK {version number}. --- title: Can I use the Dynamic Web TWAIN SDK to create a PWA application? description: Can I use the Dynamic Web TWAIN SDK to create a PWA application? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/use-with-PWA.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/use-with-PWA.md --- # SDK Download/Free Trial ## Can I use the Dynamic Web TWAIN SDK to create a PWA application? Dynamic Web TWAIN is a JavaScript SDK so it can be integrated to a Progressive Web Application (PWA). If you run into any issue, please send the detail to support@dynamsoft.com. --- title: Where can I download an older version of the Dynamic Web TWAIN SDK? description: Where can I download an older version of the Dynamic Web TWAIN SDK? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/download-older-version-sdk.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/download-older-version-sdk.md --- # SDK Download/Free Trial ## Where can I download an older version of the Dynamic Web TWAIN SDK? Visit the customer portal and go to the Download Center to access older SDK versions. Release notes for current and past stable versions are in the [Stable Releases](/_articles/info/schedule/Stable.md) page. Dynamsoft provides maintenance and support for each SDK version for two years from its GA date. If you’re on an older release, plan an upgrade to the latest version. Contact sales@dynamsoft.com with any questions. --- title: Can I run the scanning service on an ARM-based embedded device, such as Raspberry Pi? description: Can I run the scanning service on an ARM-based embedded device, such as Raspberry Pi? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/run-on-arm-based-embedded-device.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/run-on-arm-based-embedded-device.md --- # SDK Download/Free Trial ## Can I run the scanning service on an ARM-based embedded device, such as Raspberry Pi? Starting from version 17.0, we provide an ARM64 version of the Dynamic Web TWAIN Service (also called "Dynamsoft Service"). It can be found in the SDK package (Normally under C:\Program Files (x86)\Dynamsoft\Dynamic Web TWAIN SDK {version number}\Resources\dist) of the Dynamic Web TWAIN SDK from Download Center. So for any ARM64 based devices running on Linux OS, such as Raspberry Pi or Jetson Nano, you can also scan documents from physical scanners to the device's browser clients. MIPS 64-bit version of the Dynamic Web TWAIN Service is also available in the SDK package, if you need to support any MIPS devices. --- title: What image and document formats can I save my documents as? description: What image and document formats can I save my documents as? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/image-document-formats-save.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/image-document-formats-save.md --- # Document Saving ## What image and document formats can I save my documents as? Documents can be saved in BMP / JPEG / TIFF / PNG / PDF format. Notes: - To reduce the size for JPEG/PDF/TIFF format, please check [this article](/_articles/faq/smallest-size-documents.md). - Black & white image data which is 1-bit cannot be saved in the JPEG format as this format supports eight-bit grayscale images and 24-bit color images (eight bits each for red, green, and blue). - Dynamic Web TWAIN can read and write image-based PDF files; however, to read text-based PDF files, the [PDF Rasterizer add-on](/_articles/extended-usage/pdf-processing.md){:target="_blank"} is required. More details of each file type can be found here --- title: How can I change the certificate of the Dynamic Web TWAIN Service? description: How can I change the certificate of the Dynamic Web TWAIN Service? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/change-dynamsoft-service-certificate.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/change-dynamsoft-service-certificate.md --- # Security ## How can I change the certificate of the Dynamic Web TWAIN Service? To replace the default certificate, the steps are: - Generate a certificate for `127.0.0.1` with an RSA private key - Rename the certificate to `server.pem` and the private key to `server_key.pem` - Replace the old keys in the `cert` folder in the [service's installation folder](/_articles/extended-usage/dynamsoft-service-configuration.md#installation-folder) - Restart the service You can also pack the two files into a zip file and use the [configuration page](/_articles/extended-usage/dynamsoft-service-configuration.md#web-setup) to update. ## Appendix ### How to Generate the Certificate with acme.sh? Run the following command to apply for an SSL certificate. ```bash acme.sh --issue -d --keylength 2048 ``` Then, you can find the certificate named `fullchain.cer` and the private key named `your-domain.key` in the output folder. ### What are the Files in the cert Folder * default keys * server.pem * server_key.pem * keys for [local.dynamsoft.com](/_articles/faq/failed-to-load-resource.md) (encrypted, get the latest from [demo site](https://demo.dynamsoft.com/DWT/Resources/dist/cert.zip)) * server.pem.ldsc * server_key.pem.ldsc * keys for [Remote Scan](https://www.dynamsoft.com/remote-scan/docs/introduction/)'s proxy server after installation (encrypted, get the latest from the domain binding page) * server.pem.ldwtc * server_key.pem.ldwtc --- title: How can I enable HTTPS support? description: How can I enable HTTPS support? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/enable-https-support.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/enable-https-support.md --- # Document Saving ## How can I enable HTTPS support? Dynamic Web TWAIN provides SSL support. To enable HTTPS, - Set [IfSSL](/_articles/info/api/WebTwain_IO.md#ifssl){:target="_blank"} to true to turn on SSL in HTTP requests. - Set the SSL port with the API [HTTPPort](/_articles/info/api/WebTwain_IO.md#httpport){:target="_blank"}. - Call the API HTTPUpload to upload the documents. For more information on how to use HTTPUpload, please check [here](/_articles/info/api/WebTwain_IO.md#httpupload){:target="_blank"}. Note that if you use this feature, you need to enable HTTPS on the server. For how to enable HTTPS, please check out the manual of your webserver. --- title: Is the Dynamic Web TWAIN SDK GDPR compliant? description: Is the Dynamic Web TWAIN SDK GDPR compliant? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/gdpr-compliant.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/gdpr-compliant.md --- # Security ## Is the Dynamic Web TWAIN SDK GDPR compliant? Yes. With Dynamic Web TWAIN SDK technologies, all data processing can be done within the client-side devices by using an offline license of the SDK, ensuring full compliance with data protection laws. These include the General Data Protection Regulations (GDPR), effective in Europe from May 2018. You can contact sales@dynamsoft.com for an offline license. Our SDK provides strong security features and is trusted by many companies in different industries across the globe. Please check out our customer stories and testimonies. --- title: Is the Dynamic Web TWAIN SDK HIPAA compliant? description: Is the Dynamic Web TWAIN SDK HIPAA compliant? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/hipaa-compliant.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/hipaa-compliant.md --- # Security ## Is the Dynamic Web TWAIN SDK HIPAA compliant? Yes. With Dynamic Web TWAIN SDK technologies, all data processing can be done within the client-side devices by using an offline license of the SDK, ensuring full compliance with any data protection laws. In other words, the HIPAA compliance of your healthcare solution won't change by integrating our SDK. You can contact sales@dynamsoft.com for an offline license. Dynamsoft is ISO 27001 Certified and our SDK provides strong security features and is trusted by many companies in the Healthcare industry. Please check out our customer stories and testimonies. See more: What is HIPAA --- title: What type of HTTP servers do your support? Do you support other server types? description: What type of HTTP servers do your support? Do you support other server types? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/http-servers-support.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/http-servers-support.md --- # Document Saving ## What type of HTTP servers do your support? Do you support other server types? We support any web servers such Apache, NGINX, IIS, Tomcat, Node.js, etc. We also support Mail/FTP/Database servers. To upload documents via HTTP, we recommend the API [here](/_articles/general-usage/image-export/index.md#upload){:target="_blank"}. Dynamic Web TWAIN sends an HTTP POST request to the server when doing an upload. You need to write your server-side script to receive and save the uploaded files. On the server side, any scripting language can be used. For more information and sample server-side scripts, please refer to [Server Scripts](/_articles/general-usage/server-side-scripting.md){:target="_blank"}, which includes sample scripts on how to save the uploaded file to a database such as MS SQL/Oracle, and how to resend the uploaded file by email. --- title: Can I insert newly scanned pages to an existing document? description: Can I insert newly scanned pages to an existing document? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/insert-new-pages-to-existing-document.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/insert-new-pages-to-existing-document.md --- # Document Saving ## Can I insert newly scanned pages to an existing document? By default, when you scan or load images, they are appended to the end of the image array in buffer. However, in some business scenarios, the user may want to insert these new images to a specified index. Unfortunately, Dynamic Web TWAIN does not provide a native method for that, but you can utilize the property [IfAppendImage](/_articles/info/api/WebTwain_Acquire.md#ifappendimage){:target="_blank"} to achieve it. You can load some images from your local disk first, and then acquire images from your device with IfAppendImage set to 'false'. The following code snippet shows how it can be done. Insert when acquiring ```javascript function acquireToIndex(index) { DWTObject.IfAppendImage = false; DWTObject.CurrentImageIndexInBuffer = index; DWTObject.RegisterEvent("OnPostTransfer", function () { DWTObject.CurrentImageIndexInBuffer++; }); DWTObject.RegisterEvent("OnPostAllTransfers", function () { DWTObject.IfAppendImage = true; }); DWTObject.AcquireImage(); } ``` Insert when loading ```javascript function loadToIndex(index) { var oldCount = DWTObject.HowManyImagesInBuffer; DWTObject.RegisterEvent("OnPostLoad", function () { var newCount = DWTObject.HowManyImagesInBuffer; for (var j = 0; j < newCount - oldCount; j++) DWTObject.MoveImage(oldCount + j, index + j); }); DWTObject.LoadImageEx("", 5); } ``` --- title: Is the Dynamic Web TWAIN SDK ISO 27001 compliant? description: Is the Dynamic Web TWAIN SDK ISO 27001 compliant? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/iso-27001-compliant.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/iso-27001-compliant.md --- # Security ## Is the Dynamic Web TWAIN SDK ISO 27001 compliant? Yes, since April 9, 2021, Dynamsoft has successfully passed the audit and become ISO 27001 certified. We understand the importance of [information security](https://www.dynamsoft.com/Products/Dynamsoft_Security_Whitepaper.pdf) and are committed to remaining one of the most security-compliant companies in the industry. For more information, please check out our blog: Dynamsoft is now ISO 27001 certified! - Dynamsoft Blog --- title: The license key is set in JavaScript. How can I protect it? description: The license key is set in JavaScript. How can I protect it? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/license-key-protection.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/license-key-protection.md --- # Security ## The license key is set in JavaScript. How can I protect it? If you are using Per Client Device or Per Page license of Dynamic Web TWAIN SDK, your license is either the organization ID (which links to the default Handshake Code), the handshake code or both. Therefore, you can simply protect your license by adding security settings to your handshake code in the license portal. - You can set a session password. - You can add your website domain as a validation field. If you are using an offline/non-trackable license, you can configure your license to enable domain binding before activating your license. When you do this, you must make sure your application is deployed to the bound domain, otherwise you will receive an error. > Note - that this a static characteristic of your application, and it cannot be changed after it's configured. --- title: Can I limit the size of documents to be uploaded to my server? description: Can I limit the size of documents to be uploaded to my server? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/limit-upload-size-to-server.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/limit-upload-size-to-server.md --- # Security ## Can I limit the size of documents to be uploaded to my server? Yes. You can use the API [MaxUploadImageSize](/_articles/info/api/WebTwain_IO.md#maxuploadimagesize){:target="_blank"}. Note that your web server may also impose maximum file upload size. For example, the default maximum file upload size in IIS6 is 4 MB and 28.6 MB for IIS7. You can change the maxAllowedContentLength value in web.config, IIS Manager, or ApplicationHost.config file. --- title: When are the locally cached images destroyed? description: When are the locally cached images destroyed? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/local-cached-images-destroyed.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/local-cached-images-destroyed.md --- # Security ## When are the locally cached images destroyed? Dynamic Web TWAIN introduced a disk caching feature to allow saving image data to the local disk. The disk caching feature is enabled by default and can be disabled by setting [IfAllowLocalCache](/_articles/info/api/WebTwain_Buffer.md#ifallowlocalcache){:target="_blank"} to false. You can also set how much memory Dynamic Web TWAIN can use before images start to be cached. By default, 800MB is used. You can change it using the property [BufferMemoryLimit](/_articles/info/api/WebTwain_Buffer.md#buffermemorylimit){:target="_blank"}. All cached data is encrypted, can only be accessed by Dynamic Web TWAIN, and is destroyed when Dynamic Web TWAIN is unloaded. If the SDK exits unexpectedly, all cached data will also be destroyed. For more information on buffer management and local caching, please check here: [Dynamic Web TWAIN Features - Buffer (dynamsoft.com)](/_articles/extended-usage/buffer-caching.md){:target="_blank"}. --- title: Can I prompt the end-user when the Dynamic Web TWAIN SDK attempts to visit any local resources (scanner, camera, or disk drive)? description: Can I prompt the end-user when the Dynamic Web TWAIN SDK attempts to visit any local resources (scanner, camera, or disk drive)? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/prompt-end-user-when-local-resources-used.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/prompt-end-user-when-local-resources-used.md --- # Security ## Can I prompt the end-user when the Dynamic Web TWAIN SDK attempts to visit any local resources (scanner, camera, or disk drive)? Yes, Dynamic Web TWAIN supports authorization for accessing local files, scanners, or webcams. 1. Stop the Dynamic Web TWAIN Service. 2. Add the following three lines to the file `C:\Program Files (x86)\Dynamsoft\Dynamic Web TWAIN Service {version number}\DSConfiguration.ini` (for versions below 19.0, the path is `C:\Windows\SysWOW64\Dynamsoft\DynamsoftServicex64_{version number}\DSConfiguration.ini`): ```javascript EnableScannerAccessAuth=TRUE EnableFileAccessAuth=TRUE EnableWebcamAccessAuth=TRUE ``` 3. Restart the Dynamic Web TWAIN Service. --- title: How can I get a response string from my HTTP Server if the upload succeeds or fails? description: How can I get a response string from my HTTP Server if the upload succeeds or fails? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/response-string-from-server-on-upload.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/response-string-from-server-on-upload.md --- # Document Saving ## How can I get a response string from my HTTP Server if the upload succeeds or fails? ```javascript Every HTTP upload method has two callbacks with signatures like this onEmptyResponse: () => void, onServerReturnedSomething: ( errorCode: number, errorString: string, response: string) => void ``` The 1st callback onEmptyResponse is triggered when the server returns no response string. Generally, if an error has occurred on the server, the server will return some information to indicate what went wrong. Therefore, if nothing is returned, you can treat it as a successful upload. Of course, in your own server-side script to accept and process the HTTP Post request, you know whether the upload is successful and can make it more obvious by returning some custom information to indicate that. In this case, the 2nd callback onServerReturnedSomething will be triggered on purpose and you will need to read the argument response which contains what is returned by the server. > NOTE - When the callback onServerReturnedSomething is triggered, you will always get an errorCode and an errorString but you can choose to ignore them if it's triggered on purpose. Dynamic Web TWAIN also provides an API called [HTTPPostResponseString](/_articles/info/api/WebTwain_IO.md#httppostresponsestring){:target="_blank"} which contains the response and can be read outside of the upload method. --- title: How can I securely transfer scanned documents to my server? description: How can I securely transfer scanned documents to my server? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/securely-transfer-to-server.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/securely-transfer-to-server.md --- # Security ## How can I securely transfer scanned documents to my server? Dynamic Web TWAIN supports downloading/uploading documents via HTTPS. To enable HTTPS, - Set [IfSSL](/_articles/info/api/WebTwain_IO.md#ifssl){:target="_blank"} to true to turn on SSL in HTTP requests - Set the SSL port with the API [HTTPPort](/_articles/info/api/WebTwain_IO.md#httpport){:target="_blank"} - Call the API HTTPUpload to upload the documents To upload documents via HTTP/HTTPS, we recommend the API [here](/_articles/general-usage/image-export/index.md#upload){:target="_blank"}. > Note - that if you use this feature, you need to enable HTTPS on the server. For how to enable HTTPS, please check out the manual of your webserver. --- title: Do I need a separate license for each addon? description: Do I need a separate license for each addon? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/separate-license-for-addon.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/separate-license-for-addon.md --- # Addon ## Do I need a separate license for each addon? Yes—each add-on requires its own license. See pricing at Dynamic Web TWAIN Pricing and the licensing guide at [Using License Keys](/_articles/general-usage/license.md){:target="_blank"}. For per-client-device licenses, you can add an add-on license to the existing project without changing the license key string in your application. Organization ID/handshake details are in the Dynamsoft License Server terms here. --- title: How can I reduce the size of documents in PDF, TIFF or JPEG format? description: How can I reduce the size of documents in PDF, TIFF or JPEG format? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/smallest-size-documents.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/smallest-size-documents.md --- # Document Saving ## How can I reduce the size of documents in PDF, TIFF or JPEG format? There are a few things that you can try to reduce the size of a resulting file - Scan in grayscale or black & white instead of RGB; - Convert the images to grayscale or black & white before the save or upload call. Read more [here](/_articles/general-usage/image-processing/index.md#working-with-pixels-and-bit-depth){:target="_blank"}; - Scan in a lower resolution; - Convert the images to a lower resolution (DPI). Read more [here](/_articles/general-usage/image-processing/index.md#working-with-pixels-and-bit-depth){:target="_blank"}; - [Optional] If the resulting file is in the JPEG format (.jpg) or is a TIF or PDF that is encoded by the JPEG standard, you can set [JPEGQuality](/_articles/info/api/WebTwain_IO.md#jpegquality){:target="_blank"} to a lower value. - Save in PDF format (No PDF Rasterizer Addon license is required for this API), ```javascript DWTObject.Addon.PDF.Write.Setup({compression: Dynamsoft.DWT.EnumDWT_PDFCompressionType.PDF_JPEG, quality: 20}); //or set DWTObject.Addon.PDF.Write.Setup({compression: 5, quality: 20}); which is equivalent. ``` ```html ``` - Save in TIF format, ```javascript DWTObject.TIFFCompressionType = Dynamsoft.DWT.EnumDWT_TIFFCompressionType.TIFF_JPEG; //or set DWTObject.TIFFCompressionType = 7 which is equivalent. DWTObject.JPEGQuality = 20; ``` - Save in JPEG format. ```javascript DWTObject.JPEGQuality = 20; ``` **Note that black & white image cannot be saved in the JPEG format. To reduce the size, please convert the image to grayscale.** --- title: How can I automatically trigger actions when images arrive on my server side? description: How can I automatically trigger actions when images arrive on my server side? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/trigger-actions-server-side.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/trigger-actions-server-side.md --- # Document Saving ## How can I automatically trigger actions when images arrive on my server side? Dynamic Web TWAIN sends an HTTP POST request to the server when doing an upload. You need to write your server-side script to receive and save the uploaded files. On the server side, any scripting language can be used. The server-side script file is specified in the POST Form with the name RemoteFile by default and will be triggered to process the uploaded file. To change the default field name RemoteFile, you can use the API [HttpFieldNameOfUploadedImage](/_articles/info/api/WebTwain_IO.md#httpfieldnameofuploadedimage){:target="_blank"}. For Server-side Scripting examples, please check [this](/_articles/general-usage/server-side-scripting.md){:target="_blank"}. --- title: Can I upload documents to a different website domain? description: Can I upload documents to a different website domain? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/upload-documents-to-different-domain.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/upload-documents-to-different-domain.md --- # Document Saving ## Can I upload documents to a different website domain? Yes, if your web server is configured to allow cross domain requests. Please check your web server manual for instructions on how to configure it to allow cross domain requests. If your web server does not allow accessing from a different domain and you are uploading or downloading to/from a web server in a different domain than your current website, you will get a CORS error as described here: [XMLHttpRequest cannot load XXX ](/_articles/faq/XMLHttpRequest-cannot-load.md) --- title: How can I upload a JSON file to my server? description: How can I upload a JSON file to my server? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/upload-json-files-to-server.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/upload-json-files-to-server.md --- # Document Saving ## How can I upload a JSON file to my server? While you cannot send a JSON file with HTTPUpload, you can send the JSON string with the API [SetHTTPFormField](/_articles/info/api/WebTwain_IO.md#sethttpformfield){:target="_blank"}. Dynamic Web TWAIN sends an HTTP POST request to the server when doing an upload. The SetHTTPFormField() method is used to [add extra fields to the HTTP form](/_articles/faq/additional-form-fields.md){:target="_blank"}. Just like how you can add extra text information to the form, you can also add the JSON string to it. --- title: Can I upload documents via a background service outside the web browser? description: Can I upload documents via a background service outside the web browser? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/upload-using-background-service.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/upload-using-background-service.md --- # Document Saving ## Can I upload documents via a background service outside the web browser? Yes. You can use the File Uploader to create and run an upload job. The File Uploader is an independent component that is dedicated to file uploading. It can be used seamlessly with Dynamic Web TWAIN. Learn about how to use the File Uploader [here](/_articles/general-usage/image-export/server-upload.md#fileuploader). --- title: Does the Dynamic Web TWAIN SDK use any deprecated technologies like NPAPI or ActiveX? description: Does the Dynamic Web TWAIN SDK use any deprecated technologies like NPAPI or ActiveX? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/use-deprecated-technology.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/use-deprecated-technology.md --- # Security ## Does the Dynamic Web TWAIN SDK use any deprecated technologies like NPAPI or ActiveX? Dynamic Web TWAIN no longer uses NPAPI. ActiveX support was removed starting in v19.0 (see the [Removed Features](/_articles/info/schedule/Stable.md#removed-features){:target="_blank"} in the release notes). We added HTML5 support long before Chrome dropped NPAPI, so web scanning remains supported without deprecated tech. Customers should migrate off ActiveX; modern versions require the HTML5 edition. --- title: Where does the Dynamic Web TWAIN SDK store images on end-user machines? Are they encrypted? description: Where does the Dynamic Web TWAIN SDK store images on end-user machines? Are they encrypted? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/where-images-are-stored.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/where-images-are-stored.md --- # Security ## Where does the Dynamic Web TWAIN SDK store images on end-user machines? Are they encrypted? Images are stored in the memory buffer on end-user machines. Since memory configuration is limited on end-user machines, Dynamic Web TWAIN introduced a disk caching feature to allow saving image data to the local disk. The disk caching feature is enabled by default and can be disabled by setting [IfAllowLocalCache](/_articles/info/api/WebTwain_Buffer.md#ifallowlocalcache){:target="_blank"} to false. You can also set how much memory Dynamic Web TWAIN can use before images start to be cached. By default, 800MB is used. You can change it using the property [BufferMemoryLimit](/_articles/info/api/WebTwain_Buffer.md#buffermemorylimit){:target="_blank"}. All cached data is encrypted, can only be accessed by Dynamic Web TWAIN, and is destroyed when Dynamic Web TWAIN is unloaded. For more information, please check here: [Dynamic Web TWAIN Features - Buffer](/_articles/extended-usage/buffer-caching.md){:target="_blank"}. --- title: Does your Barcode Reader addon support patch code? description: Does your Barcode Reader addon support patch code? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/does-barcode-addon-support-patch-code.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/does-barcode-addon-support-patch-code.md --- # Addon ## Does your Barcode Reader addon support patch code? Yes. Configure it in the barcode types list shown here: [Specify the Barcode Type(s) to Read](/_articles/extended-usage/barcode-processing.md#specify-the-barcode-types-to-read){:target="_blank"}. --- title: How can I generate PDF/A files? description: How can I generate PDF/A files? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/generate-pdf-files.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/generate-pdf-files.md --- # Addon ## How can I generate PDF/A files? Dynamic Web TWAIN supports exporting documents as **PDF/A** starting from version **19.3**. PDF/A is an archival format designed for long-term preservation. The following variants are supported: ### Supported PDF/A Versions | PDF/A Variant | Underlying PDF Version | |:-------------:|-----------------------------| | `pdf/a-1b` | **1.4** (default) | | `pdf/a-2b` | **1.5** (default), 1.6, 1.7 | ### What’s the difference between PDF/A-1b and PDF/A-2b? Although both variants ensure that documents can be reliably displayed in the future, they differ in terms of supported PDF features and compression options. - PDF/A-1b - Uses the older PDF 1.4 specification. - **Does not support JPEG2000** or JBIG2 image compression. - Does not allow transparency. - May result in larger file sizes and more conversion restrictions. - PDF/A-2b - Based on newer PDF versions (1.5–1.7). - Supports **JPEG2000**, JBIG2, transparency, and other modern PDF features. - Typically requires **fewer changes** to the source document. - Usually produces **smaller output** files. **Recommendation:** For most use cases, we recommend using **`pdf/a-2b`**. It offers better compression support, fewer limitations, and higher compatibility with modern PDFs while still meeting archival requirements. ### Licensing Requirements Dynamic Web TWAIN does not require any add-on license to **export** or generate PDF or PDF/A files. However, PDF Rasterizer add-on would be required when **loading** a PDF/PDF-A file that contains **text or vector graphics**. You can programmatically check whether a file needs rasterization using [`IsRasterizationRequired()`](/_articles/info/api/Addon_PDF.md#israsterizationrequired): ```javascript DWTObject.Addon.PDF.IsRasterizationRequired(path); // returns true or false ``` ### Behavior and Defaults - If you do not set `pdfaVersion`, the export uses standard PDF format (non-PDF/A). - If you set `pdfaVersion` but forget to set `version`, or set a mismatched or incorrect PDF version, Dynamic Web TWAIN automatically falls back to a default PDF version: - `pdf/a-1b` → defaults to PDF `1.4` - `pdf/a-2b` → defaults to PDF `1.5` ### How to Export as PDF/A Configure PDF output using [`Write.Setup()`](/_articles/info/api/Addon_PDF.md#writesetup) before calling any save function. ```javascript DWTObject.Addon.PDF.Write.Setup({ version: "1.5", // [optional] 1.4 for "pdf/a-1b"; 1.5/1.6/1.7 for "pdf/a-2b" pdfaVersion: "pdf/a-2b" // "pdf/a-1b" or "pdf/a-2b" }); ``` After configuring `pdfaVersion`, all APIs that output PDF files will automatically generate PDF/A-compliant PDFs. This includes, but is not limited to: - **Save APIs** like: [`SaveAsPDF()`](/_articles/info/api/WebTwain_IO.md#saveaspdf), [`SaveSelectedImagesAsMultiPagePDF()`](/_articles/info/api/WebTwain_IO.md#saveselectedimagesasmultipagepdf), [`SaveAllAsPDF()`](/_articles/info/api/WebTwain_IO.md#saveallaspdf) - **Conversion APIs** like: [`ConvertToBlob()`](/_articles/info/api/WebTwain_IO.md#converttoblob), [`ConvertToBase64()`](/_articles/info/api/WebTwain_IO.md#converttobase64) - **Upload APIs** like: [`HTTPUpload()`](/_articles/info/api/WebTwain_IO.md#httpupload), [`FTPUpload()`](/_articles/info/api/WebTwain_IO.md#ftpupload), [`httpUploadBlob()`](/_articles/info/api/WebTwain_IO.md#httpuploadblob) - **OCR Output APIs** like: [`SaveToPath()`](/_articles/info/api/Addon_OCR.md#savetopath), [`SaveAsBase64()`](/_articles/info/api/Addon_OCR.md#saveasbase64), [`SaveAsBlob()`](/_articles/info/api/Addon_OCR.md#saveasblob) --- title: Do I need the PDF Rasterizer addon to convert scanned documents to PDF files? description: Do I need the PDF Rasterizer addon to convert scanned documents to PDF files? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/is-pdf-rasterizer-needed-to-convert-scanned-documents-to-pdf.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/is-pdf-rasterizer-needed-to-convert-scanned-documents-to-pdf.md --- # Addon ## Do I need the PDF Rasterizer addon to convert scanned documents to PDF files? No. Dynamic Web TWAIN can output images as image-based PDF files and this is built into the core module, so no addon is required to convert scanned documents to PDF files. --- title: How can I load PDF/A files into the Dynamic Web TWAIN SDK? description: How can I load PDF/A files into the Dynamic Web TWAIN SDK? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/load-pdf-files.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/load-pdf-files.md --- # Addon ## How can I load PDF/A files into the Dynamic Web TWAIN SDK? Dynamic Web TWAIN can load PDF/A files. Whether you need the **[PDF Rasterizer Add-on (PDFR)](https://www.dynamsoft.com/web-twain/pdf-to-image-javascript/)** depends entirely on the contents of the PDF/A document: - If the PDF/A contains **text or vector graphics**, rasterization is required → **PDFR license needed**. - If the PDF/A contains **only raster images**, the file can be loaded **without** the PDFR add-on. > [!NOTE] > **Looking for information about generating PDF/A files?** > > Starting from Dynamic Web TWAIN 19.3, PDF/A creation is supported. > > See: [How can I generate PDF/A files?](/_articles/faq/generate-pdf-files.md) ### How to check whether rasterization is required You can programmatically detect whether a given PDF/A file requires rasterization before loading it: ```javascript DWTObject.Addon.PDF.IsRasterizationRequired(path); // returns true or false ``` If this method returns **`true`**, the SDK will need the PDFR to process the file. ### When rasterization actually happens Dynamic Web TWAIN performs rasterization **only when necessary**. If [`IsRasterizationRequired()`](/_articles/info/api/Addon_PDF.md#israsterizationrequired) returns **`true`** and the PDF Rasterizer license is configured, the SDK automatically rasterizes the PDF into images using the reader settings you specify. The rasterization behavior—including resolution (default **200 DPI**) and other rendering parameters—can be customized through [`SetReaderOptions()`](/_articles/info/api/Addon_PDF.md#setreaderoptions). Rasterization may occur when using any of these APIs (including drag-and-drop): - [ `LoadImage()` ](/_articles/info/api/WebTwain_IO.md#loadimage) - [ `LoadImageEx()` ](/_articles/info/api/WebTwain_IO.md#loadimageex) - [ `LoadImageFromBase64Binary()` ](/_articles/info/api/WebTwain_IO.md#loadimagefrombase64binary) - [ `LoadImageFromBinary()` ](/_articles/info/api/WebTwain_IO.md#loadimagefrombinary) - [ `FTPDownload()` ](/_articles/info/api/WebTwain_IO.md#ftpdownload) - [ `FTPDownloadEx()` ](/_articles/info/api/WebTwain_IO.md#ftpdownloadex) - [ `HTTPDownload()` ](/_articles/info/api/WebTwain_IO.md#httpdownload) - [ `HTTPDownloadEx()` ](/_articles/info/api/WebTwain_IO.md#httpdownloadex) - [ `HTTPDownloadThroughPost()` ](/_articles/info/api/WebTwain_IO.md#httpdownloadthroughpost) - [ `HTTPDownloadDirectly()` ](/_articles/info/api/WebTwain_IO.md#httpdownloaddirectly) --- title: Can I load specific page numbers of a PDF file into the viewer? description: Can I load specific page numbers of a PDF file into the viewer? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/load-specific-page-of-pdf-to-viewer.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/load-specific-page-of-pdf-to-viewer.md --- # Addon ## Can I load specific page numbers of a PDF file into the viewer? Dynamic Web TWAIN does not provide a native method that supports loading specific page numbers of a PDF file. However, it can be done by following the steps below - a. register the [OnPostLoad](/_articles/info/api/WebTwain_IO.md#onpostload){:target="_blank"} event which is triggered once the entire file has been loaded to the viewer - b. In the event function, remove the unwanted pages (API [RemoveImage](/_articles/info/api/WebTwain_Buffer.md#removeimage){:target="_blank"}) - c. load the file to the viewer (e.g. API [LoadImage](/_articles/info/api/WebTwain_IO.md#loadimage){:target="_blank"}) --- title: How can I separate my documents automatically by barcode? description: How can I separate my documents automatically by barcode? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/separate-documents-by-barcode.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/separate-documents-by-barcode.md --- # Addon ## How can I separate my documents automatically by barcode? When dealing with batch documents, barcodes can function as a smart separator, or to properly group documents. For example, by affixing a barcode to each document in a batch and then scanning it, the files can be automatically grouped or separated. They can be automatically made into multi-page TIFF or PDF files. All of this can be accomplished with a single batch scan by integrating the Core Module and Barcode Reader add-on of Dynamic Web TWAIN SDK. Please refer to the two examples with sample codes here: [Use barcode to classify and separate documents](/_articles/extended-usage/barcode-processing.md#use-barcode-to-classify-and-separate-documents){:target="_blank"}. Here is a sample project you can try and download: Automate Document Classification Using Barcode Separator. --- title: Is there any way to speed up the barcode reading process? description: Is there any way to speed up the barcode reading process? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/speed-up-barcode-reading-process.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/speed-up-barcode-reading-process.md --- # Addon ## Is there any way to speed up the barcode reading process? There are several runtime settings you can use to speed up the barcode reading process: - Specify the Barcode Type(s) to Read - Specify maximum barcode count - Specify a scan Region - Use the built-in mode 'speed' For more details on runtime settings, please check [here](/_articles/extended-usage/barcode-processing.md#runtime-settings){:target="_blank"}. In addition, the size of the image generated during the scanning process also impacts the reading performance. You can check your scanning settings to balance the image qualify and size. --- title: What types of webcams does the Webcam Capture addon support description: What types of webcams does the Webcam Capture addon support source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/webcam-supported-by-webcam-capture-addon.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/webcam-supported-by-webcam-capture-addon.md --- # Addon ## What types of webcams does the Webcam Capture addon support? The webcams supported are DirectShow Cameras which are either built into desktops/laptops or connected via USB. Please check here for more information about these cameras and to check if your camera is DirectShow compliant. --- title: When do I need PDF Rasterizer Addon? Can I load existing PDF files into the Dynamic Web TWAIN SDK without the PDF Rasterizer addon? description: When do I need PDF Rasterizer Addon? Can I load existing PDF files into the Dynamic Web TWAIN SDK without the PDF Rasterizer addon? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/when-is-pdf-rasterizer-needed.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/when-is-pdf-rasterizer-needed.md --- # Addon ## When do I need PDF Rasterizer Addon? Can I load existing PDF files into the Dynamic Web TWAIN SDK without the PDF Rasterizer addon? Third-party generated PDF files may house multiple images, text, or annotations in a single PDF page. As these elements must be rendered within the Dynamic Web TWAIN, it will utilize the PDF rasterizer addon. When importing a PDF file generated by Dynamic Web TWAIN, or if each page of a third-party PDF holds nothing but a single image, there's no need for the PDF rasterizer addon. If you need to append images to an existing PDF and want to keep the original pages instead of rasterized images in the saved PDF, you need to enable the [`preserveUnmodifiedOnSave`](/_articles/info/api/interfaces.md#:~:text=preserveUnmodifiedOnSave){:target="_blank"} property. --- title: Error Message - Failed to load resource description: Error Message - Failed to load resource source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/failed-to-load-resource.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/failed-to-load-resource.md --- # Error Troubleshooting ## Error Message - Failed to load resource: net::ERR_CERT_DATE_INVALID ### Symptom You get an error message that says **"Failed to load resource: net::ERR_CERT_DATE_INVALID https://local.dynamsoft.com:18623/f/VersionInfo?ts=XXXXXXXXXXXX"**. And the browser keeps asking to install the Dynamic Web TWAIN Service (previously called "Dynamsoft Service"). ### Cause By default, "127.0.0.1" is used for service connection. "127.0.0.1" uses a self-signed SSL certificate without an expiry date. It is installed to your system so that the browser can trust it. If your environment requires high level security, self-signed certificates may not be accepted. Moreover, it is not easy to install the self-signed certificate for systems like Chrome OS. In this case, we provide a domain, "local.dynamsoft.com", which points to "127.0.0.1". It has a VeriSign’ed certificate that has an expiry date. The most recent expired "local.dynamsoft.com" certificate expired on 2025 November 20th, and the latest certificate will expire on 2026 November 21st. > [!NOTE] > All official third-party certificates come with an expiry date (generally one year). If `local.dynamsoft.com` is used, the certificate needs to be updated each year. ### Resolution - **No High Level Security Requirement**: Set back to self-signed certificate "127.0.0.1" by comment the line `Dynamsoft.WebTwainEnv.Host = "local.dynamsoft.com"` or `Dynamsoft.DWT.Host="local.dynamsoft.com"` out. No need to worry about the expiry date of the certificate anymore. - **High Level Security Requirement** > [!WARNING] > If you use `local.dynamsoft.com`, replace the certificate annually due to expiration. If you have to use "local.dynamsoft.com", the following methods can be taken: - Method 1. Use the following links to download and install the Dynamic Web TWAIN Service Installer. > [!IMPORTANT] > Dynamic Web TWAIN Service installers are backward-compatible within the same major version. Identify the major SDK version first, then download the corresponding installer (for example, 19.x SDK uses v19 installers, 18.x SDK uses v18 installers). If you are unsure about your SDK version, follow [How do I know which SDK version I am using?](/_articles/faq/find-SDK-version.md).
- Windows - macOS - Linux
> Choose between Admin (requires admin privileges) or Personal (for individual users). - Version 19 - [Windows Installer (Admin)](https://download2.dynamsoft.com/Demo/DWT/Resources/dist/19.3.2/DynamicWebTWAINServiceSetup.msi) - [Windows Installer (Personal)](https://download2.dynamsoft.com/Demo/DWT/Resources/dist/19.3.2/DynamicWebTWAINServiceSetup.exe) - Version 18 - [Windows Installer (Admin)](https://download2.dynamsoft.com/Demo/DWT/Resources/dist/18.5.4/DynamsoftServiceSetup.msi) - [Windows Installer (Personal)](https://download2.dynamsoft.com/Demo/DWT/Resources/dist/18.5.4/DynamsoftServiceSetup.exe)
> Use the installer matching your SDK version. - [macOS Installer v19](https://download2.dynamsoft.com/Demo/DWT/Resources/dist/19.3.2/DynamicWebTWAINServiceSetup.pkg) - [macOS Installer v18](https://download2.dynamsoft.com/Demo/DWT/Resources/dist/18.5.4/DynamsoftServiceSetup.pkg)
> Select the installer format based on your distribution type. - RPM Packages (Red Hat, Fedora, CentOS, etc.) - [Linux RPM Installer v19](https://download2.dynamsoft.com/Demo/DWT/Resources/dist/19.3.2/DynamicWebTWAINServiceSetup.rpm) - [Linux RPM Installer v18](https://download2.dynamsoft.com/Demo/DWT/Resources/dist/18.5.4/DynamsoftServiceSetup.rpm) - DEB Packages (Ubuntu, Debian, etc.) - [Linux DEB Installer v19](https://download2.dynamsoft.com/Demo/DWT/Resources/dist/19.3.2/DynamicWebTWAINServiceSetup.deb) - [Linux DEB Installer v18](https://download2.dynamsoft.com/Demo/DWT/Resources/dist/18.5.4/DynamsoftServiceSetup.deb) - ARM64 Architecture - [Linux ARM64 DEB Installer v19](https://download2.dynamsoft.com/Demo/DWT/Resources/dist/19.3.2/DynamicWebTWAINServiceSetup-arm64.deb) - [Linux ARM64 DEB Installer v18](https://download2.dynamsoft.com/Demo/DWT/Resources/dist/18.5.4/DynamsoftServiceSetup-arm64.deb) - MIPS Architecture - [Linux MIPS DEB Installer v19](https://download2.dynamsoft.com/Demo/DWT/Resources/dist/19.3.2/DynamicWebTWAINServiceSetup-mips64el.deb) - [Linux MIPS DEB Installer v18](https://download2.dynamsoft.com/Demo/DWT/Resources/dist/18.5.4/DynamsoftServiceSetup-mips64el.deb)
- Method 2. Click here to download the new certificate and use the new server.pem.ldsc & server_key.pem.ldsc to replace the old one in the `cert` folder under the service's [installation folder](/_articles/extended-usage/dynamsoft-service-configuration.md#installation-folder). Then restart Dynamic Web TWAIN Service. - Method 3. [Contact Dynamsoft](/_articles/about/getsupport.md){:target="_blank"} for a new service installer for client-side. Please specify the exact service version build number found from the version your client currently has installed. - Method 4. You can also generate the certificate by yourself. Check out this [post](/_articles/faq/change-dynamsoft-service-certificate.md).
--- title: Request header field dwt-md5 is not allowed by Access-Control-Allow-Headers in preflight response description: Request header field dwt-md5 is not allowed by Access-Control-Allow-Headers in preflight response source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/dwt-md5-is-not-allowed.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/dwt-md5-is-not-allowed.md --- # Error Troubleshooting ## Request header field dwt-md5 is not allowed by Access-Control-Allow-Headers in preflight response ### Symptom When uploading images, the request fails with this CORS error. ### Cause `dwt-md5` is a built-in header Dynamic Web TWAIN uses to validate upload integrity. Because it’s non-standard, browsers send a preflight OPTIONS request to confirm the header is allowed. If your server doesn’t allow it, the upload fails. ### Solution Allow the `dwt-md5` header in your server’s CORS configuration. For IIS, add: ```xml ``` > Note > > After updating the server configuration file, you'll need to restart the server (i.e. IIS). Check out more info [here](https://fetch.spec.whatwg.org/#http-cors-protocol) --- title: Error message - The current product key does not support XXX, please contact the site administrator description: Error message - The current product key does not support XXX, please contact the site administrator source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/error-message-current-product-key-does-not-support.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/error-message-current-product-key-does-not-support.md --- # Error Troubleshooting ## Error message - The current product key does not support XXX, please contact the site administrator ### Symptom You get an error message that says "The current product key does not support xxx…" or "The current product key is invalid because …". ### Cause You are trying to use an unlicensed feature of Dynamic Web TWAIN or use it on an unlicensed Platform or Browser . ### Resolution Make sure you have the correct license set in the proper configuration. If you have any questions please contact Dynamsoft Support. --- title: Error message - The current product key is empty or invalid, please contact the site administrator description: Error message - The current product key is empty or invalid, please contact the site administrator source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/error-message-current-product-key-is-empty-or-invalid.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/error-message-current-product-key-is-empty-or-invalid.md --- # Error Troubleshooting ## Error message - The current product key is empty or invalid, please contact the site administrator ### Symptom You get an error message that says "The current product key is empty or invalid, please contact the site administrator". ### Cause You are trying to use an unlicensed feature of Dynamic Web TWAIN or use it on an unlicensed platform or browser. ### Resolution Make sure you have the correct license set in the proper configuration. If you have any questions please contact Dynamsoft Support. --- title: Error message - The domain of your current site does not match the domain bound in the current product key, please contact the site administrator. description: Error message - The domain of your current site does not match the domain bound in the current product key, please contact the site administrator. source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/error-message-domain-of-site-doesnt-match-domain-bound-to-product-key.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/error-message-domain-of-site-doesnt-match-domain-bound-to-product-key.md --- # Error Troubleshooting ## Error message - The domain of your current site does not match the domain bound in the current product key, please contact the site administrator. ### Symptom When you visit a Dynamic Web TWAIN application, you may be met with this error message. ### Cause To protect your license, you can bind it to your domain. When you do this, you must make sure your application is deployed to the bound domain, otherwise you will receive the error. ### Resolution Make sure you deployed the application to the domain bound to your license or add the domain to your license bindings by contacting Dynamsoft Support. --- title: Error message - The current product key is invalid because it's generated with the licenses of a different major version description: Error message - The current product key is invalid because it's generated with the licenses of a different major version source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/error-message-license-generated-with-license-of-major-version.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/error-message-license-generated-with-license-of-major-version.md --- # Error Troubleshooting ## Error message - The current product key is invalid because it's generated with the licenses of a different major version ### Symptom You get an error message that says "The current product key is invalid because it's generated with the licenses of a different major version". ### Cause You are trying to use a product key for a different major version. ### Resolution Make sure you have the correct license set in the proper configuration. If you have doubts or questions, you can contact Dynamsoft Support. --- title: Error message - The current product key does not support current OS for embed device, please contact the site administrator description: Error message - The current product key does not support current OS for embed device, please contact the site administrator source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/error-message-product-key-does-not-support-current-os.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/error-message-product-key-does-not-support-current-os.md --- # Error Troubleshooting ## Error message - The current product key does not support current OS for embed device, please contact the site administrator ### Symptom You get an error message that says "The current product key does not support current OS for embed device, please contact the site administrator". ### Cause You are trying to use a product key on an unlicensed OS. ### Resolution Make sure you have the correct license set in the proper configuration and that the license you own covers the platform you are attempting to use. If you have any questions please contact Dynamsoft Support. --- title: Error message – Your Dynamic Web TWAIN product key expired description: Error message – Your Dynamic Web TWAIN product key expired source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/error-message-product-key-expired.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/error-message-product-key-expired.md --- # Error Troubleshooting ## Error message – Your Dynamic Web TWAIN product key expired ### Symptom You see the following pop-up ![Product key expired](/assets/imgs/product-key-expired.png) ### Cause The trial product key has expired. ### Resolution Follow the instructions on that pop-up which are: 1. Request a new trial product key here. Refer to [this article](/_articles/indepth/development/upgrade.md#update-the-license-key){:target="_blank"} to update the ProductKey 2. Do a hard refresh or clear cache in your browser to make sure the new ProductKey is used --- title: Error message - The current product key is missing the core license, please contact the site administrator description: Error message - The current product key is missing the core license, please contact the site administrator source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/error-message-product-key-is-missing-the-core-license.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/error-message-product-key-is-missing-the-core-license.md --- # Error Troubleshooting ## Error message - The current product key is missing the core license, please contact the site administrator ### Symptom You get an error message that says "The current product key is missing the core license, please contact the site administrator". ### Cause You are missing a license for the core module of Dynamic Web TWAIN, most likely only an addon license has been used. ### Resolution Make sure you have the correct license set in the proper configuration. See [Using full licenses](/_articles/general-usage/license.md#using-full-licenses){:target="_blank"} for guidance. If you have doubts or questions, you can contact Dynamsoft Support. --- title: Error message - The current product key is not for full/trial version, please contact the site administrator description: Error message - The current product key is not for full/trial version, please contact the site administrator source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/error-message-product-key-is-not-for-full-version.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/error-message-product-key-is-not-for-full-version.md --- # Error Troubleshooting ## Error message - The current product key is not for full/trial version, please contact the site administrator You are trying to use a product key full/trial version that does not match with the Dynamic Web TWAIN Service (also called "Dynamsoft Service") full/trial version. Please uninstall your local Dynamic Web TWAIN Service first and access the page again to install the correct version. Or make sure you have the correct license set in the proper configuration. If you have any questions please contact Dynamsoft Support. --- title: General troubleshooting steps description: Step-by-step guide for collecting verbose logs and reporting issues to Dynamsoft Support. source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/general-troubleshooting-steps.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/general-troubleshooting-steps.md --- # Error Troubleshooting ## General Troubleshooting Steps Before contacting support, complete the following steps: 1. Try the [Dynamic Web TWAIN online demo](https://demo.dynamsoft.com/web-twain/) to check whether the issue is reproducible outside your own application. 2. Open the browser developer tools (F12) and check the **Console** and **Network** tabs for errors. Note any error messages. 3. Enable verbose logging and collect the log files as described below. ## Enable and Collect Verbose Logs 1. Remove old log files in the `log` folder under the service's [installation folder](/_articles/extended-usage/dynamsoft-service-configuration.md#installation-folder). 2. Set the log level using one of the options below: - **Option A (recommended) — Single client machine (no coding required):** Use the Dynamic Web TWAIN Service information page. 1. Open [http://127.0.0.1:18625/](http://127.0.0.1:18625/) in a browser on the client machine. 2. Under **Detailed information**, locate the **Log** row. 3. Click **(change)** to enable verbose logging. > [!NOTE] > If **(change)** is not available, enable Web Setup by setting `EnableWebSetup=TRUE` in `DSConfiguration.ini` (admin privileges required), then restart the Dynamic Web TWAIN Service. See [Web Setup](/_articles/extended-usage/dynamsoft-service-configuration.md#web-setup). ![DWT Service page — click (change) to enable verbose logging](/assets/imgs/dwt-service-log-change.png) - **Option B — Single client machine:** Add the line `LogLevel=14` to `DSConfiguration.ini` on the machine. The `DSConfiguration.ini` file is in the **parent directory** of the log folder. - **Option C — All client machines (application-wide):** Set [`LogLevel`](/_articles/info/api/WebTwain_Util.md#loglevel) to `1` in your application code. This should be set as early as possible when the `WebTwain` instance is created — for example, in the `Dynamsoft_OnReady` event: ```javascript function Dynamsoft_OnReady() { DWTObject = Dynamsoft.DWT.GetWebTwain("dwtcontrolContainer"); DWTObject.LogLevel = 1; } ``` 3. Perform a hard refresh (**Ctrl + F5**) on the application page and reproduce the issue. 4. Optionally, create a `.txt` file noting the exact time the issue occurred and place it in the same log folder — this helps pinpoint the relevant log entries faster. 5. Zip the log folder and share it with the [Dynamsoft Support Team](/_articles/about/getsupport.md). > [!IMPORTANT] > After collecting the logs, disable verbose logging — leaving it enabled will affect scanning performance. > - **Option A**: Click **(change)** again on the service page. > - **Option B**: Remove the `LogLevel` line from `DSConfiguration.ini`. > - **Option C**: Set `DWTObject.LogLevel` back to `0` in your application code. --- title: Sequence error description: Sequence error source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/sequence-error.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/sequence-error.md --- # Error Troubleshooting ## Sequence error ### Symptom When you fail to acquire images from your scanner, you may get this error. ### Cause This problem occurs when the correct order of operations is not followed for the TWAIN sequence. ### Resolution Check if you followed the acquisition sequence to get images from your device. For example, some methods and properties, like the [PixelType](/_articles/info/api/WebTwain_Acquire.md#pixeltype) property, can only be used after calling the [OpenSource()](/_articles/info/api/WebTwain_Acquire.md#opensource) method. Please check the TWAIN State Transition Diagram below for more information ![TWAIN State Transition](/assets/imgs/TWAIN-State-Transition.png) --- title: Source is connected to the maximum supported number of applications description: Source is connected to the maximum supported number of applications source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/source-connected-to-maximum.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/source-connected-to-maximum.md --- # Error Troubleshooting ## Source is connected to the maximum supported number of applications ### Symptom When you try to acquire images, you may get this error. ### Cause The problem may occur when the source is **not** disabled completely after a transfer ends or is used by other applications. ### Resolution - Check whether another application is using the source. If yes, close it and try again. - Set [IfDisableSourceAfterAcquire](/_articles/info/api/WebTwain_Acquire.md#ifdisablesourceafteracquire) to `true` and use [CloseSource()](/_articles/info/api/WebTwain_Acquire.md#closesource) to make sure that the source is closed after a scanning session. ```javascript function btnScan_onclick() { DWTObject.RegisterEvent("OnPostAllTransfers", function () { DWTObject.CloseSource(); }); DWTObject.SelectSource(); DWTObject.CloseSource(); //close source before open DWTObject.OpenSource(); DWTObject.IfDisableSourceAfterAcquire = true; //close the scanner UI after acquiring DWTObject.AcquireImage(); } ``` - Reboot your device. --- title: Syntax error – Unexpected Token "<" description: Syntax error – Unexpected Token "<" source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/syntax-error-unexpected-token.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/syntax-error-unexpected-token.md --- # Error Troubleshooting ## Syntax error – Unexpected Token "<" This is usually because the request to load our resources is returning a 404 error. Please make sure the path to dwt-resources is correct and that you can find \*.viewer.js under the src folder. If it does not exist, please manually copy the Dynamic Web TWAIN resources to that folder. Please refer to this link for more details on server deployment [Dynamic Web TWAIN Deployment - Server Deployment](/_articles/general-usage/server-deployment.md){:target="_blank"}. --- title: What is your discount policy? description: What is your discount policy? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/discount-policy.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/discount-policy.md --- # Licensing and Purchase ## What is your discount policy? We offer discounts based on the below mentioned criteria: - Educational and non-profit discounts are available. Please send your info to sales@dynamsoft.com to see if you are qualified. - Discounts are also available for volume purchases or licenses for non-production use. Please contact us to get a discounted quote. --- title: Does the per-server license allow unlimited number of client devices and end users? description: Does the per-server license allow unlimited number of client devices and end users? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/does-per-server-allow-unlimited.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/does-per-server-allow-unlimited.md --- # Licensing and Purchase ## Does the per-server license allow unlimited number of client devices and end users? Yes. With per server license, you get an unlimited number of client devices and end users. Note that every VM or machine (either a server or workstation) that hosts the web app needs a 1-server license seat. If your application is a commercial cloud service, the per-server license may not be applicable. Please submit your requirement via this quote form to our sales team so we can provide proper licensing option to fit in your need. --- title: Are you flexible to discuss custom licensing models? description: Are you flexible to discuss custom licensing models? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/flexible-to-custom-license.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/flexible-to-custom-license.md --- # Licensing and Purchase ## Are you flexible to discuss custom licensing models? Yes. We understand our standard options may not cover your need, so we are very flexible with different licensing metrics to best serve your business. Please submit your request via this form or directly contact us. --- title: Do I get free upgrade if there is a newer version available? description: Do I get free upgrade if there is a newer version available? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/free-upgrade.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/free-upgrade.md --- # Licensing and Purchase ## Do I get free upgrade if there is a newer version available? If you have a valid annual maintenance contract with us, then you are eligible for free upgrades as well as premium tech support. If you don't know the status of your maintenance contract, please send your license info to sales@dynamsoft.com. --- title: Is internet connectivity required to use all licenses? description: Is internet connectivity required to use all licenses? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/is-internet-connectivity-required.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/is-internet-connectivity-required.md --- # Licensing and Purchase ## Is internet connectivity required to use all licenses? No it is not mandatory, but different licensing options leverage different techniques. Generally, you need to use a license server program to distribute your purchased license seats to specified devices. Option #1: Connect to a license server hosted by Dynamsoft - Dynamsoft has the license server hosted on Amazon's AWS. If your device can connect to the internet, you can easily license your devices this way. More Detail > Option #2: Host the license server program on your own server machine - By hosting the license server internally, all your devices can get licensed via your intranet. This is suggested if you don't allow internet connection of your devices. More Detail > Option #3: Discuss custom licensing with Dynamsoft - If neither of the above options is desired, we can also provide a non-tracking offline license with a trust-based agreement signed by both parties. Please contact us to discuss it. --- title: What if I reach the limit of the granted number of license seats? description: What if I reach the limit of the granted number of license seats? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/license-limit-reached.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/license-limit-reached.md --- # Licensing and Purchase ## What if I reach the limit of the granted number of license seats? For Per Client Device or Per Page licensing model, we offer some additional quota at no cost in case you can't extend or expand the license in time. For details, see What happens if my license runs out?. To avoid running out of licensed seats suddenly, Dynamsoft sends notification emails automatically to licensees about the status of the license. Please refer to Usage Alerts. For other licensing models, please refer to the contract or agreement you signed or contact your account manager for help. --- title: Do you have any local resellers from whom I can purchase a license of the Dynamic Web TWAIN SDK? description: Do you have any local resellers from whom I can purchase a license of the Dynamic Web TWAIN SDK? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/local-resellers.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/local-resellers.md --- # Licensing and Purchase ## Do you have any local resellers from whom I can purchase a license of the Dynamic Web TWAIN SDK? Yes. To see if there is an authorized local reseller in your region, please go to this page. If you can't find an appropriate one from the list, you can contact your preferred local reseller and have them email reseller@dynamsoft.com for quick registration. The registration process takes 1 - 3 business days. Or, contact us so we can look into it directly. --- title: Do you offer lifetime/perpetual licenses? description: Do you offer lifetime/perpetual licenses? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/offer-perpetual-license.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/offer-perpetual-license.md --- # Licensing and Purchase ## Do you offer lifetime/perpetual licenses? Yes, we offer a lifetime/perpetual license, which typically includes one year of software maintenance service. To receive upgrades and premium technical support, you would need to renew your yearly maintenance. Learn more about [the benefits of maintenance](https://www.dynamsoft.com/company/annual-maintenance/). To obtain pricing for your specific scenario, please visit our "[Ask for Quote](https://www.dynamsoft.com/store/dynamic-web-twain/)" page. --- title: Do I need to purchase a license for my dev or testing environment? description: Do I need to purchase a license for my dev or testing environment? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/purchase-dev-or-test-license.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/purchase-dev-or-test-license.md --- # Licensing and Purchase ## Do I need to purchase a license for my dev or testing environment? The answer will depend upon the timeframe in which it is used and the environment in which you are testing. - For ongoing development and testing, you can purchase a license from the online store to cover your usage. If you expect to consume a large volume of scans or browser clients during your dev or testing, please contact us for a discount. - For evaluation, you can use the 30-day free trial SDK provided by Dynamsoft. - For temporary development and testing, you can contact support@dynamsoft.com or log into the customer portal to get a 15-day (max. 30 days) temporary license. --- title: What's your refund policy? description: What's your refund policy? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/refund-policy.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/refund-policy.md --- # Licensing and Purchase ## What's your refund policy? - All purchases are governed by our 30-Day Money-Back Guarantee policy. - If you are not completely satisfied, you may request a full refund by sending an e-mail to sales@dynamsoft.com within 30 days of purchasing a license. --- title: For the per-client-device licensing model, can seats taken by retired/unused devices be released from the license? description: For the per-client-device licensing model, can seats taken by retired/unused devices be released from the license? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/release-license-seats.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/release-license-seats.md --- # Licensing and Purchase ## For the per-client-device licensing model, can seats taken by retired/unused devices be released from the license? Yes. Seats tied to a device are automatically released if that device hasn’t used the SDK for 90 days. A client device is simply the end user’s computer (Windows/macOS/Linux). --- title: I need to resell the SDK within my application to my customers. What options do you offer? description: I need to resell the SDK within my application to my customers. What options do you offer? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/resell-sdk.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/resell-sdk.md --- # Licensing and Purchase ## I need to resell the SDK within my application to my customers. What options do you offer? We are happy to discuss an OEM partnership agreement with you if you are selling your commercial application with our SDK integrated to your end customers. You may submit your requirement via this quote form and our sales team will contact you for further discussion. --- title: Will a client machine take an additional license seat if its operating system is reinstalled? description: Will a client machine take an additional license seat if its operating system is reinstalled? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/seat-taken-if-os-reinstalled.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/seat-taken-if-os-reinstalled.md --- # Licensing and Purchase ## Will a client machine take an additional license seat if its operating system is reinstalled? Yes, When a client device is licensed, a random UUID is issued to the client device. Reinstalling the device OS would erase the UUID, so if the device accesses the SDK feature again, it will take a new UUID – i.e. a new license seat will be taken. However, if an UUID has no usage of the SDK for consecutive 90 days, the license seat taken by the UUID will be automatically released. Furthermore, our Per-Client-Device license allows you to overuse up to an additional 10% of the purchased device quota, which helps relieve minor misuse or device reinstallation. For example, if you purchase a license for 100 client devices, you can actually license 110 devices. --- title: What license should I purchase if I am providing SaaS? description: What license should I purchase if I am providing SaaS? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/which-license-purchase-needed-for-saas.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/which-license-purchase-needed-for-saas.md --- # Licensing and Purchase ## What license should I purchase if I am providing SaaS? The Per Client Device licensing model suits any usage scenarios including SaaS. Please note that Dynamsoft Sales team is open to discuss any custom licensing option that may better fit in your need. To help us learn your requirement in detail, we recommend that you submit your requirement via this quote form and our team will contact you for further discussion. --- title: How can I verify if my physical document scanner works with the Dynamic Web TWAIN SDK? description: How can I verify if my physical document scanner works with the Dynamic Web TWAIN SDK? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/verify-if-device-is-supported.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/verify-if-device-is-supported.md --- # Capture/Image Source ## How can I verify if my physical document scanner works with the Dynamic Web TWAIN SDK? Dynamsoft supports the following types of scanners: - TWAIN Scanners (for Windows) - ICA Scanners (for macOS) - SANE Scanners (for Linux) There are two ways to check if a physical document scanner is compatible: 1) Verify via Dynamsoft's Online Demo The fastest and most convenient way is to check using our online demo, which is built based on the Dynamic Web TWAIN SDK. If your scanner shows in the source list and can scan documents properly, it means it works well with our SDK. ![source check using demo](/assets/imgs/source-check-using-demo.png) 2) Use Native Program to Verify ### For Windows Use the tool called Twacker which is developed by the TWAIN Working Group to verify if a scanner is TWAIN compatible on a Windows machine. 1. Download and install (Note: Please download the version of TWACKER that matches your driver architecture, not your operating system architecture. In most cases, it would be 32-bit.) - 32-bit - 64-bit 2. Open the program 3. Select your device from File -> Select Source... (Note: If your device is not listed, please check if the driver is installed. Or, try running Twacker as admin to see if it shows up.) 4. Try scanning a document via Acquire... ![source check using Twacker](/assets/imgs/source-check-using-twacker.png) If scanning is successful without any errors, then your device should be TWAIN compliant. You can also try other commands to see how it works. If your scanner doesn't work with TWACKER, please check your scanner model online and make sure you have installed the (latest) TWAIN driver from its manufacturer. ### For macOS Use the Image Capture app (provided by Apple Inc.) to verify if a scanner is ICA compatible on a macOS machine. 1. Find the Image Capture application ![source check using mac](/assets/imgs/source-check-using-mac.png) 2. Open the application 3. Acquire an image and see how it works ![source check using mac 2](/assets/imgs/source-check-using-mac-2.png) For more info, please check out the official guide. ### For Linux Use the XSane app to verify if a scanner is SANE compatible on a Linux machine. Please check out the official guide for more details. --- title: How can I use a custom capability of my scanner hardware when there is no direct API to set it? description: How can I use a custom capability of my scanner hardware when there is no direct API to set it? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/custom-capability.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/custom-capability.md --- # Capture/Image Source ## How can I use a custom capability of my scanner hardware when there is no direct API to set it? You can use Capability Negotiation to set it. Capability Negotiation is the way a TWAIN application communicates with a TWAIN source. This is how Dynamic Web TWAIN communicates with a scanner. The process looks something like this: - [Dynamic Web TWAIN] Are you capable of \*\*\*? - [Scanner] Yes, and here is what I can do… - [Dynamic Web TWAIN] Great, here is what I want done… - [Scanner] Consider it done The steps are: 1. Use [getCapabilities](/_articles/info/api/WebTwain_Acquire.md#getcapabilities){:target="_blank"} to find the capability you want to set. ```javascript DWTObject.OpenSource(); DWTObject.getCapabilities( function () { console.log(arguments); }, function (error) { console.log(error); } ); ``` - Alternatively, you can install the [TWAIN Sample App](http://www.dynamsoft.com/download/support/twainapp.win32.installer.msi) to check the capabilities available and their values. 2. Use [setCapabilities](/_articles/info/api/WebTwain_Acquire.md#setcapabilities){:target="_blank"} to set the capability. ```javascript DWTObject.setCapabilities( { exception: "ignore", capabilities: [ { capability: Dynamsoft.DWT.EnumDWT_Cap.ICAP_CONTRAST, curValue: 500, // set the contrast to 500 exception: "fail", }, ], }, function (result) { console.log(result); }, function (error) { console.log(error); } ); ``` --- title: Can the Dynamic Web TWAIN SDK detect whether papers exist on the flatbed? description: Can the Dynamic Web TWAIN SDK detect whether papers exist on the flatbed? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/detect-paper-on-flatbed.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/detect-paper-on-flatbed.md --- # Capture/Image Source ## Can the Dynamic Web TWAIN SDK detect whether papers exist on the flatbed? Yes. You can use [IfFeederLoaded](/_articles/info/api/WebTwain_Acquire.md#iffeederloaded){:target="_blank"} API to inspect whether papers are loaded in the feeder of your current scanner. Before calling this API, please use [IfPaperDetectable](/_articles/info/api/WebTwain_Acquire.md#ifpaperdetectable){:target="_blank"} to inspect whether your current scanner hardware has a sensor to detect papers. Code Example: ```javascript DWTObject.SelectSource(); DWTObject.OpenSource(); if(DWTObject.IfPaperDetectable) if(DWTObject.IfFeederLoaded) DWTObject.AcquireImage(); else alert("There is no paper in the feeder."); ... ... ``` --- title: Document scanning via the Dynamic Web TWAIN SDK is slower than using the native scanner application. How can I speed it up? description: Document scanning via the Dynamic Web TWAIN SDK is slower than using the native scanner application. How can I speed it up? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/document-scanning-slow-than-native.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/document-scanning-slow-than-native.md --- # Capture/Image Source ## Document scanning via the Dynamic Web TWAIN SDK is slower than using the native scanner application. How can I speed it up? First, confirm you are using the same scan settings (color mode, DPI, duplex, etc.) as the native app. If settings match, look for extra work in your callbacks. Check code in `AcquireImage()` callbacks like [`OnPostTransfer`](/_articles/info/api/WebTwain_Acquire.md#onposttransfer){:target="_blank"} and [`OnPostAllTransfers`](/_articles/info/api/WebTwain_Acquire.md#onpostalltransfers){:target="_blank"}. If you must run per-page logic, prefer [`OnPostTransferAsync`](/_articles/info/api/WebTwain_Acquire.md#onposttransferasync){:target="_blank"} to avoid blocking the scan pipeline. If the scanning performance issue persists, please contact us. --- title: Can I download an image from an FTP or HTTP server using the Dynamic Web TWAIN SDK? description: Can I download an image from an FTP or HTTP server using the Dynamic Web TWAIN SDK? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/download-image-from-FTP-or-HTTP-server.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/download-image-from-FTP-or-HTTP-server.md --- # Capture/Image Source ## Can I download an image from a FTP or HTTP server using the Dynamic Web TWAIN SDK? Yes, you can download an image from a FTP or HTTP server using the Dynamic Web TWAIN SDK by using FTPDownload and HTTPDownload. You can find [here](/_articles/info/api/WebTwain_IO.md#input-methods){:target="_blank"} all the input methods that are provided by Dynamic Web TWAIN SDK. --- title: Do you support fingerprint or medical imaging devices? description: Do you support fingerprint or medical imaging devices? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/fingerprint-medical-imaging.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/fingerprint-medical-imaging.md --- # Capture/Image Source ## Do you support fingerprint or medical imaging devices? The Dynamic Web TWAIN SDK works with any TWAIN specification compatible devices including fingerprint devices. However, there are not many fingerprint devices that provide TWAIN drivers. You can refer to this blog for some info. For medical imaging devices, DICOM is a common specification, which is not supported by our Dynamic Web TWAIN SDK. --- title: Can I hide offline scanner devices from the select source list? description: Can I hide offline scanner devices from the select source list? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/hide-offline-scanners-from-source-list.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/hide-offline-scanners-from-source-list.md --- # Capture/Image Source ## Can I hide offline scanner devices from the select source list? Generally, the modern scanner drivers have the functionality to auto-hide themselves if they are not connected. If your scanner doesn't hide itself when it is offline, unfortunately, there is no good way to automatically remove this offline device from showing on the source list. If your requirement is to hide some specific devices (e.g. hide all Epson scanners) from the source list, this could be achieved by using the below example: ```javascript var sources = DWTObject.GetSourceNames(); for (var i = 0; i < sources.length; i++) { if (sources[i].toLowerCase().indexOf("epson") != -1) { sources.splice(i, 1); } } ``` --- title: Can I hide webcam devices from the select source list? description: Can I hide webcam devices from the select source list? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/hide-webcam-from-source-list.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/hide-webcam-from-source-list.md --- # Capture/Image Source ## Can I hide webcam devices from the select source list? Many webcam devices may use WIA drivers. As explained in this article, WIA drivers can also be detected by the Dynamic Web TWAIN SDK. If you need to exclude webcam/camera devices, you can try using [GetDeviceType](/_articles/info/api/WebTwain_Acquire.md#getdevicetype){:target="_blank"} API to verify if a source is a scanner or not. If not, you can skip it from your source list. Please note that you would need to call [OpenSource](/_articles/info/api/WebTwain_Acquire.md#opensource){:target="_blank"} API to open a source before you can inspect its device type. If there are any offline devices in the source name list, this process would be interrupted. Another workaround is to exclude some sources by detecting certain keywords from the source name list. E.g. you can try to exclude any source names with 'camera' or 'webcam'. Please refer to this [FAQ](/_articles/faq/hide-offline-scanners-from-source-list.md){:target="_blank"} for more details. --- title: Can I import existing images or PDF documents using the Dynamic Web TWAIN SDK? description: Can I import existing images or PDF documents using the Dynamic Web TWAIN SDK? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/import-existing-documents-or-images.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/import-existing-documents-or-images.md --- # Capture/Image Source ## Can I import existing images or PDF documents using the Dynamic Web TWAIN SDK? Yes, Dynamic Web TWAIN supports loading PNG, JPG, BMP, image-only PDF, and TIFF files. But if you need to support text-based PDF files, you also require the PDF Rasterizer Addon. **Code snippet** ```javascript var onSuccess = function() { console.log("Loaded a file successfully!"); }; var onFailure = function(errorCode, errorString) { console.log(errorString); }; DWTObject.IfShowFileDialog = true; // PDF Rasterizer Addon is used here to ensure text-based PDF support DWTObject.Addon.PDF.SetReaderOptions({ convertMode: Dynamsoft.DWT.EnumDWT_ConvertMode.CM_RENDERALL, renderOptions:{ renderAnnotations: true, resolution: 300, } }); DWTObject.LoadImage(); ``` #### Related Links [PDF Rasterizer Guide](/_articles/extended-usage/pdf-processing.md){:target="_blank"}. [API Documentation](/_articles/info/api/Addon_PDF.md) --- title: How can I set the last selected source as the default source for an end user? description: How can I set the last selected source as the default source for an end user? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/last-selected-sourcename.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/last-selected-sourcename.md --- # Capture/Image Source ## How can I set the last selected source as the default source for an end user? [DefaultSourceName](/_articles/info/api/WebTwain_Acquire.md#defaultsourcename){:target="_blank"} is the API which you can use to leverage this functionality. Example: ![default sourcename](/assets/imgs/default-sourcename.png) --- title: Is there a limit on the number of pages I can scan at a time? Where do you store them after scanning? description: Is there a limit on the number of pages I can scan at a time? Where do you store them after scanning? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/limit-on-scanned-pages.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/limit-on-scanned-pages.md --- # Capture/Image Source ## Is there a limit on the number of pages I can scan at a time? Where do you store them after scanning? Dynamic Web TWAIN Desktop Service edition allows you to scan unlimited number of pages from a physical document scanner. The Desktop Service edition can run in 32-bit and 64-bit and the data is stored raw in DIB format. Starting from version 15.0, 64-bit has been made the default option on a 64-bit OS and that means the available address space is large enough that you are unlikely to hit memory limits in normal scenarios. However, physical memory size is always finite, so a good practice is to store images to memory by default and temporarily cache some images to the local disk when the used memory size exceeds a specific value (e.g. 800MB). Note the disk caching feature is turned on by default and you can change the setting by using the following APIs - [IfAllowLocalCache](/_articles/info/api/WebTwain_Buffer.md#ifallowlocalcache){:target="_blank"} - [BufferMemoryLimit](/_articles/info/api/WebTwain_Buffer.md#buffermemorylimit){:target="_blank"} (defaults to 800MB) --- title: How can I limit all users to use a specific scanner model? description: How can I limit all users to use a specific scanner model? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/limit-to-specific-scanner.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/limit-to-specific-scanner.md --- # Capture/Image Source ## How can I limit all users to use a specific scanner model? You can limit all the users to use a specific scanner model by automatically selecting that scanner programmatically. Use the method [SelectSourceByIndex()](/_articles/info/api/WebTwain_Acquire.md#selectsourcebyindex){:target="_blank"} to select a scanner by its index in the source list. In some cases, you may want to select a source by its name as shown in the example below. This way you can use the specific scanner model. ```javascript var sources = DWTObject.GetSourceNames(); sources.find(function (name, index) { //"EPSON DS-530" is the name of the scanner if (name === "EPSON DS-530") DWTObject.SelectSourceByIndex(index); }); ``` --- title: How can I get a list of supported resolution/DPI values from the document scanner? description: How can I get a list of supported resolution/DPI values from the document scanner? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/list-supported-resolution-DPI.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/list-supported-resolution-DPI.md --- # Capture/Image Source ## How can I get a list of supported resolution/DPI values from the document scanner? You can use capability negotiation to get all the resolutions supported by the scanner. Steps: - Step-1: Use [getCapabilities](/_articles/info/api/WebTwain_Acquire.md#getcapabilities){:target="_blank"} to get all capabilities of the current data source, ```javascript DWTObject.OpenSource(); DWTObject.getCapabilities( function () { console.log(arguments); }, function (error) { console.log(error); } ); ``` and then find the capability corresponding to the resolution. Normally, it is called ICAP_XRESOLUTION. ![Capability Resolution](/assets/imgs/capability-resolution.png) - Step-2: Call the following code to get all the resolutions supported by the scanner. ```javascript DWTObject.OpenSource(); DWTObject.getCapabilities( function (result) { for (var i = 0; i < result.length; i++) { if (result[i].capability.value === Dynamsoft.DWT.EnumDWT_Cap.ICAP_XRESOLUTION) { if (result[i].conType.label === 'TWON_ENUMERATION') { // If the capability's Value Type is Enumeration dpi = result[i].values; console.log(dpi); // The list of supported resolution. } else if (result[i].conType.label === 'TWON_RANGE') { // If the capability's Value Type is Range max = result[i].maxValue; min = result[i].minValue; step = result[i].stepSize; console.log("maxValue: " + max); // The maximum value for the resolution. console.log("minValue: " + min); // The minimum value for the resolution. console.log("stepSize: " + step); // The step size for the resolution. } else { console.log("Please contact Dynamsoft for help."); } } } }, function (error) { console.log(error); } ); ``` --- title: Can I set my document scanner to scan x pages instead of all pages from the automatic document feeder (ADF)? description: Can I set my document scanner to scan x pages instead of all pages from the automatic document feeder (ADF)? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/scan-x-pages-from-automatic-document-feeder.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/scan-x-pages-from-automatic-document-feeder.md --- # Capture/Image Source ## Can I set my document scanner to scan x number of pages instead of all pages from the automatic document feeder (ADF)? Yes. You can use [XferCount](/_articles/info/api/WebTwain_Acquire.md#xfercount){:target="_blank"} to set the number of pages you'd like to scan from the feeder at a time. However, please note that the XferCount API is a hardware-dependent feature, so it only works properly if your scanner device supports it. --- title: Can I set scanning settings without using the default scanner's UI? What pre-scanning settings do you support? description: Can I set scanning settings without using the default scanner's UI? What pre-scanning settings do you support? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/setting-scan-settings-without-ui.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/setting-scan-settings-without-ui.md --- # Capture/Image Source ## Can I set scanning settings without using the default scanner's UI? What pre-scanning settings do you support? Yes, you can set the scanner settings without using the default scanner's UI. By setting [IfShowUI](/_articles/info/api/WebTwain_Acquire.md#ifshowui){:target="_blank"} to false, the default scanner's UI is hidden. Then, you can instead set multiple settings by passing the configuration settings to acquire image api. Please refer to [this API instruction page](/_articles/info/api/WebTwain_Acquire.md#acquireimage){:target="_blank"} for more details. --- title: Do you support capturing documents from mobile cameras? description: Do you support capturing documents from mobile cameras? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/support-capture-from-mobile-camera.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/support-capture-from-mobile-camera.md --- # Capture/Image Source ## Do you support capturing documents from mobile camera? While Dynamic Web TWAIN has discontiued its support of using mobile cameras starting from version [18.1](/_articles/info/schedule/Stable.md#181-01122023), we are introducing [Mobile Document Scanner](https://www.dynamsoft.com/use-cases/mobile-document-scanner/) for better performance and customizability. --- title: How can I trigger an automatic workflow right after document scanning or image importing? description: How can I trigger an automatic workflow right after document scanning or image importing? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/trigger-automatic-workflow-after-scanning.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/trigger-automatic-workflow-after-scanning.md --- # Capture/Image Source ## How can I trigger an automatic workflow right after document scanning or image importing? There are many events available to help you build an automatic business workflow in your document scanning application. If you scan papers from your physical document scanners, you can use the [OnPostTransfer](/_articles/info/api/WebTwain_Acquire.md#onposttransfer){:target="_blank"} or [OnPostTransferAsync](/_articles/info/api/WebTwain_Acquire.md#onposttransferasync){:target="_blank"} event to trigger actions right after each page is successfully scanned. You can use [OnPostAllTransfers](/_articles/info/api/WebTwain_Acquire.md#onpostalltransfers){:target="_blank"} if you need to trigger any actions once all pages are scanned successfully. If you import images from your local disk, you can use the [OnPostLoad](/_articles/info/api/WebTwain_IO.md#onpostload){:target="_blank"} event which triggers right after each file is successfully loaded. --- title: Can I use built-in or USB webcam to capture document? description: Can I use built-in or USB webcam to capture document? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/use-usb-webcam-to-capture.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/use-usb-webcam-to-capture.md --- # Capture/Image Source ## Can I use built-in or USB webcam to capture document? Yes, you can use either the built-in webcam or a USB-connected webcam to capture documents. To verify if your device supports the DirectShow architecture, you can test it using the [online demo](https://demo.dynamsoft.com/web-twain/camera-scan). --- title: What physical document scanners does the Dynamic Web TWAIN SDK support? description: What physical document scanners does the Dynamic Web TWAIN SDK support? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/what-physical-scanners-are-supported.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/what-physical-scanners-are-supported.md --- # Capture/Image Source ## What physical document scanners does the Dynamic Web TWAIN SDK support? Dynamic Web TWAIN's main feature is interacting with imaging devices like scanners and cameras. Here is the list of supported document scanners. 1. TWAIN Scanners (for Windows) 2. ICA Scanners (for macOS) 3. SANE Scanners (for Linux) You can learn more details about each type of device on this page. TWAIN, ICA and SANE are free scanner driver specifications and they have been adopted by almost all the scanner manufacturers in the market. Network scanners are also supported as long as there is a TWAIN/ICA/SANE scanner driver available. Therefore, Dynamic Web TWAIN SDK has great compatibilities with almost all scanners in the market. Note that ScanSnap is one known scanner model that is not TWAIN compliant. To verify if your scanner is compatible with our SDK, you can refer to [this article](/_articles/faq/verify-if-device-is-supported.md). --- title: How can I change the display language of all messages from English to another language? description: How can I change the display language of all messages from English to another language? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/change-display-language.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/change-display-language.md --- # UI Customization ## How can I change the display language of all messages from English to another language? You can customize the display language in dynamsoft.webtwain.config.js by changing the values of the properties of the Dynamsoft.DWT.CustomizableDisplayInfo object. ```javascript Dynamsoft.DWT.CustomizableDisplayInfo = { errorMessages: { // launch ERR_MODULE_NOT_INSTALLED: "Error: The Dynamic Web TWAIN module is not installed.", ERR_BROWSER_NOT_SUPPORT: "Error: This browser is currently not supported.", ERR_CreateID_MustNotInContainers: "Error: Duplicate ID detected for creating Dynamic Web TWAIN objects, please check and modify.", ERR_CreateID_NotContainer: "Error: The ID of the DIV for creating the new DWT object is invalid.", ERR_DWT_NOT_DOWNLOADED: "Error: Failed to download the Dynamic Web TWAIN module.", // image view limitReachedForZoomIn: "Error: You have reached the limit for zooming in", limitReachedForZoomOut: "Error: You have reached the limit for zooming out", // image editor insufficientParas: "Error: Not enough parameters.", invalidAngle: "Error: The angle you entered is invalid.", invalidHeightOrWidth: "Error: The height or width you entered is invalid.", imageNotChanged: "Error: You have not changed the current image.", }, // launch generalMessages: { checkingDWTVersion: "Checking WebTwain version ...", updatingDService: "Dynamic Web TWAIN Service is updating ...", downloadingDWTModule: "Downloading the Dynamic Web TWAIN module.", refreshNeeded: "Please REFRESH your browser.", downloadNeeded: "Please download and install the Dynamic Web TWAIN.", DWTmoduleLoaded: "The Dynamic Web TWAIN module is loaded.", }, customProgressText: { // html5 event upload: "uploading...", download: "Downloading...", load: "Loading...", decode: "Decoding...", decodeTIFF: "Decoding tiff...", decodePDF: "Decoding pdf...", encode: "Encoding...", encodeTIFF: "Encoding tiff...", encodePDF: "Encoding pdf...", // image control canvasLoading: "Loading ...", }, // image editor buttons: { titles: { previous: "Previous Image", next: "Next Image", print: "Print Image", scan: "Acquire new Image(s)", load: "Load local Image(s)", 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", }, }, 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!", ], }, }; ``` For the Dynamic Web TWAIN Service (also called "Dynamsoft Service") installation message below, you can customize the display language by searching for `Dynamsoft._show_install_dialog` in dynamsoft.webtwain.install.js, and changing the display language accordingly. ![install dialog](/assets/imgs/Initialization-1.png) --- title: How can I change/hide the spinner which shows during document scanning? description: How can I change/hide the spinner which shows during document scanning? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/change-hide-spinner.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/change-hide-spinner.md --- # UI Customization ## How can I change/hide the spinner which shows during document scanning? You can change/hide the loading bar which is shown during document scanning. The detailed steps can be found in [this link](/_articles/extended-usage/ui-customization.md#loading-bar-and-backdrop){:target="_blank"}.
> Note: there is a known issue in v17.3, if you cannot hide the loading bar with the above method, please refer to this [link](/_articles/faq/unable-hide-loading-bar.md).
--- title: Can I customize UI elements of the built-in image editor? description: Can I customize UI elements of the built-in image editor? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/customize-ui-elements-of-image-editor.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/customize-ui-elements-of-image-editor.md --- # UI Customization ## Can I customize UI elements of the built-in image editor? Yes, you can perform various customizations on the image editor. Some of such customizations are shown below as examples. ### Can I change the language of the Editor? Yes, as shown in the sample code below, you can use the parameters `titles` and `dialogText` to specify the language used in the editor. ```javascript titles: { 'previous': 'Previous Image', 'next': 'Next Image', 'print': 'Print Image', 'scan': 'Scan Documents', 'load': 'Load Local Images' } ``` ```javascript 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'] } ``` ### Can I remove or add buttons on the toolbar of the Editor? While you can use `visibility` (as shown in the sample code below) to remove a default button(s), currently you cannot add a custom button. ```javascript visibility: { 'scan': true, 'load': true, 'print': false, 'removeall': true } ``` You can see the print icon is hidden in the image below. ![image](/assets/imgs/hideicon.png) ### Can I specify where and how big the Editor is? Yes, as shown in the sample code below, you can use the parameter `element` to specify where the editor is created and then use `width` and `height` to specify its size. ```javascript element: document.getElementById("imageEditor"), width: 600, height: 400, ``` ### Can I change the colors of the Editor? Yes, as shown in the sample code below, the parameters `border` , `topMenuBorder` , `innerBorder` and `background` can be used to specify the style, including the color of the editor. ```javascript border: '5px solid rgb(0,128,0)', topMenuBorder: '', innerBorder: '', background: "rgb(255, 255, 255)", ``` ![image](/assets/imgs/colorchange.png) Complete code is as below. ```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(); ``` --- title: How can I change/hide the UI of the progress bar when importing or uploading images? description: How can I change/hide the UI of the progress bar when importing or uploading images? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/hide-progress-bars.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/hide-progress-bars.md --- # UI Customization ## How can I change/hide the UI of the progress bar when importing or uploading images? To change/hide the progress bar shown during the import/upload process, please refer to [this article](/_articles/extended-usage/ui-customization.md#progress-bar){:target="_blank"}. --- title: Is the UI of the Dynamic Web TWAIN SDK fully customizable? What cannot be customized? description: Is the UI of the Dynamic Web TWAIN SDK fully customizable? What cannot be customized? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/is-ui-customizable.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/is-ui-customizable.md --- # UI Customization ## Is the UI of the Dynamic Web TWAIN SDK fully customizable? What cannot be customized? Most UI is customizable: you can style or replace the viewer, thumbnail viewer, image editor, progress/loading indicators, and the install prompt (via `dynamsoft.webtwain.install.js`, e.g., `Dynamsoft._show_install_dialog`). You can also localize built-in error messages and other labels. What you cannot customize is the native scanner UI itself. See the full guide at [UI Elements and customization](/_articles/extended-usage/ui-customization.md){:target="_blank"}. --- title: Can I stop the scanner from showing its default popup when there is a paper jam? description: Can I stop the scanner from showing its default popup when there is a paper jam? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/stop-default-scanner-popup.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/stop-default-scanner-popup.md --- # UI Customization ## Can I stop the scanner from showing its default popup when there is a paper jam? Dynamic Web TWAIN cannot prevent showing the popup of the printer UI as the popup comes from the scanner driver. But if you would like, you can catch the error code from the driver and handle it. --- title: Can I convert a color image to grayscale or black & white? description: Can I convert a color image to grayscale or black & white? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/convert-color-image-to-grayscale.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/convert-color-image-to-grayscale.md --- # Image Editing ## Can I convert a color image to grayscale or black & white? Yes, you can convert the color of an image easily by using the below methods: - [DWTObject.ConvertToBW()](/_articles/info/api/WebTwain_Edit.md#converttobw){:target="_blank"} // Converts the specified image to a black-and-white image - [DWTObject.ConvertToGrayScale()](/_articles/info/api/WebTwain_Edit.md#converttograyscale){:target="_blank"} // Converts the specified image to a grayscale image --- title: How can I remove only the selected images? description: How can I remove only the selected images? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/remove-selected-images.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/remove-selected-images.md --- # Image Editing ## How can I remove only the selected images? - You can remove the selected images by first selecting the images from the buffer by using the command: [DWTObject.SelectImages([0, 1, 2]);](/_articles/info/api/WebTwain_Buffer.md#selectimages){:target="_blank"} // This command selects the first 3 images from the buffer, you can pass the indices of the images you want to select as the argument to this method. - As the second step, invoke the remove command to delete the selected images. [DWTObject.RemoveAllSelectedImages();](/_articles/info/api/WebTwain_Buffer.md#removeallselectedimages){:target="_blank"} // This command will remove all the images that were selected in first step. --- title: How can I configure all scanned images to conform to a specific size standard (e.g., A4)? description: How can I configure all scanned images to conform to a specific size standard (e.g., A4)? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/set-page-size.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/set-page-size.md --- # Image Editing ## How can I configure all scanned images to conform to a specific size standard (e.g., A4)? Simply, you can use [PageSize](/_articles/info/api/WebTwain_Acquire.md#pagesize){:target="_blank"} to set the page size to be used when acquiring images. Or you can leverage the negotiation capabilities functionality by following the steps mentioned below. 1. ask for the supported sizes of your device. ```javascript DWTObject.getCapabilities( function (result) { for (var i = 0; i < result.length; i++) { if ( result[i].capability.value === Dynamsoft.DWT.EnumDWT_Cap.ICAP_SUPPORTEDSIZES ) sizes = result[i].values; } console.log(sizes); }, function (error) { console.log(error); } ); ``` 2. set the page size to a size standard as needed. ```javascript DWTObject.setCapabilities( { exception: "ignore", capabilities: [ { capability: Dynamsoft.DWT.EnumDWT_Cap.ICAP_SUPPORTEDSIZES, curValue: 1, // 1 means 'A4' in our case exception: "fail", }, ], }, function (result) { console.log(result); }, function (error) { console.log(error); } ); ``` A list of the values of various supported sizes can be found [here](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_capsupportedsizes){:target="_blank"}. You can use the value for the curValue property. --- title: How can I show the default image editor tool? description: How can I show the default image editor tool? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/show-default-image-editor.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/show-default-image-editor.md --- # Image Editing ## How can I show the default image editor tool? Image editor can be easily integrated by using the code sample provided below. ```javascript // The below command will use the default settings in which it shows all buttons in toolbar and also takes up entire screen. var imageEditor = DWTObject.Viewer.createImageEditor(); imageEditor.show(); ``` If you are looking to customize the settings of the image editor before integrating it, you can change the properties mentioned on [this link](/_articles/info/api/WebTwain_Viewer.md#createimageeditor){:target="_blank"}. --- title: Do you support image deskew? description: Do you support image deskew? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/support-image-deskew.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/support-image-deskew.md --- # Image Editing ## Do you support image deskew? Generally, there are two ways to automatically deskew an image. ### Enable the capability of a scanner > Applicable only to compatible TWAIN scanners There is a standard TWAIN capability called `ICAP_AUTOMATICDESKEW` which, when enabled, does the deskewing of all scanned images automatically. If your scanner supports this capability, you can enable the functionality through `Dynamic Web TWAIN` using the API [IfAutomaticDeskew](/_articles/info/api/WebTwain_Acquire.md#ifautomaticdeskew){:target="_blank"} ``` javascript DWTObject.OpenSource(); DWTObject.IfAutomaticDeskew = true; ``` ### Use Dynamic Web TWAIN to deskew an image as it is scanned > The function `deskew()` below is applicable to all platforms. The event [OnPostTransferAsync](/_articles/info/api/WebTwain_Acquire.md#onposttransferasync){:target="_blank"} is only triggered during scanning ``` javascript function deskew(index) { DWTObject.GetSkewAngle( index, function(angle) { console.log("skew angle: " + angle); DWTObject.Rotate(index, angle, true, function() { console.log("Successfully deskewed an image!"); }, function(errorCode, errorString) { console.log(errorString); } ); }, function(errorCode, errorString) { console.log(errorString); } ); } DWTObject.RegisterEvent("OnPostTransferAsync", function(info) { deskew(DWTObject.ImageIDToIndex(info.imageId)); }); ``` --- title: Is there an undo functionality? description: Is there an undo functionality? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/undo-functionality.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/undo-functionality.md --- # Image Editing ## Is there an undo functionality? No, we don't have an undo functionality for editing an image because it may not be easy to achieve step-by-step undo with our SDK. However, we offer a restore changes functionality inside of an image editor before saving any changes that were made. But our advice would be to save the image/images first before editing, and then if you want to revert, you can simply load the previously saved version. --- title: What image editing operations does the Dynamic Web TWAIN SDK support? description: What image editing operations does the Dynamic Web TWAIN SDK support? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/what-image-editing-operation-supported.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/what-image-editing-operation-supported.md --- # Image Editing ## What image editing operations does the Dynamic Web TWAIN SDK support? Dynamic Web TWAIN offers many image editing features to help give you the result you are looking for. All the image editing operations are explained in details [here](/_articles/general-usage/image-processing/index.md#edit-options){:target="_blank"}. --- title: How can I change the background color of the image viewer? description: How can I change the background color of the image viewer? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/change-background-color.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/change-background-color.md --- # Image Viewer ## How can I change the background color of the image viewer? You can change the background color of the image viewer according to your requirements and even put an image in the background. Example: DWTObject.Viewer.background = 'rgb(255, 255, 255)' Read more on background shorthand CSS. --- title: How to get the coordinates of the selected area on an image? description: How to get the coordinates of the selected area on an image? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/coordinates-of-selected-area.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/coordinates-of-selected-area.md --- # Image Viewer ## How to get the coordinates of the selected area on an image? You can use the [`pageAreaSelected`](/_articles/info/api/WebTwain_Viewer.md#pageareaselected) event to get the coordinates of the selected area on an image. This event is triggered when the user selects an area (draws a rectangle) or moves a selected area on the current page. (Click the link to view syntax and sample usage) --- title: How can I create a thumbnail viewer to view images? description: How can I create a thumbnail viewer to view images? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/create-thumbnail-viewer-to-navigate-images.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/create-thumbnail-viewer-to-navigate-images.md --- # Image Viewer ## How can I create a thumbnail viewer to view images? You can create a thumbnail viewer by using the API [createThumbnailViewer()](/_articles/info/api/WebTwain_Viewer.md#createthumbnailviewer){:target="_blank"}. You can either use the default settings or customize the viewer as shown below: ```javascript // Use default settings var objThumbnailViewer = DWTObject.Viewer.createThumbnailViewer(); objThumbnailViewer.background = "rgb(0,0,255)"; objThumbnailViewer.show(); // Customize the thumbnail viewer var thumbnailViewerSettings = { location: "left", size: "30%", columns: 1, rows: 3, scrollDirection: "vertical", // 'horizontal' pageMargin: 10, background: "rgb(255, 255, 255)", border: "", allowKeyboardControl: true, allowPageDragging: true, allowResizing: false, showPageNumber: false, pageBackground: "transparent", pageBorder: "1px solid rgb(238, 238, 238)", hoverBackground: "rgb(239, 246, 253)", hoverPageBorder: "1px solid rgb(238, 238, 238)", placeholderBackground: "rgb(251, 236, 136)", selectedPageBorder: "1px solid rgb(125,162,206)", selectedPageBackground: "rgb(199, 222, 252)", }; var thumbnail = DWTObject.Viewer.createThumbnailViewer(thumbnailViewerSettings); thumbnail.show(); ``` --- title: How can I disable drag and drop images in the viewer? description: How can I disable drag and drop images in the viewer? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/disable-drag-and-drop-in-images.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/disable-drag-and-drop-in-images.md --- # Image Viewer ## How can I disable drag and drop images in the viewer? You can leverage the inbuilt API [acceptDrop](/_articles/info/api/WebTwain_Viewer.md#acceptdrop){:target="_blank"} to disable the load functionality of the dropped images in the viewer. ```javascript DWTObject.Viewer.acceptDrop = false; ``` --- title: How can I insert an image after a selected image in the viewer? description: How can I insert an image after a selected image in the viewer? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/insert-image-after-selected-image.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/insert-image-after-selected-image.md --- # Image Viewer ## How can I insert an image after a selected image in the viewer? By default, when you scan or load images, they are appended to the end of the image array in buffer. However, in some business scenarios, the user may want to insert these new images to a specified index. Unfortunately, Dynamic Web Twain does not provide a native method for that. The following code snippet shows how this functionality can be implemented. 1. Insert when acquiring ```javascript function acquireToIndex(index) { DWTObject.IfAppendImage = false; DWTObject.CurrentImageIndexInBuffer = index; DWTObject.RegisterEvent("OnPostTransfer", function () { DWTObject.CurrentImageIndexInBuffer++; }); DWTObject.RegisterEvent("OnPostAllTransfers", function () { DWTObject.IfAppendImage = true; }); DWTObject.AcquireImage(); } ``` 2. Insert when loading ```javascript function loadToIndex(index) { var oldCount = DWTObject.HowManyImagesInBuffer; DWTObject.RegisterEvent("OnPostLoad", function () { var newCount = DWTObject.HowManyImagesInBuffer; for (var j = 0; j < newCount - oldCount; j++) DWTObject.MoveImage(oldCount + j, index + j); }); DWTObject.LoadImageEx("", 5); } ``` --- title: What mouse click events does the viewer support? description: What mouse click events does the viewer support? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/mouse-click-events-supported.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/mouse-click-events-supported.md --- # Image Viewer ## What mouse click events does the viewer support? Dynamic Web TWAIN Viewer supports several mouse click events like mouseup, mousedown, mousemove, mouseover, mouseout and click. You can find [here](/_articles/info/api/WebTwain_Viewer.md#events){:target="_blank"} a list of all supported events by the viewer. --- title: Can I print images from the viewer? description: Can I print images from the viewer? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/print-images-from-viewer.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/print-images-from-viewer.md --- # Image Viewer ## Can I print images from the viewer? Yes, you can print the images from the viewer by exporting all image data in the buffer to a new browser window and use the browser's default feature to print images. This can be achieved by using the [Print](/_articles/info/api/WebTwain_IO.md#print){:target="_blank"} API. Note: The Print API prints all the images on the viewer, you can use [PrintEx](/_articles/info/api/WebTwain_IO.md#printex){:target="_blank"} to print only selected images. --- title: Can I protect sensitive information of an image from being seen? description: Can I protect sensitive information of an image from being seen? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/protect-sensitive-information.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/protect-sensitive-information.md --- # Image Viewer ## Can I protect sensitive information of an image from being seen? If you need to modify an image by concealing certain areas permanently, you can use the [erase()](/_articles/info/api/WebTwain_Edit.md#erase){:target="_blank"} method. This method is particularly useful when the requirement involves replacing a rectangular region within the image with a solid white block. On the other hand, if you prefer a customizable and removable layer to temporarily conceal particular content, our newly developed Annotation feature is just what you need. For comprehensive details about this feature, please click on the following link: How can I add annotations to an image and then save/upload it? --- title: How can I resize the view of image (e.g. zoom in/out an current image)? description: How can I resize the view of image (e.g. zoom in/out on an image)? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/resize-view-of-image.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/resize-view-of-image.md --- # Image Viewer ## How can I resize the view of image (e.g. zoom in/out on an image)? Use the viewer’s `zoom` property to change the zoom factor (enlarge or reduce the current page). See the API reference for details: [zoom](/_articles/info/api/WebTwain_Viewer.md#zoom){:target="_blank"}. --- title: How can I reorder images in the viewer? description: How can I reorder images in the viewer? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/resort-images-in-viewer.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/resort-images-in-viewer.md --- # Image Viewer ## How can I reorder images in the viewer? You can easily reorder the images in the viewer. You may drag and drop the images in the order you want them to appear. This process will trigger the inbuilt callback event [OnIndexChangeDragDropDone](/_articles/info/api/WebTwain_Buffer.md#onindexchangedragdropdone){:target="_blank"}. You can also reorder the images by using the method [SwitchImage(index1, index2)](/_articles/info/api/WebTwain_Buffer.md#switchimage){:target="_blank"}. --- title: How can I show multiple images at a time? description: How can I show multiple images at a time? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/show-multiple-images.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/show-multiple-images.md --- # Image Viewer ## How can I show multiple images at a time? You can use the [setViewMode](/_articles/info/api/WebTwain_Viewer.md#setviewmode){:target="_blank"} API to show multiple images at a time in the viewer. Example: ```javascript // display 6 images at a time in 2 columns and 3 rows DWTObject.Viewer.setViewMode(2, 3); ``` ![Show multiple images](/assets/imgs/show-multiple-Images.png) --- title: Can the size of the image viewer auto resize when the browser window size changes? description: Can the size of the image viewer auto resize when the browser window size changes? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/viewer-size-auto-resize.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/viewer-size-auto-resize.md --- # Image Viewer ## Can the size of the image viewer auto resize when the browser window size changes? Scenario When using Dynamic Web TWAIN in different environments, it may be necessary to change the size of the viewer within the window automatically. Steps This can be done in two different ways 1. Set the viewer size when the page is opened based upon the size of the window 2. Change the viewer size when the window size is adjusted based on the new size of the window For option 1: You may change the container size based on the window size by setting the following in your javascript file (before any other Dynamsoft-related operations): ```javascript Dynamsoft.DWT.Containers = [ { ContainerId: "dwtcontrolContainer", Width: window.innerWidth, Height: window.innerHeight, }, ]; ``` and in dynamsoft.webtwain.config.js file set: ```javascript Dynamsoft.DWT.Containers = []; ``` Note: window.innerWidth and window.innerHeight do not work in IE. You can replace it with document.documentElement.clientWidth and document.documentElement.clientHeight. For option 2: Write your own function to calculate the Container's width and height according to the browser's size. Then, assign the values to our API's Height & Width. Finally, use the event [resize](/_articles/info/api/WebTwain_Viewer.md#resize){:target="_blank"} to trigger the function. --- title: Is there any component of the Dynamic Web TWAIN SDK that needs to be installed on end-user machines? description: Is there any component of the Dynamic Web TWAIN SDK that needs to be installed on end-user machines? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/component-needs-to-be-installed-on-end-user-machine.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/component-needs-to-be-installed-on-end-user-machine.md --- View all FAQs about [Project Deployment and End-user Installation]( https://www.dynamsoft.com/web-twain/docs/faq/#project-deployment-and-end-user-installation) # Is there any component of the Dynamic Web TWAIN SDK that needs to be installed on end-user machines? For the [Desktop Service Edition](/_articles/general-usage/initialization.md#desktop-service-edition){:target="_blank"}, end users need the Dynamic Web TWAIN Service installed locally (this was called “Dynamsoft Service” prior to v19.0). They are prompted to install it the first time they open your application. When you upgrade Dynamic Web TWAIN, plan to reinstall the service on client machines if required. See [Update Dynamic Web TWAIN Service on the Client-side](/_articles/indepth/development/upgrade.md#update-dynamsoft-service-on-the-client-side){:target="_blank"} for details. If you prefer zero client-side installation, enable Remote Scan. It routes scanning through a host machine’s service, so the browser client installs nothing. Learn how to enable it [here](/_articles/faq/how-to-enable-remote-scan.md){:target="_blank"}. --- title: What resources of the SDK should be included in my web application? description: What resources of the SDK should be included in my web application? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/resources-to-be-included-in-SDK.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/resources-to-be-included-in-SDK.md --- View all FAQs about [Project Deployment and End-user Installation]( https://www.dynamsoft.com/web-twain/docs/faq/#project-deployment-and-end-user-installation) # What resources of the SDK should be included in my web application? You can include all the files under the Resources folder, but not all are required. Under the `\addon` folder, you do not need the files for add-ons which are not used by your web application. Under the `\dist` folder, you can include the installers required per your OS requirements. Under the `\src` folder, you do not need the wasm files if you are not using camera functionalities. For more information, please check [Loading the Resource Files](/_articles/general-usage/initialization.md#loading-the-core-js-files){:target="_blank"}. --- title: I have installed the Dynamic Web TWAIN Service on an end-user machine but still got asked to install it repeatedly. Why? description: I have installed the Dynamic Web TWAIN Service on an end-user machine but still got asked to install it repeatedly. Why? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/service-prompting-to-install-repeatedly.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/service-prompting-to-install-repeatedly.md --- View all FAQs about [Project Deployment and End-user Installation]( https://www.dynamsoft.com/web-twain/docs/faq/#project-deployment-and-end-user-installation) # I have installed the Dynamic Web TWAIN Service on an end-user machine but still got asked to install it repeatedly. Why? #### There are a few possible causes > [!NOTE] > "Local network access permission is not granted" is a **newly developing issue** 1. The local network access permission is not granted (required starting Chromium 142). 2. The Dynamic Web TWAIN Service (previously called "Dynamsoft Service") is not installed properly. 3. The Dynamic Web TWAIN Service is installed correctly but not started. 4. The requests sent to the Service are redirected because you are using a proxy server on IE. 5. The service's listening ports are blocked by another software, like anti-virus software. 6. The service is blocked by extensions or plugins you have installed in the browser. (e.g. NoScript, M*Modal Fluency Direct Web Connector) 7. You are accessing an HTTPS site on a Linux machine. 8. You are visiting a public HTTP website with Dynamic Web TWAIN SDK integrated via Chrome v94+ (or any Chromium v94+ based browsers) 9. You have added `Access-Control-Allow-Origin` setting in the `DSConfiguration.ini` file, but the request originates from a different domain and you didn't set [`IfCheckCORS`](/_articles/extended-usage/dynamsoft-service-configuration.md#access-control-allow-origin). #### The respective fixes are listed below 1. See [Chromium local network access issue](/_articles/faq/chromium-142-local-network-access-issue.md) for details and corrective actions. 2. Check the service's [installation folder](/_articles/extended-usage/dynamsoft-service-configuration.md#installation-folder) and make sure you have [the correct files](/_articles/extended-usage/dynamsoft-service-configuration.md#related-files-and-folders){:target="_blank"}. 3. Check `Local Services` and make sure the Dynamic Web TWAIN Service is listed and Running. 4. On IE, go to `Internet Options` --> `Security` tab, select `Local Intranet`, then click `Sites`, uncheck 'Include all sites that bypass the proxy server' ![why-is-the-browser-prompting-me-to-install-dynamsoft-service-repeatedly-1](/assets/imgs/why-is-the-browser-prompting-me-to-install-dynamsoft-service-repeatedly-1.png) ![why-is-the-browser-prompting-me-to-install-dynamsoft-service-repeatedly-2](/assets/imgs/why-is-the-browser-prompting-me-to-install-dynamsoft-service-repeatedly-2.png) 5. Check your anti-virus software or any other software that can block local ports and make sure the ports 18622, 18623, 18625 and 18626 are not blocked. 6. Disable all the extensions or plugins in the browser, refresh and try again. 7. On your Linux client machine, visit https://127.0.0.1:18626 and https://127.0.0.1:18623 separately in Chrome and FireFox, manually add both certificates to the exception lists. 8. See the solution [here](/_articles/faq/http-insecure-websites-in-chromium-browser.md){:target="_blank"} 9. Set [`IfCheckCORS`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#ifcheckcors) to `true` in `dynamsoft.webtwain.config.js` file. --- title: How do I upgrade the end-user installation for all end users once I upgrade my project? description: How do I upgrade the end-user installation for all end users once I upgrade my project? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/upgrade-end-user-installations.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/upgrade-end-user-installations.md --- View all FAQs about [Project Deployment and End-user Installation]( https://www.dynamsoft.com/web-twain/docs/faq/#project-deployment-and-end-user-installation) # How do I upgrade the end-user installation for all end users once I upgrade my project? By default once your application with the upgraded version has been deployed, end-users will be prompted to install the newer version of the Dynamic Web TWAIN Service (also called "Dynamsoft Service"). In a controlled environment Dynamic Web TWAIN can be distributed to all clients in one go just like other similar programs. Group Policy is one such technology. You can install Dynamic Web TWAIN Service silently using the following commands:
- [v19.0+](#19plus) - [Versions below 19.0](#19min)
- Windows ```javascript msiexec /i "/path/to/DynamicWebTWAINServiceSetup.msi" /qn ``` - macOS ```javascript // Install sudo installer -pkg /path/to/DynamicWebTWAINServiceSetup.pkg -target /Applications // Stop service sudo launchctl unload /Library/LaunchAgents/com.dynamsoft.dynamicwebtwainservicex64.plist // Start service launchctl load /Library/LaunchAgents/com.dynamsoft.dynamicwebtwainservicex64.plist ``` • Linux ```javascript sudo dpkg -i /path/to/DynamicWebTWAINServiceSetup.deb // or sudo rpm -i path/to/DynamicWebTWAINServiceSetup.rpm ```
- Windows ```javascript msiexec /i "/path/to/DynamsoftServiceSetup.msi" /qn ``` - macOS ```javascript // Install sudo installer -pkg /path/to/DynamsoftServiceSetup.pkg -target /Applications // Stop service sudo launchctl unload /Library/LaunchAgents/com.dynamsoft.dynamsoftservicex64.plist // Start service launchctl load /Library/LaunchAgents/com.dynamsoft.dynamsoftservicex64.plist ``` • Linux ```javascript sudo dpkg -i /path/to/DynamsoftServiceSetup.deb // or sudo rpm -i path/to/DynamsoftServiceSetup.rpm ```
> Note - If you are upgrading from version 14, end-users may need to uninstall the previous version manually before reinstallation.
--- title: How do I upgrade my project to use the latest version of the Dynamic Web TWAIN SDK? description: How do I upgrade my project to use the latest version of the Dynamic Web TWAIN SDK? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/upgrade-to-latest-version.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/upgrade-to-latest-version.md --- View all FAQs about [Project Deployment and End-user Installation]( https://www.dynamsoft.com/web-twain/docs/faq/#project-deployment-and-end-user-installation) # How do I upgrade my project to use the latest version of the Dynamic Web TWAIN SDK? For the upgrade process, we would recommend trying out the latest version with a trial before requesting the upgrade. You can download a 30-day free trial here. Please refer to the upgrade guide and the release notes below to update your application/configuration. [Dynamic Web TWAIN Development - Upgrade Guide](/_articles/indepth/development/upgrade.md){:target="_blank"} [Dynamic Web TWAIN Schedule - Stable Release](/_articles/info/schedule/Stable.md){:target="_blank"} Once you are ready to upgrade, please send an email to sales@dynamsoft.com requesting the upgrade be done. Please note that once your license is upgraded, the old license will be revoked within 60 days. --- title: What does the Dynamic Web TWAIN Service do on the end-user machine? description: What does the Dynamic Web TWAIN Service do on the end-user machine? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/what-does-dynamsoft-service-do-on-end-user-machine.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/what-does-dynamsoft-service-do-on-end-user-machine.md --- View all FAQs about [Project Deployment and End-user Installation]( https://www.dynamsoft.com/web-twain/docs/faq/#project-deployment-and-end-user-installation) # What does the Dynamic Web TWAIN Service do on the end-user machine? Dynamic Web TWAIN Service (also called "Dynamsoft Service") is required for the Desktop Service Edition of Dynamic Web TWAIN. It's a background system service that handles the communication between connected physical devices and the browser, as well as image processing, encoding, decoding, etc.
- [v19.0+](#19plus) - [Versions below 19.0](#19min)
## Three processes By default, there are three Dynamic Web TWAIN Service processes running which use the same file `DynamicWebTWAINService.exe` but initiated with different arguments: - The **main process** starts without any argument as follows: ``` cmd C:\Program Files (x86)\Dynamsoft\Dynamic Web TWAIN Service {version number}\DynamicWebTWAINService.exe ``` - Then there is a **monitor process** which is meant to monitor the main process and automatically start it in case it crashes. The monitor process starts like this: ``` cmd C:\Program Files (x86)\Dynamsoft\Dynamic Web TWAIN Service {version number}\DynamicWebTWAINService.exe -asmonitor XXX ``` - The last always-running process is meant to **support the SSL certificate specifically for the Firefox browser**: ``` cmd C:\Program Files (x86)\Dynamsoft\Dynamic Web TWAIN Service {version number}\DynamicWebTWAINService.exe -certCheck XXX ``` > Note: you may find another process named 'Dynamsoft Scanning New Module', which is a scan module. This process will start when you access an application integrated with Dynamic Web TWAIN, and will automatically stop when you close the application. > * On Windows, the service runs under the Local System account > * On macOS, the service runs under the current user account > * On Linux, the service runs under the root account ## Files and folders in the service directory There are multiple files and folders in the service directory. Taking Windows service (located at `C:\Program Files (x86)\Dynamsoft\Dynamic Web TWAIN Service {version number}`) as an example, the content is as follows: ### For the Service * `\cache\` : Data cached on the disk. Check out [Disk Caching](/_articles/extended-usage/buffer-caching.md#disk-caching){:target="_blank"}. * `\cert\` : The certificates used for SSL connection. Check out [How to change the certificates](/_articles/faq/change-dynamsoft-service-certificate.md){:target="_blank"}. * `\dump\` : Dump files in case the service crashes. * `\log\` : Log files for debugging purposes. * `\upload\` : Temporary location for image data to be uploaded by the file uploader. * `DSConfiguration.ini` : Service configuration file. * `DWASManager_19000318.dll` : The service manager. The name of the file may vary among different versions. * `DynamicWebTWAINService.exe` : The service. * `service.ini` : Define service name. * `user_config.ini` : User configuration file. * `welcome.htm` : The home page for the service (present when you visit http://127.0.0.1:18625) ### Components These files are named with their version number. The following uses v19.0 as an example. * Core scanning module + `dwt_19.0.0.0318.dll` + `DSSCN2.exe` + `DSSCN2x64.exe` + `TWAINDSM.dll` + `TWAINDSMx64.dll` * Barcode Reader Addon + `\x64\DynamsoftBarcodeReaderx64_9.6.dll` + `dbrx64_9.6.2.0318.dll` * PDF Addon & Imaging features + `\x64\DynamsoftCorex64.dll` + `\x64\DynamsoftImageProcessingx64.dll` + `\x64\ImageProcessx64.dll` * Webcam Addon + `DynamicWebcamx64_15.0.0.0625.dll` * File Uploader + `UploadModule_1.9.0.0318.dll` ### Supporting files * `favicon.ico` : The favicon. * `legal.txt` : Legal notice. * `libcurl.dll` : The file transfer library. * For OpenSSL + `libssl-3-x64.dll` * `port.lock` ## HTTP Requests and Responses Dynamic Web TWAIN Service sets up a local HTTP service that accepts requests from JavaScript code running in the browser and performs operations accordingly. The following are a few examples. > NOTE > > These requests are handled by the JavaScript client of the library. Please do not try to make similar requests in your own code without consulting [Dynamsoft Support](/_articles/about/getsupport.md). #### Perform image removal - Request ``` https://127.0.0.1:18623/f/RemoveAllImages?753350643 ``` - Response in case of success ```json { "id": "414778098", "method": "RemoveAllImages", "result": [true], "cmdId": "" } ``` #### Return an image - Request ``` https://127.0.0.1:18623/dwt/dwt_16100728/img?id=414778098&index=5&width=585&height=513&ticks=1603162807999 ``` - Response in case of success The image data.
## Three processes By default, there are three Dynamsoft Service processes running which use the same file `DynamsoftService.exe` but initiated with different arguments: - The **main process** starts without any argument as follows: ``` cmd C:\Windows\SysWOW64\Dynamsoft\DynamsoftServicex64\DynamsoftService.exe ``` - Then there is a **monitor process** which is meant to monitor the main process and automatically start it in case it crashes. The monitor process starts like this: ``` cmd C:\Windows\SysWOW64\Dynamsoft\DynamsoftServicex64_{version number}\DynamsoftService.exe -asmonitor XXX ``` - The last always-running process is meant to **support the SSL certificate specifically for the Firefox browser**: ``` cmd C:\Windows\SysWOW64\Dynamsoft\DynamsoftServicex64_{version number}\DynamsoftService.exe -certCheck XXX ``` > Note: you may find another process named 'Dynamsoft Scanning New Module', which is a scan module. This process will start when you access an application integrated with Dynamic Web TWAIN, and will automatically stop when you close the application. > * On Windows, the service runs under the Local System account > * On macOS, the service runs under the current user account > * On Linux, the service runs under the root account ## Files and folders in the service directory There are multiple files and folders in the service directory. Taking Windows service (located at `C:\Windows\SysWOW64\Dynamsoft\DynamsoftServicex64_16`) as an example, the content is as follows: ### For the Service * `\cache\` : Data cached on the disk. Check out [Disk Caching](/_articles/extended-usage/buffer-caching.md#disk-caching){:target="_blank"}. * `\cert\` : The certificates used for SSL connection. Check out [How to change the certificates](/_articles/faq/change-dynamsoft-service-certificate.md){:target="_blank"}. * `\dump\` : Dump files in case the service crashes. * `\log\` : Log files for debugging purposes. * `\upload\` : Temporary location for image data to be uploaded by the file uploader. * `DSConfiguration.ini` : Service configuration file. * `DWASManager_16000428.dll` : The service manager. The name of the file may vary among different versions. * `DynamsoftService.exe` : The service. * `DynamicSocket.dll` : For socket connections. * `service.ini` : Define service name. * `user_config.ini` : User configuration file. * `welcome.htm` : The home page for the service (present when you visit http://127.0.0.1:18625) ### Components These files are named with their version number. The following uses v16.1.1 as an example. * Core scanning module + `dwt_16.1.0.0728.dll` + `DSSCN2.exe` + `DSSCN2x64.exe` + `TWAINDSM.dll` + `TWAINDSMx64.dll` * Barcode Reader Addon + `\x64\` + `\x86\` + `dbr_7.4.0.0428.dll` + `dbrx64_7.4.0.0428.dll` * PDF Addon + `DynamicPdfCore_11.0.0.0428.dll` + `DynamicPdfCorex64_11.0.0.0428.dll` + `DynamicPdfR_11.0.0.0428.dll` (for the PDF Rasterizer) + `DynamicPdfRx64_11.0.0.0428.dll` (for the PDF Rasterizer) * Webcam Addon + `DynamicWebcam_15.0.0.0625.dll` + `DynamicWebcamx64_15.0.0.0625.dll` * File Uploader + `UploadModule_1.6.0.0428.dll` * Imaging features + `DynamicImage.dll` + `DynamicImagex64.dll` ### Supporting files * `favicon.ico` : The favicon. * `legal.txt` : Legal notice. * `libcurl.dll` : The file transfer library. * For OpenSSL + `libeay32.dll` + `ssleay32.dll` * `port.lock` ## HTTP Requests and Responses Dynamsoft Service sets up a local HTTP service that accepts requests from JavaScript code running in the browser and performs operations accordingly. The following are a few examples. > NOTE > > These requests are handled by the JavaScript client of the library. Please do not try to make similar requests in your own code without consulting [Dynamsoft Support](/_articles/about/getsupport.md). #### Return availability - Request ``` https://127.0.0.1:18623/fa/VersionInfo?ts=1603161807908 ``` - Response in case of success ```json { "id": "1", "method": "VersionInfo", "result": ["16, 1, 0, 0728", "", "64"], "cmdId": "" } ``` #### Perform image removal - Request ``` https://127.0.0.1:18623/f/RemoveAllImages?753350643 ``` - Response in case of success ```json { "id": "414778098", "method": "RemoveAllImages", "result": [true], "cmdId": "" } ``` #### Return an image - Request ``` https://127.0.0.1:18623/dwt/dwt_16100728/img?id=414778098&index=5&width=585&height=513&ticks=1603162807999 ``` - Response in case of success The image data.
For more information, please refer to [Dynamic Web TWAIN Deployment - Dynamic Web TWAIN Service](/_articles/extended-usage/dynamsoft-service-configuration.md){:target="_blank"}.
--- title: How can I use Dynamic Web TWAIN SDK in a Citrix environment? description: How can I use Dynamic Web TWAIN in a Citrix environment? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/use-dwt-in-citrix-env.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/use-dwt-in-citrix-env.md --- View all FAQs about [Project Deployment and End-user Installation]( https://www.dynamsoft.com/web-twain/docs/faq/#project-deployment-and-end-user-installation) # How can I use Dynamic Web TWAIN in a Citrix environment? If too many end-users access the same scanning application using the same communication port, it can slow down server response and increase wait time. To optimize user experience within the Citrix environment, Dynamsoft offers **enhanced mode** which distributes end-users among different ports. For more information, please check here: Optimized Document Scanning Within Citrix Remote Desktop **Note**: enabling enhanced mode requires license key modifications. Please contact our [support team](/_articles/about/getsupport.md) to use enhanced mode functionalities. To configure the enhanced mode, please follow the steps below:
- [v19.0+](#19plus) - [Versions below 19.0](#19min)
1. Stop Dynamic Web TWAIN Service 2. Set EnableEnhancedMode=TRUE in DSConfiguration.ini which is under `C:\Program Files (x86)\Dynamsoft\Dynamic Web TWAIN Service {version number}` 3. Set Dynamsoft.DWT.IfCheckDCP=true in dynamsoft.webtwain.config.js 4. Restart Dynamic Web TWAIN Service ***In this case, initializing the DWT object dynamically is not supported.*** How to check if Enhanced mode is running 1. user_config.ini which is under `C:\Program Files (x86)\Dynamsoft\Dynamic Web TWAIN Service {version number}` will list the ports that each user is listening on. 2. In Network, the DWT port included in the request URL should be 17000 and so on, not 18622 anymore
1. Stop Dynamsoft Service 2. Set EnableEnhancedMode=TRUE in DSConfiguration.ini which is under `C:\Windows\SysWOW64\Dynamsoft\DynamsoftServicex64_{version number}` 3. Set Dynamsoft.DWT.IfCheckDCP=true in dynamsoft.webtwain.config.js 4. Restart Dynamsoft Service ***In this case, initializing the DWT object dynamically is not supported.*** How to check if Enhanced mode is running 1. user_config.ini which is under `C:\Windows\SysWOW64\Dynamsoft\DynamsoftServicex64_{version number}` will list the ports that each user is listening on. 2. In Network, the DWT port included in the request URL should be 17000 and so on, not 18622 anymore
--- title: Can I generate/load an encrypted file in PDF format? description: Can I generate/load an encrypted file in PDF format? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/encrypt-pdf-files.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/encrypt-pdf-files.md --- # Security ## Can I generate/load an encrypted file in PDF format? Yes. In v18.5, Dynamic Web TWAIN supports the function of [`encrypting the generated PDF files`](/_articles/extended-usage/pdf-processing.md#pdf-save-settings). Moreover, loading password-protected PDFs has been supported by utilizing the [`ReaderOptions`](/_articles/info/api/interfaces.md#readeroptions) interface along with the [`SetReaderOptions()`](/_articles/info/api/Addon_PDF.md#setreaderoptions) method. --- title: Why is my scanner not shown or not responding in the browser? description: Why is my scanner not shown or not responding in the browser? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/scanner-not-shown-or-not-responding-in-the-browser.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/scanner-not-shown-or-not-responding-in-the-browser.md --- # Capture/Image Source ## Why is my scanner not shown or not responding in the browser? ### Symptom Sometimes when you are using a scanning page built with Dynamic Web TWAIN, you will encounter an issue where your scanner is not shown, not responding or shown as busy in the browser. ### Causes 1. The scanner is not connected to the machine or the scanner driver is not installed. Especially when you are using **64-bit Internet Explorer** but you don't have the 64-bit scanner (TWAIN) driver installed on the machine. 2. The Browser doesn't have enough permission to access the scanner driver. This mostly happens on **Windows 7/Vista/2008 OS** where high security level is applied to **Internet Explorer**. It would also happen in Firefox 4+ and Safari. ### Solution 1. Make sure the driver of the scanner is installed and the scanner is running and properly connected to the machine. You should be able to see the scanner in the Windows' Scanners and Cameras Wizard. And you can use Twacker to check if the driver is TWAIN compatible. In addition, if you are using 64-bit Internet Explorer, please make sure you have a 64-bit TWAIN driver of the scanner installed. 2. **For Firefox, Safari, etc.**, please go to C:\Windows\twain_32 and you should be able to find that your scanner driver has a sub-folder there. In order to show the scanner as an available source, you need to copy the dlls in the sub-folder and paste them to the folder C:\Windows\System32 (or C:\Windows\SysWOW64 on a 64-bit OS). For Internet Explorer, you can try one of the following tricks: 1. Add the website to the zone of trusted sites. IE | Tools | Internet Options | Security | Trusted Sites. 2. Turn Protected Mode off. To turn off the protected mode of IE, you can go to Tools | Internet Options | Security and uncheck "Enable Protected Mode (requires restarting Internet Explorer)" option. FYI, Protected Mode helps protect users from attack by running an IE process with greatly restricted privileges. It uses the Windows Vista integrity mechanism to run the Internet Explorer process at low integrity. But with Protected Mode turned on, you may encounter problems when running Dynamic Web TWAIN applications. 3. To temporarily elevate permissions of IE. Click Start, point to All Programs, right-click IE, and then select Run as Administrator (with Administrator permissions). --- title: How to use a blank page as a separator? description: How to use a blank page as a separator? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/use-blank-page-as-a-separator.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/use-blank-page-as-a-separator.md --- # Document Saving ## How to use a blank page as a separator? ### Scenario You are scanning in multiple documents with a blank page separating them and would like to save each set of documents separately. ### Solution In order to do this we will scan in all the sheets, then use [IsBlankImageExpress](/_articles/info/api/WebTwain_Buffer.md#isblankimageexpress){:target="_blank"} to detect whether or not it is blank. If the sheet is blank we will then remove it from the buffer and save the previous set of sheets. In order to accomplish this task we are going to use the event OnPostAllTransfers, which fires after all scans are complete in order to check whether or not any pages are blank. ```javascript function Dynamsoft_OnReady() { DWTObject = Dynamsoft.DWT.GetWebTwain('dwtcontrolContainer'); // Get the Dynamic Web TWAIN object that is embedded in the div with id 'dwtcontrolContainer' if (DWTObject) { DWTObject.IfShowUI = false; DWTObject.IfAutoDiscardBlankpages = false; DWTObject.RegisterEvent('OnPostAllTransfers', CheckBlankPage); //Register the OnPostAllTransfers event that will be called after all scanning is complete } } function AcquireImage() { if (DWTObject) { DWTObject.SelectSource(function () { var OnAcquireImageSuccess = function () { DWTObject.CloseSource(); }; var OnAcquireImageFailure = function (ec, es) { DWTObject.CloseSource(); alert(es); }; DWTObject.OpenSource(); DWTObject.IfDisableSourceAfterAcquire = false; // Scanner source will be disabled/closed automatically after the scan. DWTObject.AcquireImage(OnAcquireImageSuccess, OnAcquireImageFailure); }, function () { console.log('SelectSource failed!'); }); } } function OnSuccess() { console.log('successful'); } function OnFailure(errorCode, errorString) { alert(errorString); } function CheckBlankPage() { //Function for checking a blank page, called when OnPostAllTransfers is triggered if (DWTObject) { //Ensure there is a DWTObject var startindex = 0; // Assume it starts from the first page in the buffer. for (var i = 0; i < DWTObject.HowManyImagesInBuffer; i++) { //Go through each image in the buffer. if (DWTObject.IsBlankImageExpress(i)) { DWTObject.RemoveImage(i); // remove the blank page from the buffer. if (i != 0) { var imageRecord = []; i--; //decrement i for the removed image var selectedCount = i - startindex + 1; for (var j = 0; j < selectedCount; j++) { //loop to select all images from previous blank to current imageRecord.push(j + startindex); } if (selectedCount > 0) { //save images as long as there are some in the selection DWTObject.SelectImages(imageRecord); DWTObject.IfShowFileDialog = true; DWTObject.SaveSelectedImagesAsMultiPagePDF("C:\\....", OnSuccess, OnFailure); //PLEASE CHANGE THIS FILE PATH (The first parameter) } startindex = i + 1; //set the start index for next search 1 higher than current page } } else if (i == DWTObject.HowManyImagesInBuffer - 1) { //the last few images are not blank var selectedCount = i - startindex + 1; // set how many images are selected var imageRecord = []; for (var j = 0; j < selectedCount; j++) { //loop to select all images from previous blank to current imageRecord.push(j + startindex); } if (selectedCount > 0) { //save images as long as there are some in the selection DWTObject.SelectImages(imageRecord); DWTObject.IfShowFileDialog = true; DWTObject.SaveSelectedImagesAsMultiPagePDF("C:\\...", OnSuccess, OnFailure); //PLEASE CHANGE THIS FILE PATH (The first parameter) } } } } } ``` If your application is having a hard time detecting blank pages(there is some areas around the edge of the blank page with non-blank spots) or you are using coloured pages you may want to use the pages standard deviation instead. You may use the following Snippet instead. **Using Page Standard Deviation:** ```javascript function CheckBlankPage(){ //Function for checking a blank page, called when OnPostAllTransfers is triggered if(DWTObject){//Ensure there is a DWTObject for(var i = 0; i < DWTObject.HowManyImagesInBuffer;i++){//Go through each image in the buffer. if(DWTObject.IsBlankImageExpress(i)){}//Make Blank Image run, but do not use the result if(DWTObject.BlankImageCurrentStdDev < 15.0){//set a standard deviation for the program to use //...... } } } } ``` --- title: How to resolve Dynamic Web TWAIN SDK issue in Chrome 101? description: How to resolve Dynamic Web TWAIN issue in Chrome 101? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/private-network-access-in-chrome101.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/private-network-access-in-chrome101.md --- View all FAQs about [Project Deployment and End-user Installation]( https://www.dynamsoft.com/web-twain/docs/faq/#project-deployment-and-end-user-installation) # Dynamic Web TWAIN issue in Chrome 101 **Latest Update from Google:** (REF: https://developer.chrome.com/blog/private-network-access-preflight/) September 27, 2022: Google has stated that the pre-flight changes will not occur sooner than Chrome version 109, which according to Google's release calendar, is scheduled for early 2023. July 7, 2022: Google has updated the timeline for this preflight request feature. The experiment is scheduled again for Chrome 104 and may be released in Chrome 107 at the earliest. Please refer to Google's feature updates here. March 7, 2022: The experiment in Chrome 98 was rolled back due to stability and compatibility issues discovered in the rollout to Chrome stable. These issues will be fixed before the experiment is tried again, no earlier than in Chrome 101. Learn more in the blink-dev@chromium.org Intent to Ship email thread for more details. ### Symptom In Chrome 101 at the earliest, when visiting a website that has Dynamic Web TWAIN SDK v17.2 or older integrated into the application, you may see the following **error message** in the browser console. For the end users of your website, they may be prompted repeatedly to download and install the Dynamic Web TWAIN Service (also called "Dynamsoft Service"). NOTE that the same issue will also occur in any browser based on **Chromium 101+**, such as Microsoft Edge 101. ``` Access to XMLHttpRequest at 'https://local.dynamsoft.com:****' from origin 'https://yourwebsiteURL' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Private-Network' header was present in the preflight response for this private network request targeting the `local` address space. ``` In Chrome 98, you may have already noticed the following **warning/error message** in the browser console, but it is not expected to cause any immediate issues. Per Google's message below, Chrome 101 is expected to be released in April 2022. ``` A site requested a resource from a network that it could only access because of its users' privileged network position. These requests expose devices and servers to the internet, increasing the risk of a cross-site request forgery (CSRF) attack, and/or information leakage. To mitigate these risks, Chrome will require non-public subresources to opt-into being accessed with a preflight request and will start blocking them in Chrome 101 (April 2022). ``` ### Cause As a part of the Private Network Access (PNA) specification, Chrome is deprecating direct access to private network endpoints from public websites. In Chrome 101 at the earliest, Chrome will enforce explicit permission from private network endpoints before requests from public websites can be allowed. According to Google, "this will begin only if and when compatibility data indicates that the change is safe enough and we've outreached directly when necessary." More details can be found at https://developer.chrome.com/blog/private-network-access-preflight/. Dynamic Web TWAIN utilizes a local service named 'Dynamic Web TWAIN Service' to support document scanning from physical scanners. Your web scanning page needs to make requests to localhost or 127.0.0.1 to communicate with the local service. In Chrome 101, the connection from your public website to the private network (i.e. localhost/127.0.0.1) will be blocked. ### Resolution To avoid this potential issue, you can apply one of the following solutions: 1. [Upgrade](/_articles/indepth/development/upgrade.md){:target="_blank"} Dynamic Web TWAIN SDK to **version 17.2.1** or later In version 17.2.1, we have made changes to handle preflight requests on our end to resolve the issue. You can test the latest version with our free trial and when you are ready to upgrade, please contact sales@dynamsoft.com to request the upgrade. Please note that once upgraded, the Dynamic Web TWAIN Service on all client machines also need to be updated. You may consider [installing Dynamic Web TWAIN Service silently](/_articles/faq/can-i-install-dynamsoft-service-silently.md#can-i-install-dynamsoft-service-silently){:target="_blank"}. 2. Disable Private Network Access checks using enterprise policies If you have administrative control over your users, you can disable Private Network Access checks using either of the following policies: InsecurePrivateNetworkRequestsAllowed InsecurePrivateNetworkRequestsAllowedForUrls For more details about managing policies for your users, please refer to Google's help center article. ### If you need more time to implement the solution Register for Google's deprecation trials to request a time extension so your website will not be affected during the trial period which will last for at least 6 months. --- title: Dynamic Web TWAIN SDK – Content-Security-Policy violated description: Dynamic Web TWAIN – Content-Security-Policy violated source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/content-security-policy-violated.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/content-security-policy-violated.md --- View all FAQs about [Project Deployment and End-user Installation]( https://www.dynamsoft.com/web-twain/docs/faq/#project-deployment-and-end-user-installation) # Dynamic Web TWAIN – Content-Security-Policy violated If your server has Content-Security-Policy enabled, you might get an error when accessing a web scanning page using Dynamic Web TWAIN. ``` CSP14312: Resource violated directive 'default-src 'self' 'unsafe-inline' 'unsafe-eval'' in Content-Security-Policy: wss://127.0.0.1:8992/. Resource will be blocked. ``` In such cases, you will need to modify your Content-Security-Policy settings to allow the loading of Dynamic Web TWAIN JS files like dynamsoft.webtwain.initiate.js, dynamsoft.webtwain.config.js. etc. To do so, please set the Content-Security-Policy value on the client or server side to: ``` connect-src 'self' ws://127.0.0.1:18622 wss://127.0.0.1:18623 ws://127.0.0.1:18625 wss://127.0.0.1:18626 http://127.0.0.1:18622 https://127.0.0.1:18623 http://127.0.0.1:18625 https://127.0.0.1:18626 ``` More information can be found on https://content-security-policy.com/ --- title: Dynamic Web TWAIN Service installation and uninstallation issue description: Dynamic Web TWAIN Service installation and uninstallation issue source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/service-installation-issue.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/service-installation-issue.md --- View all FAQs about [Project Deployment and End-user Installation]( https://www.dynamsoft.com/web-twain/docs/faq/#project-deployment-and-end-user-installation) # Dynamic Web TWAIN Service installation and uninstallation issue ### Symptom The old version of Dynamic Web TWAIN Service (also called "Dynamsoft Service") cannot be uninstalled successfully through the Control Panel, and the new version of Dynamic Web TWAIN Service cannot be successfully installed by double-clicking, or the following error message appears during installation. ![service installation-1](/assets/imgs/service-installation-1.png) ### Cause The current user account does not match the user account under C:\Users\{account} In the screenshot below, the current user is owen_thinkpad_t480s, but in 'Command Prompt', the corresponding folder under the C:\Users is ThinkPad. ![service installation-2](/assets/imgs/service-installation-2.png) When installing by double-clicking DynamsoftServiceSetup.msi (from v19.0+, use DynamicWebTWAINServiceSetup.msi) or uninstalling via Control Panel, Dynamic Web TWAIN takes the current user's Temp directory: C:\Users\owen_thinkpad_t480s\AppData\Local\Temp, because this path can't be found, the installation/uninstallation failed. ### Resolution Run 'Command Prompt' as administrator, go to C:\WINDOWS\system32, then execute the following line to uninstall it: ``` shell wmic product where name="Dynamsoft Service" call uninstall /nointeractive //from v19.0+ wmic product where name="Dynamic Web TWAIN Service" call uninstall /nointeractive ``` ![How-to-uninstall-the-Dynamsoft-Service-without MSI-installer.png](/assets/imgs/How-to-uninstall-the-Dynamsoft-Service-without MSI-installer.png) and then run the following command to install Dynamic Web TWAIN Service. ``` shell msiexec /i "/path/to/DynamsoftServiceSetup.msi" /qn //from v19.0+ msiexec /i "/path/to/DynamicWebTWAINServiceSetup.msi" /qn ``` --- title: Can I use two different websites integrated with two different versions of Dynamic Web TWAIN SDK on the same computer? description: Can I use two different websites integrated with two different versions of Dynamic Web TWAIN on the same computer? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/service-backward-compatibility.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/service-backward-compatibility.md --- View all FAQs about [Project Deployment and End-user Installation]( https://www.dynamsoft.com/web-twain/docs/faq/#project-deployment-and-end-user-installation) # Running two different websites integrated with two different versions of Dynamic Web TWAIN on the same computer Dynamic Web TWAIN has limited backward compatibility between different versions and generally only one version is expected to be used on an end-user's computer. However, since Dynamic Web TWAIN is a popular document scanning SDK and has been integrated to many web applications all over the world, it is not uncommon that some end users use two different websites (developed by two different vendors) integrated with different versions of Dynamic Web TWAIN on the same computer. As a result, we have provided the following instructions for backward compatibility for some of the older versions, in order to support running both versions on the same computer. From 16.x, the latest service within the major version supports all previous versions of the same major version. > Note: There is a known issue for the 17.2 and 17.2.x services. Please use the 17.3 service if you are using 17.x as your latest service. ### Instructions for setting up cross major version support 1. Install the _older_ version of Dynamic Web TWAIN Service (also called "Dynamsoft Service"). 2. Copy the .dll files from `C:\Windows\SysWOW64\Dynamsoft\DynamsoftService64_{version number}\` to a temporary location. For the list of .dll files you are required to copy, please refer to the list below. 3. Install the _newer_ version of the Dynamic Web TWAIN Service. 4. Copy the .dll files from your temporary location into the _new_ Dynamic Web TWAIN Service folder (from v19.0+, the target path is `C:\Program Files (x86)\Dynamsoft\Dynamic Web TWAIN Service {version number}`). ### List of required .dll files
- [v19.0+](#19plus) - [Versions below 19.0](#19min)
**Version 18.x** ```javascript dwt_18.5.1.0828.dll DynamicImagex64.dll DynamicPdfCorex64_11.5.3.0828.dll DynamicPdfRx64_11.5.3.0828.dll DWASManager_18500312.dll DeviceManager_18510828.dll UploadModule_1.8.5.0828.dll dbrx64_9.6.1.0312.dll ``` **Version 17.x** ```javascript dwt_17.3.5.1212.dll DynamicImagex64.dll DynamicPdfCorex64_11.4.0.0531.dll DynamicPdfRx64_11.4.0.0531.dll DWASManager_17351212.dll DynamicSocket.dll libcrypto-1_1-x64.dll libssl-1_1-x64.dll UploadModule_1.7.2.1026.dll dbrx64_8.8.0.0531.dll x64 ``` **Version 16.x** ```javascript dwt_16.2.6.1212.dll DynamicImagex64.dll DynamicPdfCorex64_11.1.0.0112.dll DynamicPdfRx64_11.1.0.0112.dll DWASManager_16261212.dll DynamicSocket.dll libeay32.dll ssleay32.dll UploadModule_1.6.0.0428.dll dbrx64_7.6.0.0112.dll x64 ``` **Version 15.x** ```javascript dwt_15.3.4.1212.dll DynamicImagex64.dll DynamicPdfCorex64_10.3.3.0924.dll DynamicPdfRx64_10.3.3.0924.dll DWASManager_15341212.dll DynamicSocket.dll libeay32.dll ssleay32.dll UploadModule_1.4.0.0107.dll dbrx64_7.3.0.0107.dll x64 ```
**Version 17.x** ```javascript dwt_17.3.0.0531.dll DynamicPdfCorex64_11.4.0.0531.dll DynamicPdfRx64_11.4.0.0531.dll libcrypto-1_1-x64.dll ``` **Version 16.x** ```javascript dwt_16.2.0.0112.dll DynamicPdfCorex64_11.1.0.0112.dll DynamicPdfRx64_11.1.0.0112.dll ``` **Version 15.3.1** ```javascript dwt_15.3.0.0116.dll DynamicPdfCorex64_10.3.3.0924.dll DynamicPdfRx64_10.3.3.0924.dll ``` **Version 15.3** ```javascript dwt_15.3.0.0107.dll DynamicPdfCorex64_10.3.3.0924.dll DynamicPdfRx64_10.3.3.0924.dll ``` **Version 15.2** ```javascript dwt_15.2.0.0924.dll DynamicPdfCorex64_10.3.3.0924.dll DynamicPdfRx64_10.3.3.0924.dll ``` **Version 15.1** ```javascript dwt_15.1.0.0806.dll DynamicPdfCorex64_10.3.2.0806.dll DynamicPdfRx64_10.3.2.0806.dll ``` **Version 15.0** ```javascript dwt_15.0.0.0625.dll DynamicPdfCorex64_10.3.1.0124.dll DynamicPdfRx64_10.3.1.0124.dll ```
--- title: Error Message - The connection from the insecure (HTTP) web page to the local 'Dynamsoft Service' failed description: Error Message - The connection from the insecure (HTTP) web page to the local 'Dynamsoft Service' failed source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/connection-from-the-insecure-HTTP-to-service-failed.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/connection-from-the-insecure-HTTP-to-service-failed.md --- # Error Troubleshooting ## Error Message - The connection from the insecure (HTTP) web page to the local 'Dynamsoft Service' failed ### Symptom On Windows 7 x86, Win7 64 Enterprise (or any older Windows OS), you get an error message that says **"The connection from the insecure (HTTP) web page to the local 'Dynamsoft Service' failed. To fix the issue, please update your website to HTTPS or refer to [this article](/_articles/faq/http-insecure-websites-in-chromium-browser.md){:target="_blank"} for other workarounds"** even if you are accessing a secure (HTTPs) web page. And refresh the web page does not work. ### Cause This issue is only limited on Windows 7, likely the cause is due to TLS 1.2 is not enabled on Windows 7 by default (this protocol is enabled by default on Windows 8 and higher versions), which leads to GoDaddy Cert can't be recognized. ### Resolution There are 2 resolutions to fix this issue. **Resolution 1:** Install Service Pack 1 for Windows 7 or Windows Server 2008 R2. See more details here. **Resolution 2:** Update Godaddy Cert - Click here to download the certs. - Run `Certmgr.msc` to open Certificate Manager Tool ![connection-from-HTTP-to-service-failed-1](/assets/imgs/connection-from-HTTP-to-service-failed-1.png) - Import `godaddy Trusted Root Cert.cer` to Trusted Root Certification Authorities. - Import `godaddy Intermediate Cert.cer` to Intermediate Certificate Authorities. ![connection-from-HTTP-to-service-failed-2](/assets/imgs/connection-from-HTTP-to-service-failed-2.png) --- title: Scanner source is listed on XSane application but not on my web application on Linux machines description: Scanner source is listed on XSane application but not on my web application on Linux machines source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/source-not-listed-on-linux.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/source-not-listed-on-linux.md --- View all FAQs about [Project Deployment and End-user Installation]( https://www.dynamsoft.com/web-twain/docs/faq/#project-deployment-and-end-user-installation) # Scanner source is listed on XSane application but not on my web application on Linux machines ### Symptom On Linux machines, the scanner can be accessed using the XSane application and it can successfully scan. But the scanner does not show on the web application integrated with Dynamic Web TWAIN even after the Dynamic Web TWAIN Service (also called "Dynamsoft Service") is installed. ### Cause Dynamic Web TWAIN Service is not installed correctly. ### Resolution
- [v19.0+](#19plus) - [Versions below 19.0](#19min)
Please follow the steps below to reinstall Dynamic Web TWAIN Service: 1. Run the following commands ``` shell su usermod -aG wheel XXX ps:XXX is current username ``` 2. Restart the terminal under current user 3. Run the following command ``` shell sudo rpm -i DynamicWebTWAINServiceSetup.rpm OR sudo dpkg -i DynamicWebTWAINServiceSetup.deb ``` If the above does not resolve the issue, please follow the troubleshooting steps below. 1. Run the command below and check whether the process (DynamsoftScanningMgr) has started. ``` shell ps aux | grep dynamsoft ``` 2. Does the below command list out the source? ``` shell bash /opt/dynamsoft/DynamicWebTWAINService/DynamsoftScanning list ``` 3. Please check the logs here: /var/log/syslog
Please follow the steps below to reinstall Dynamsoft Service: 1. Run the following commands ``` shell su usermod -aG wheel XXX ps:XXX is current username ``` 2. Restart the terminal under current user 3. Run the following command ``` shell sudo rpm -i DynamsoftServiceSetup.rpm OR sudo dpkg -i DynamsoftServiceSetup.deb ``` If the above does not resolve the issue, please follow the troubleshooting steps below. 1. Run the command below and check whether the process (DynamsoftScanningMgr) has started. ``` shell ps aux | grep dynamsoft ``` 2. Does the below command list out the source? ``` shell bash /opt/dynamsoft/DynamsoftService/DynamsoftScanning list ``` 3. Please check the logs here: /var/log/syslog
For further support, please email support@dynamsoft.com and include any screenshots and logs collected.
--- title: The scanner's UI or the system's file dialog does not open when scanning description: The scanner's UI or the system's file dialog does not open when scanning source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/service-is-blocked.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/service-is-blocked.md --- View all FAQs about [Project Deployment and End-user Installation]( https://www.dynamsoft.com/web-twain/docs/faq/#project-deployment-and-end-user-installation) # The scanner's UI or the system's file dialog does not open when scanning ### Symptom Dynamic Web TWAIN Service (also called "Dynamsoft Service") is installed successfully, but when attempting to scan or load files, the scanner's UI or the system's file dialog does not open. You may also see the error, "The pipe is being closed." ### Cause **Cause One** This can be due to permissions, firewall, or other programs (e.g. anti-virus) blocking connections to the Dynamic Web TWAIN Service. To determine if Dynamic Web TWAIN Service is blocked by another process, open Task Manager and go to the Details Tab. Typically, before opening the scan page, you will see three Dynamic Web TWAIN Service processes listed: two under SYSTEM and one under the user account.
![service blocked-1](/assets/imgs/service-blocked-1.png)
When you open the scan page, two new processes are created under the user account.
![service blocked-2](/assets/imgs/service-blocked-2.png)
If these two processes are not under the user account, we can confirm that Dynamic Web TWAIN Service is being blocked by another process. **Cause Two** The issue occurs when the allocated memory address exceeds the 32-bit limit. In this situation, it becomes impossible to access resources under the current user's permissions, such as save/load operations. Notably, 32-bit scanning and memory uploads remain unaffected. This issue is present in all versions before 18.2. ### Resolution #### Resolution for Cause 1 To determine which process is blocking Dynamic Web TWAIN Service, please follow the steps below. 1. Collect [verbose log](/_articles/faq/general-troubleshooting-steps.md#how-to-enable-and-collect-verbose-log){:target="_blank"} 2. Open the file wts.log and search for the string "GetConnectionProcessID" to locate the line: *GetConnectionProcessID:: connection client 1960 process is xxxxx.* [xxxxx] indicates the connection process id, which will identify a process in Task Manager. This process should should typically be a browser process. ![service blocked-3](/assets/imgs/service-blocked-3.png) However, if the identified PID is not a browser process as expected, the PID will typically be the process which is blocking Dynamic Web TWAIN Service. If you need further assistance, please contact Dynamsoft Support. #### Resolution for Cause 2 Please contact [Dynamsoft](https://www.dynamsoft.com/contact/) for patched installer.
--- title: Why I cannot hide the loading bar (spinner)? description: Why I cannot hide the loading bar (spinner)? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/unable-hide-loading-bar.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/unable-hide-loading-bar.md --- # UI Customization ## Why I cannot hide the loading bar (spinner)? ### Symptom: In v17.3 of the Dynamic Web TWAIN SDK, you may find the spinner is unable to hide with the method mentioned in this [article](/_articles/extended-usage/ui-customization.md#loading-bar-and-backdrop), it will continue to spin or will never stop. ![image1](/assets/imgs/unable_hide_spinner_spinner.png) ### Cause: The event `Dynamsoft.OnWebTwainPreExecuteCallback` is not registered in the **dynamsoft.webtwain.install.js** file in v17.3 so that the `Dynamsoft.DWT.OnWebTwainPreExecute()` will never be called. ### Workaround: Step 1) In the **dynamsoft.webtwain.install.js** file, add the event behind the function `OnWebTwainPostExecuteCallback`. ![image3](/assets/imgs/unable_hide_spinner_install_code2.png) ````javascript Dynamsoft.OnWebTwainPreExecuteCallback = function(){ console.log("OnWebTwainPreExecuteCallback") } ```` Step 2) Follow the step in this [article](/_articles/extended-usage/ui-customization.md#loading-bar-and-backdrop). *Note: If `Dynamsoft.DWT.AutoLoad` in your code is set to false, please contact us.* --- title: How to upload multiple files at a time? description: How to upload multiple files at a time? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/upload-multiple-files-at-a-time.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/upload-multiple-files-at-a-time.md --- # Document Saving ## How to upload multiple files at a time? ### Scenario: After scanning multiple files, you might want to upload them one by one as individual images. Before version 13.1, you have to call the upload method(s) multiple times. From version 13.1+, you can do this in one go. ### Solution: You can use the methods [ConvertToBlob](/_articles/info/api/WebTwain_IO.md#converttoblob) and [HTTPUpload](/_articles/info/api/WebTwain_IO.md#httpupload) to achieve this. ### Steps: 1. In JS, write code similar to the following: ```javascript function UploadAsJPG() { var count = 0; DWTObject.ClearAllHTTPFormField(); DWTObject.SetHTTPFormField("UploadedImagesCount",DWTObject.HowManyImagesInBuffer); function asyncFailureFunc(errorCode, errorString) { alert("ErrorCode: " + errorCode + "\r" + "ErrorString:" + errorString); }; var onEmptyResponse = function () { console.log("Uploaded Successfully"); }; var onServerReturnedSomething = function (ecode,estring,resp) { console(resp); } var convertImage = function (_index) { DWTObject.ConvertToBlob( [_index], Dynamsoft.DWT.EnumDWT_ImageType.IT_JPG, function (result) { DWTObject.SetHTTPFormField('image_' + _index, result, 'JPG_image_' + _index); count++; if (count < DWTObject.HowManyImagesInBuffer) { convertImage(count); } else { DWTObject.HTTPUpload("http://localhost:90/saveUploadedJPG.aspx", onEmptyResponse, onServerReturnedSomething);// Please replace the URL with yours. } }, asyncFailureFunc ); }; convertImage(0); } ``` 2. On the server, add an action page to process the uploaded data, take c# as an example, ```csharp <%@ Page Language="C#" %> <% try { String strImageName; String strInfo = HttpContext.Current.Request["UploadedImagesCount"]; short uploadedImagesCount = Convert.ToInt16(strInfo); HttpFileCollection files = HttpContext.Current.Request.Files; for (short i = 0; i < uploadedImagesCount; i++) { HttpPostedFile uploadfile = files["image_" + i.ToString()]; strImageName = uploadfile.FileName; uploadfile.SaveAs(Server.MapPath(".") + "\\UploadedImages\\" + strImageName + ".jpg"); } } catch { } %> ``` --- title: Dynamic Web TWAIN SDK FAQs Develop How to Exclude WIA Sources in the Source List description: Dynamic Web TWAIN SDK Documentation FAQs How to Exclude WIA Sources in the Source List source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/how-to-exclude-wia-sources-in-the-source-list.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/how-to-exclude-wia-sources-in-the-source-list.md --- # Develop ## How to exclude WIA sources in the source list? > Applicable to Windows only There are two ways to achieve this: * Set [IfUseTwainDSM](/_articles/info/api/WebTwain_Acquire.md#ifusetwaindsm) to `true` ``` javascript DWTObject.IfUseTwainDSM = true; ``` * Filter sources before listing them ``` javascript var sources = DWTObject.GetSourceNames(); sources = sources.filter(source => !source.toLowerCase().includes('wia')); ``` If you are still having issues with a device, please feel free to [contact us](https://www.dynamsoft.com/company/contact/) via email, live chat, or phone call. --- title: Error Message - Source has nothing to capture description: Error Message - Source has nothing to capture source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/source-has-nothing-to-capture.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/source-has-nothing-to-capture.md --- # Error Troubleshooting ## Error Message - Source has nothing to capture ### Symptom On Linux, calling `ErrorCode`/`ErrorString` after a scan could return code 1029 with “Source has nothing to capture,” even though scanning completed successfully. ### Solution The message was cosmetic only. It was fixed in Dynamic Web TWAIN 18.0. On 18.0 or later, no action is required. If you are on an earlier version and see 1029 despite a successful scan, you can ignore it or upgrade to 18.0+ to remove the message. --- title: Warning message - Canvas2D Warning description: Canvas2D Warning source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/chrome-106-107-warning.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/chrome-106-107-warning.md --- # Error Troubleshooting ## Warning message - Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true. > Archived: This warning was fixed in Dynamic Web TWAIN 18.0. The steps below are only for projects pinned to versions prior to 18.0. ### Symptom When you are using Chrome 107(developer version) & 106 (official version) or any version above these, you could encounter a warning in console: ```shell Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true. See: https://html.spec.whatwg.org/multipage/canvas.html#concept-canvas-will-read-frequently ``` ### Cause Based on Google developer guide, the setting for attribute `willReadFrequently` in `getContext("2d")` has to be `true` if you are using Chrome 107(developer version) & 106 (official version) or higher, otherwise it will show this warning message. ### Solution Step 1. Navigate to '../Resources/dynamsoft.webtwain.initiate.js' replace all `getContext("2d")` to `getContext("2d",{willReadFrequently:true})` Step 2. Navigate to '../Resources/src/dynamsoft.viewer.js' replace all `getContext("2d")` to `getContext("2d",{willReadFrequently:true})` ### Status Fixed in Dynamic Web TWAIN 18.0+. No action is needed on supported versions. --- title: Error Message - Uncaught TypeError - Cannot read properties of null (reading 'appendChild') or Failed to execute 'appendChild' on 'Node' - parameter 1 is not of type 'Node'. description: Error Message - Uncaught TypeError - Cannot read properties of null (reading 'appendChild') or Failed to execute 'appendChild' on 'Node'- parameter 1 is not of type 'Node'. source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/type-error-appendchild.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/type-error-appendchild.md --- # Error Troubleshooting ## Error Message - Uncaught TypeError: Cannot read properties of null (reading 'appendChild') or Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'. ### Symptom: You may see the following errors when you open your application. These errors may be sporadic or may halt your application. - **Uncaught TypeError: Cannot read properties of null (reading 'appendChild')** - **Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'** ### Cause: Typically, an application uses `DWTObject = Dynamsoft.DWT.GetWebTwain('dwtcontrolContainer')` to create the object at the target container. There are certain conditions where Dynamic Web TWAIN's initialization process will complete, but after initialization, the target container is not defined or remains null. You will then see the error when trying to upload your files. ### Workaround: Please check if your container is created dynamically (especially if you are using dynamic frameworks). There are two ways to address the issue. (1) If you want to use dynamic initialization method, here is sample code to create the object dynamically: ```javascript Dynamsoft.DWT.CreateDWTObjectEx( { WebTwainId: 'myDWT' }, function(obj) { DWTObject = obj; DWTObject.Viewer.bind(document.getElementById('dwtcontrolContainer')); DWTObject.Viewer.height = 400; DWTObject.Viewer.width = 600; DWTObject.Viewer.show(); }, function(err) { console.log(err); } ); ``` (2) If you want to use default initialization method, please set `Dynamsoft.DWT.AutoLoad` to `false` and manually implement `Dynamsoft.DWT.Load()` after you confirm the container has been created. --- title: Error message - User cancelled the operation description: Error message - User cancelled the operation source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/error-message-user-cancelled-the-operation.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/error-message-user-cancelled-the-operation.md --- # Error Troubleshooting ## Error message - User cancelled the operation ### Symptom You may encounter the error "user cancelled the operation" after successfully scanning all pages. But you can still run the application normally. ### Cause 1) The user manually terminated the ongoing operation. 2) This is known to happen if you use a **WIA/WIATWAIN** driver instead of TWAIN driver. Our SDK is developed based upon the TWAIN protocol, therefore the performance in WIA driver cannot be guaranteed. ### Resolution (For versions prior to v18.2) To prevent any issues related to the WIA driver, we recommend using the TWAIN driver provided by the manufacturer.
(For v18.2 and above) To mitigate potential problems with the WIATWAIN driver, we suggest using either the TWAIN driver from the manufacturer or the WIA driver, which is officially supported starting from version v18.2.
--- title: The loading bar keeps spinning when capture the image with iPhone. description: The loading bar keeps spinning when capture the image with iPhone. source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/the-loading-bar-keeps-spinning-when-capture-the-image-with-iphone.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/the-loading-bar-keeps-spinning-when-capture-the-image-with-iphone.md --- # Error Troubleshooting ## The loading bar keeps spinning when capturing images with iPhone. ### Symptom iOS 16.4 was released on March 27th, 2023. In this version, all browsers on iOS have begun to support `OffscreenCanvas`. Unfortunately, Apple's implementation of the API is still incomplete and is missing an important feature: "webgl context". Please see the MDN docs on [OffscreenCanvas](https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas) for more details. ### Cause `OffscreenCanvas` is utilized in all versions of the Dynamic Web TWAIN Mobile Web Capture Edition. After you upgrade your iOS to v16.4, the loading bar will keep spinning when you try to capture an image. Note that the Service Edition is not affected by this issue. ### Resolution Add the following lines of code to disable the API. ```javascript if (Dynamsoft.navInfoSync.biPhone || Dynamsoft.navInfoSync.biPad) { window.OffscreenCanvas = null } ``` **Or** download the patch version: - For NPM project, please upgrade your dwt package to `v17.3.4` or `v18.0.2`. - For Non-NPM application, please download the new camera.js file below and replace the old file with new one under `Resource/addon` directory. - [v17.3 camera.js file](https://tst.dynamsoft.com/public/DWT_FIX/v17.3/OffscreenCanvas/dynamsoft.webtwain.addon.camera.zip) - [v18.0 camera.js file](https://tst.dynamsoft.com/public/DWT_FIX/v18.0/OffscreenCanvas/dynamsoft.webtwain.addon.camera.zip) > If the resolution doesn't work for you, please [contact us](https://www.dynamsoft.com/company/contact/). --- title: How can I support WIA scanner drivers in my application? description: How can I support WIA scanner drivers in my application? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/support-wia-scanner-drivers.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/support-wia-scanner-drivers.md --- # Capture/Image Source ## How can I support WIA scanner drivers in my application? Prior to Dynamic Web TWAIN version 18.2, WIA drivers are not supported and TWAIN drivers are recommended. Please refer to [this article](/_articles/faq/difference-between-Twain-and-wia.md){:target="_blank"} for the differences between WIA and TWAIN drivers. As of Dynamic Web TWAIN version 18.2, we officially support WIA 2.0. By comparison, `WIA` can only control a very limited set of general capabilities of the device, while `TWAIN` can control all standard and even custom capabilities of the device. In addition, `WIA` has only two transfer modes (Memory, File), while `TWAIN` has three (Native, Memory, File). Since Dynamic Web TWAIN v18.0, we introduced a new set of scanner related APIs. To compatible with both TWAIN and WIA 2.0, - If your application is already using the new set of APIs below, no application change is required. - If not, replace the old APIs with the matching new APIs. | New APIs (supports WIA) | Old APIs | |:-|:-| | [GetDeviceAsync()](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Acquire.html#getdevicesasync) | [GetSourceNames()](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Acquire.html#getsourcenames), [GetSourceNamesAsync()](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Acquire.html#getsourcenamesasync)| | [SelectDeviceAsync()](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Acquire.html#selectdeviceasync) | [SelectSourceByIndex()](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Acquire.html#selectsourcebyindex), [SelectSourceByIndexAsync()](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Acquire.html#selectsourcebyindexasync) | | [SelectSourceAsync()](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Acquire.html#selectsourceasync) | [SelectSource()](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Acquire.html#selectsource) | | [AcquireImageAsync()](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Acquire.html#acquireimageasync) | [AcquireImage()](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Acquire.html#acquireimage) | ### Example Code ```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) }) ``` ### Difference between the WIASCANNER and WIATWAINSCANNER DeviceType To support the WIA protocol in v18.2+, we added a new Enumeration `WIASCANNER` to [Dynamsoft.DWT.EnumDWT_DeviceType](https://www.dynamsoft.com/web-twain/docs/info/api/Dynamsoft_Enum.html?ver=latest&&cVer=true#dynamsoftdwtenumdwt_devicetype) . The enumeration named `WIATWAINSCANNER` represents WIA sources mapped through the TWAIN protocol after packaging by Microsoft. It was used in previous versions of Dynamic Web TWAIN and it will continue to be supported. --- title: Why are my images coming out distorted in MacOS Sonoma? description: Why are my images coming out distorted in MacOS Sonoma? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/macos-sonoma-distorted-scans.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/macos-sonoma-distorted-scans.md --- # MacOS Sonoma issue identified ## Symptoms The user may see distorted, duplicated, or ghost copies of the image when acquiring the scan on MacOS while using Dynamic Web TWAIN 18.4 or below. ## Background ICA are the drivers that are put out by the manufacturers to specifically work with the [ImageCaptureCore](https://developer.apple.com/documentation/imagecapturecore) specification on the Mac platform. Generally, the ICA drivers are bundled with MacOS and are updated with MacOS updates. Some manufacturers will make ICA drivers available for their scanners through their own support portals. It has been discovered that with the release of MacOS Sonoma (MacOS 14.0), Dynamic Web TWAIN may behave unexpectedly when acquiring images using ICA drivers. We have investigated and it seems that there was a change in how ICA drivers respond to Dynamic Web TWAIN commands. Based on this information, it would be recommended to avoid upgrading to Sonoma, if possible. However, Dynamsoft understands that many end users will automatically upgrade and therefore adjustments to Dynamic Web TWAIN must be made. ## Solution 1) The recommended solution is to download and install the TWAIN driver from the scanner manufacturer, and use the TWAIN driver. 2) Dynamsoft understands that not all manufacturers provide TWAIN drivers for MacOS. Therefore, Dynamsoft has released Dynamic Web TWAIN 18.4.1 which includes an updated Dynamic Web TWAIN Service (also called "Dynamsoft Service") for MacOS that should help alleviate the issue. Please upgrade to Dynamic Web TWAIN 18.4.1 to utilize this updated Dynamic Web TWAIN Service. --- title: How do I know which SDK version I am using? description: How do I know which SDK version I am using? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/find-SDK-version.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/find-SDK-version.md --- View all FAQs about [Project Deployment and End-user Installation]( https://www.dynamsoft.com/web-twain/docs/faq/#project-deployment-and-end-user-installation) # How do I know which SDK version I am using? ### Introduction Due to Dynamic Web TWAIN being a long-standing and popular product among enterprises, customers who have integrated Dynamic Web TWAIN may be using various versions. To provide better technical support, customers will need to provide the SDK version number they are using to help support team understand the situation more accurately. This article will outline several methods to assist users in finding the current SDK version they are using. ### Resolution * Method 1 > If you are not using NPM to manage Dynamic Web TWAIN resources, you can try to find and open the "**dynamsoft.webtwain.config.js**" file in your project. At the very top of the file, you can see the version number noted by Dynamsoft in the comments.
![config_comment](/assets/imgs/config-comment.png) > If you are using NPM to manage Dynamic Web TWAIN resources, you can try to find and open the "**dynamsoft.webtwain.min.js**" file in your project. At the very top of the file, you can see the version number noted by Dynamsoft in the comments.
![min_comment](/assets/imgs/min-comment.png) * Method 2 > For versions 17.0 and above, you can retrieve the current SDK version by running the code "`Dynamsoft.DWT.JSVersion`". > For versions prior to 17.0, you can obtain the current SDK version by executing the code "`Dynamsoft.WebTwainEnv.JSVersion`" * Method 3 > Let's take Windows as a example, to find the version of Dynamic Web TWAIN Service (also called "Dynamsoft Service") on Windows, you can follow these steps: > 1. Open the Control Panel. > 2. In the Control Panel, click on the "Uninstall a Program" option. > 3. Look for "Dynamic Web TWAIN Service" in the list of installed programs. > 4. The version of Dynamic Web TWAIN Service should be displayed in the program list.
![panel](/assets/imgs/panel.png) If you need further assistance, please contact [Dynamsoft Support](https://www.dynamsoft.com/contact/).
--- title: How to deploy your own upload server with ASP.NET? description: How to deploy your own upload server with ASP.NET? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/deploy-your-own-upload-server-with-asp.net.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/deploy-your-own-upload-server-with-asp.net.md --- # Document Saving ## How to Deploy an Upload Server Using ASP.NET Dynamic Web TWAIN is a client-side JavaScript SDK. However, it does need to interact with the server when performing operations like uploading and downloading. This article introduces how to deploy an upload server using backend ASP.NET code.
Please select your frontend language:
- [Javascript](#Javascript) - [Angular](#Angular) - [React-Javascript](#React-Javascript) - [React-TypeScript](#React-TypeScript) - [Vue-Javascript](#Vue-Javascript) - [Vue-Typescript](#Vue-Typescript)
This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-JavaScript.zip. After unzipping it, the directory structure is shown in the image below. ![javascript.png](/assets/imgs/javascript.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite: Please ensure your web server supports ASP.NET(C#). ### Steps:
  1. Download the server-side ASP.NET code, unzip it and copy the aforementioned "Upload" directory to the "Sample" directory. Under the "Upload" root folder, there is a file "SaveToFile.aspx". This is the backend page that accepts the uploaded data.

  2. Modify the client-side upload function in {path}\Sample\Scripts\online_demo_operation.js, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

function Upload() {
    if (DWTObject && DWTObject.HowManyImagesInBuffer > 0) {
      //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
      var strUrl = "http://{server-path}/Sample/Upload/SaveToFile.aspx";
      var imgAry = [DWTObject.CurrentImageIndexInBuffer];
      DWTObject.HTTPUpload(
        strUrl, 
        imgAry, 
        Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
        Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
        "WebTWAINImage.png", 
        onUploadSuccess, 
        onUploadFailure);
    } else {
      alert("There is no image in buffer.");
    }
}

function onUploadSuccess() {
  alert("Upload successful");
}

function onUploadFailure(errorCode, errorString, sHttpResponse) {
  alert(sHttpResponse.length > 0 ? sHttpResponse : errorString);
}
  1. Copy the "Sample" directory to the IIS website or other web server services.

  2. Navigate to http://{server-path}/Sample/index.html in your browser to access the sample.

This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-Angular.zip. After unzipping it, the directory structure is shown in the image below. ![angular.png](/assets/imgs/angular.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite:
  1. Please ensure that Node.js is installed. The recommended version is v20.13.1.

  2. Please ensure your web server supports ASP.NET(C#).

### Steps:
  1. Download the server-side ASP.NET code, unzip it and copy the "Upload" directory to the "Sample\src\public" directory. Under the "Upload" folder, there is a file "SaveToFile.aspx". This is the backend page that accepts the uploaded data.

  2. Modify the client-side upload function In {path}\Sample\src\app\components\tools\dwtService.ts, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

Upload(): Promise<any> {
  return new Promise((res, rej) => {
    if (this._dwtObject && this._dwtObject.HowManyImagesInBuffer > 0) {
      //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
      let strUrl = "http://{server-path}/dist/Upload/SaveToFile.aspx";
      let imgAry = [this._dwtObject.CurrentImageIndexInBuffer];
      this._dwtObject.HTTPUpload(
        strUrl, 
        imgAry, 
        Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
        Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
        "WebTWAINImage.png", 
        ()=>{
          res();
        }, (errCode, errString, responseStr) => { 
          rej({
            code: errCode,
            message: errString
          });
        });
    } else {
      rej({
        code: -1,
        message: "There is no image in buffer."
      });
    }
  }
}
  1. Build the client-side project

    Open your terminal or Command Prompt and execute the following three commands to build the project:

    1). Navigate to the Sample directory:

    cd [path]/Sample
    

    2). Install the dependencies:

    npm install
    

    3). Build the project:

    npm run build
    
  2. Copy the "Sample/dist" directory, which is built, to the web server.

  3. Navigate to http://{server-path}/dist/index.html in your browser to access the sample.

This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-React-JavaScript.zip. After unzipping it, the directory structure is shown in the image below. ![react.png](/assets/imgs/react.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite:
  1. Please ensure that Node.js is installed. The recommended version is v20.13.1.

  2. Please ensure your web server supports ASP.NET(C#).

### Steps:
  1. Download the server-side ASP.NET code, unzip it and copy the "Upload" directory to the "Sample\public" directory. Under the "Upload" folder, there is a file "SaveToFile.aspx". This is the backend page that accepts the uploaded data.

  2. Modify the client-side upload function In {path}\Sample\src\components\tools\dwtService.js, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

Upload() {
  return new Promise((res, rej) => {
    if (this._dwtObject && this._dwtObject.HowManyImagesInBuffer > 0) {
      //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
      let strUrl = "http://{server-path}/dist/Upload/SaveToFile.aspx";
      let imgAry = [this._dwtObject.CurrentImageIndexInBuffer];
      this._dwtObject.HTTPUpload(
        strUrl, 
        imgAry, 
        Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
        Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
        "WebTWAINImage.png", 
        ()=>{
          res();
        }, (errCode, errString, responseStr) => { 
          rej({
            code: errCode,
            message: errString
          });
        });
    } else {
      rej({
        code: -1,
        message: "There is no image in buffer."
      });
    }
  }
}
  1. Build the client-side project

    Open your terminal or Command Prompt and execute the following three commands to build the project:

    1). Navigate to the Sample directory:

    cd [path]/Sample
    

    2). Install the dependencies:

    npm install
    

    3). Build the project:

    npm run build
    
  2. Copy the "Sample/dist" directory, which is built, to the web server.

  3. Navigate to http://{server-path}/dist/index.html in your browser to access the sample.

This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-React-TypeScript.zip. After unzipping it, the directory structure is shown in the image below. ![react-typescript.png](/assets/imgs/react-typescript.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite:
  1. Please ensure that Node.js is installed. The recommended version is v20.13.1.

  2. Please ensure your web server supports ASP.NET(C#).

### Steps:
  1. Download the server-side ASP.NET code, unzip it and copy the "Upload" directory to the "Sample\public" directory. Under the "Upload" folder, there is a file "SaveToFile.aspx". This is the backend page that accepts the uploaded data.

  2. Modify the client-side upload function In {path}\Sample\src\components\tools\dwtService.ts, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

Upload(): Promise<any> {
  return new Promise((res, rej) => {
    if (this._dwtObject && this._dwtObject.HowManyImagesInBuffer > 0) {
      //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
      let strUrl = "http://{server-path}/dist/Upload/SaveToFile.aspx";
      let imgAry = [this._dwtObject.CurrentImageIndexInBuffer];
      this._dwtObject.HTTPUpload(
        strUrl, 
        imgAry, 
        Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
        Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
        "WebTWAINImage.png", 
        ()=>{
          res();
        }, (errCode, errString, responseStr) => { 
          rej({
            code: errCode,
            message: errString
          });
        });
     } else {
      rej({
        code: -1,
        message: "There is no image in buffer."
      });
    }
  }
}
  1. Build the client-side project

    Open your terminal or Command Prompt and execute the following three commands to build the project:

    1). Navigate to the Sample directory:

    cd [path]/Sample
    

    2). Install the dependencies:

    npm install
    

    3). Build the project:

    npm run build
    
  2. Copy the "Sample/dist" directory, which is built, to the web server.

  3. Navigate to http://{server-path}/dist/index.html in your browser to access the sample.

This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-Vue-JavaScript.zip. After unzipping it, the directory structure is shown in the image below. ![vue.png](/assets/imgs/vue.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite:
  1. Please ensure that Node.js is installed. The recommended version is v20.13.1.

  2. Please ensure your web server supports ASP.NET(C#).

### Steps:
  1. Download the server-side ASP.NET code, unzip it and copy the "Upload" directory to the "Sample\public" directory. Under the "Upload" folder, there is a file "SaveToFile.aspx". This is the backend page that accepts the uploaded data.

  2. Modify the client-side upload function In {path}\Sample\src\components\tools\dwtService.js, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

Upload() {
  return new Promise((res, rej) => {
    if (this._dwtObject && this._dwtObject.HowManyImagesInBuffer > 0) {
      //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
      let strUrl = "http://{server-path}/dist/Upload/SaveToFile.aspx";
      let imgAry = [this._dwtObject.CurrentImageIndexInBuffer];
      this._dwtObject.HTTPUpload(
        strUrl, 
        imgAry, 
        Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
        Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
        "WebTWAINImage.png", 
        ()=>{
          res();
        }, (errCode, errString, responseStr) => { 
          rej({
            code: errCode,
            message: errString
          });
        });
     } else {
      rej({
        code: -1,
        message: "There is no image in buffer."
      });
    }
  }
}
  1. Build the client-side project

    Open your terminal or Command Prompt and execute the following three commands to build the project:

    1). Navigate to the Sample directory:

    cd [path]/Sample
    

    2). Install the dependencies:

    npm install
    

    3). Build the project:

    npm run build
    
  2. Copy the "Sample/dist" directory, which is built, to the web server.

  3. Navigate to http://{server-path}/dist/index.html in your browser to access the sample.

This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-Vue-TypeScript.zip. After unzipping it, the directory structure is shown in the image below. ![vue-typescript.png](/assets/imgs/vue-typescript.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite:
  1. Please ensure that Node.js is installed. The recommended version is v20.13.1.

  2. Please ensure your web server supports ASP.NET(C#).

### Steps:
  1. Download the server-side ASP.NET code, unzip it and copy the "Upload" directory to the "Sample\public" directory. Under the "Upload" folder, there is a file "SaveToFile.aspx". This is the backend page that accepts the uploaded data.

  2. Modify the client-side upload function In {path}\Sample\src\components\tools\dwtService.ts, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

Upload(): Promise<any> {
  return new Promise((res, rej) => {
    if (this._dwtObject && this._dwtObject.HowManyImagesInBuffer > 0) {
      //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
      let strUrl = "http://{server-path}/dist/Upload/SaveToFile.aspx";
      let imgAry = [this._dwtObject.CurrentImageIndexInBuffer];
      this._dwtObject.HTTPUpload(
        strUrl, 
        imgAry, 
        Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
        Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
        "WebTWAINImage.png", 
        ()=>{
          res();
        }, (errCode, errString, responseStr) => { 
          rej({
            code: errCode,
            message: errString
          });
        });
     } else {
      rej({
        code: -1,
        message: "There is no image in buffer."
      });
    }
  }
}
  1. Build the client-side project

    Open your terminal or Command Prompt and execute the following three commands to build the project:

    1). Navigate to the Sample directory:

    cd [path]/Sample
    

    2). Install the dependencies:

    npm install
    

    3). Build the project:

    npm run build
    
  2. Copy the "Sample/dist" directory, which is built, to the web server.

  3. Navigate to http://{server-path}/dist/index.html in your browser to access the sample.

### Online Demo

https://demo.dynamsoft.com/web-twain/

--- title: How to deploy your own upload server with JSP? description: How to deploy your own upload server with JSP? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/deploy-your-own-upload-server-with-jsp.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/deploy-your-own-upload-server-with-jsp.md --- # Document Saving ## How to Deploy an Upload Server Using JSP Dynamic Web TWAIN is a client-side JavaScript SDK. However, it does need to interact with the server when performing operations like uploading and downloading. This article introduces how to deploy an upload server using backend JSP code.
Please select your frontend language:
- [Javascript](#Javascript) - [Angular](#Angular) - [React-Javascript](#React-Javascript) - [React-TypeScript](#React-TypeScript) - [Vue-Javascript](#Vue-Javascript) - [Vue-Typescript](#Vue-Typescript)
This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-JavaScript.zip. After unzipping it, the directory structure is shown in the image below. ![javascript.png](/assets/imgs/javascript.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite: Please ensure your web server that has the Java Development Kit (JDK) installed and supports Java Server Pages (JSP). ### Steps:
  1. Download the server-side JSP code, unzip it and copy the aforementioned "Upload" directory to the "Sample" directory. Under the "Upload" root folder, there is a file "SaveToFile.jsp". This is the backend page that accepts the uploaded data.

  2. Modify the client-side upload function In {path}\Sample\Scripts\online_demo_operation.js, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

function Upload() {
    if (DWTObject && DWTObject.HowManyImagesInBuffer > 0) {
      //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
      var strUrl = "http://{server-path}/Sample/Upload/SaveToFile.jsp";
      var imgAry = [DWTObject.CurrentImageIndexInBuffer];
      DWTObject.HTTPUpload(
        strUrl, 
        imgAry, 
        Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
        Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
        "WebTWAINImage.png", 
        onUploadSuccess, 
        onUploadFailure);
    } else {
      alert("There is no image in buffer.");
    }
}

function onUploadSuccess() {
  alert("Upload successful");
}

function onUploadFailure(errorCode, errorString, sHttpResponse) {
  alert(sHttpResponse.length > 0 ? sHttpResponse : errorString);
}
  1. Copy the "Sample" directory to the web server. For example, if you are using Tomcat 10.1.16, copy it to "{Tomcat-installed-path}/webapps".

  2. Restart the web server.

  3. Navigate to http://{server-path}/Sample/index.html in your browser to access the sample.

This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-Angular.zip. After unzipping it, the directory structure is shown in the image below. ![angular.png](/assets/imgs/angular.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite:
  1. Please ensure that Node.js is installed. The recommended version is v20.13.1.

  2. Please ensure your web server that has the Java Development Kit (JDK) installed and supports Java Server Pages (JSP).

### Steps:
  1. Download the server-side JSP code, unzip it and copy the "Upload" directory to the "Sample\src\public" directory. Under the "Upload" folder, there is a file "SaveToFile.jsp". This is the backend page that accepts the uploaded data.

  2. Modify the client-side upload function In {path}\Sample\src\app\components\tools\dwtService.ts, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

Upload(): Promise<any> {
  return new Promise((res, rej) => {
    if (this._dwtObject && this._dwtObject.HowManyImagesInBuffer > 0) {
      //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
      let strUrl = "http://{server-path}/dist/Upload/SaveToFile.jsp";
      let imgAry = [this._dwtObject.CurrentImageIndexInBuffer];
      this._dwtObject.HTTPUpload(
        strUrl, 
        imgAry, 
        Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
        Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
        "WebTWAINImage.png", 
        ()=>{
          res();
        }, (errCode, errString, responseStr) => {
          rej({
            code: errCode,
            message: errString
          });
        });
    } else {
      rej({
         code: -1,
         message: "There is no image in buffer."
      });
    }
  }
}
  1. Build the client-side project

    Open your terminal or Command Prompt and execute the following three commands to build the project:

    1). Navigate to the Sample directory:

    cd [path]/Sample
    

    2). Install the dependencies:

    npm install
    

    3). Build the project:

    npm run build
    
  2. Copy the "Sample/dist" directory to the web server. For example, if you are using Tomcat 10.1.16, copy it to "{Tomcat-installed-path}/webapps".

  3. Restart the web server.

  4. Navigate to http://{server-path}/dist/index.html in your browser to access the sample.

This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-React-JavaScript.zip. After unzipping it, the directory structure is shown in the image below. ![react.png](/assets/imgs/react.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite:
  1. Please ensure that Node.js is installed. The recommended version is v20.13.1.

  2. Please ensure your web server that has the Java Development Kit (JDK) installed and supports Java Server Pages (JSP).

### Steps:
  1. Download the server-side JSP code, unzip it and copy the "Upload" directory to the "Sample\public" directory. Under the "Upload" folder, there is a file "SaveToFile.jsp". This is the backend page that accepts the uploaded data.

  2. Modify the client-side upload function In {path}\Sample\src\components\tools\dwtService.js, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

Upload() {
  return new Promise((res, rej) => {
    if (this._dwtObject && this._dwtObject.HowManyImagesInBuffer > 0) {
      //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
      let strUrl = "http://{server-path}/dist/Upload/SaveToFile.jsp";
      let imgAry = [this._dwtObject.CurrentImageIndexInBuffer];
      this._dwtObject.HTTPUpload(
      strUrl, 
      imgAry, 
      Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
      Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
      "WebTWAINImage.png", 
      ()=>{
        res();
      }, (errCode, errString, responseStr) => { 
        rej({
           code: errCode,
           message: errString
        });
      });
    } else {
      rej({
        code: -1,
        message: "There is no image in buffer."
      });
    }
  }
}
  1. Build the client-side project

    Open your terminal or Command Prompt and execute the following three commands to build the project:

    1). Navigate to the Sample directory:

    cd [path]/Sample
    

    2). Install the dependencies:

    npm install
    

    3). Build the project:

    npm run build
    
  2. Copy the "Sample/dist" directory to the web server. For example, if you are using Tomcat 10.1.16, copy it to "{Tomcat-installed-path}/webapps".

  3. Restart the web server.

  4. Navigate to http://{server-path}/dist/index.html in your browser to access the sample.

This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-React-TypeScript.zip. After unzipping it, the directory structure is shown in the image below. ![react-typescript.png](/assets/imgs/react-typescript.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite:
  1. Please ensure that Node.js is installed. The recommended version is v20.13.1.

  2. Please ensure your web server that has the Java Development Kit (JDK) installed and supports Java Server Pages (JSP).

### Steps:
  1. Download the server-side JSP code, unzip it and copy the "Upload" directory to the "Sample\public" directory. Under the "Upload" folder, there is a file "SaveToFile.jsp". This is the backend page that accepts the uploaded data.

  2. Modify the client-side upload function In {path}\Sample\src\components\tools\dwtService.ts, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

Upload(): Promise<any> {
  return new Promise((res, rej) => {
    if (this._dwtObject && this._dwtObject.HowManyImagesInBuffer > 0) {
      //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
      let strUrl = "http://{server-path}/dist/Upload/SaveToFile.jsp";
      let imgAry = [this._dwtObject.CurrentImageIndexInBuffer];
      this._dwtObject.HTTPUpload(
      strUrl, 
      imgAry, 
      Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
      Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
      "WebTWAINImage.png", 
      ()=>{
        res();
      }, (errCode, errString, responseStr) => { 
        rej({
           code: errCode,
           message: errString
        });
      });
    } else {
      rej({
         code: -1,
         message: "There is no image in buffer."
      });
    }
  }
}
  1. Build the client-side project

    Open your terminal or Command Prompt and execute the following three commands to build the project:

    1). Navigate to the Sample directory:

    cd [path]/Sample
    

    2). Install the dependencies:

    npm install
    

    3). Build the project:

    npm run build
    
  2. Copy the "Sample/dist" directory to the web server. For example, if you are using Tomcat 10.1.16, copy it to "{Tomcat-installed-path}/webapps".

  3. Restart the web server.

  4. Navigate to http://{server-path}/dist/index.html in your browser to access the sample.

This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-Vue-JavaScript.zip. After unzipping it, the directory structure is shown in the image below. ![vue.png](/assets/imgs/vue.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite:
  1. Please ensure that Node.js is installed. The recommended version is v20.13.1.

  2. Please ensure your web server that has the Java Development Kit (JDK) installed and supports Java Server Pages (JSP).

### Steps:
  1. Download the server-side JSP code, unzip it and copy the "Upload" directory to the "Sample\public" directory. Under the "Upload" folder, there is a file "SaveToFile.jsp". This is the backend page that accepts the uploaded data.

  2. Modify the client-side upload function In {path}\Sample\src\components\tools\dwtService.js, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

Upload() {
  return new Promise((res, rej) => {
    if (this._dwtObject && this._dwtObject.HowManyImagesInBuffer > 0) {
      //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
      let strUrl = "http://{server-path}/dist/Upload/SaveToFile.jsp";
      let imgAry = [this._dwtObject.CurrentImageIndexInBuffer];
      this._dwtObject.HTTPUpload(
      strUrl, 
      imgAry, 
      Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
      Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
      "WebTWAINImage.png", 
      ()=>{
        res();
      }, (errCode, errString, responseStr) => { 
        rej({
          code: errCode,
          message: errString
        });
      });
    } else {
      rej({
        code: -1,
        message: "There is no image in buffer."
      });
    }
  }
}
  1. Build the client-side project

    Open your terminal or Command Prompt and execute the following three commands to build the project:

    1). Navigate to the Sample directory:

    cd [path]/Sample
    

    2). Install the dependencies:

    npm install
    

    3). Build the project:

    npm run build
    
  2. Copy the "Sample/dist" directory to the web server. For example, if you are using Tomcat 10.1.16, copy it to "{Tomcat-installed-path}/webapps".

  3. Restart the web server.

  4. Navigate to http://{server-path}/dist/index.html in your browser to access the sample.

This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-Vue-TypeScript.zip. After unzipping it, the directory structure is shown in the image below. ![vue-typescript.png](/assets/imgs/vue-typescript.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite:
  1. Please ensure that Node.js is installed. The recommended version is v20.13.1.

  2. Please ensure your web server that has the Java Development Kit (JDK) installed and supports Java Server Pages (JSP).

### Steps:
  1. Download the server-side JSP code, unzip it and copy the "Upload" directory to the "Sample\public" directory. Under the "Upload" folder, there is a file "SaveToFile.jsp". This is the backend page that accepts the uploaded data.

  2. Modify the client-side upload function In {path}\Sample\src\components\tools\dwtService.ts, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

Upload(): Promise<any> {
  return new Promise((res, rej) => {
    if (this._dwtObject && this._dwtObject.HowManyImagesInBuffer > 0) {
      //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
      let strUrl = "http://{server-path}/dist/Upload/SaveToFile.jsp";
      let imgAry = [this._dwtObject.CurrentImageIndexInBuffer];
      this._dwtObject.HTTPUpload(
      strUrl, 
      imgAry, 
      Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
      Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
      "WebTWAINImage.png", 
      ()=>{
        res();
      }, (errCode, errString, responseStr) => { 
        rej({
          code: errCode,
          message: errString
        });
      });
    } else {
      rej({
        code: -1,
        message: "There is no image in buffer."
      });
    }
  }
}
  1. Build the client-side project

    Open your terminal or Command Prompt and execute the following three commands to build the project:

    1). Navigate to the Sample directory:

    cd [path]/Sample
    

    2). Install the dependencies:

    npm install
    

    3). Build the project:

    npm run build
    
  2. Copy the "Sample/dist" directory to the web server. For example, if you are using Tomcat 10.1.16, copy it to "{Tomcat-installed-path}/webapps".

  3. Restart the web server.

  4. Navigate to http://{server-path}/dist/index.html in your browser to access the sample.

### Online Demo

https://demo.dynamsoft.com/web-twain/

--- title: How to deploy your own upload server with Node.js? description: How to deploy your own upload server with Node.js? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/deploy-your-own-upload-server-with-node.js.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/deploy-your-own-upload-server-with-node.js.md --- # Document Saving ## How to Deploy an Upload Server Using Node.js Dynamic Web TWAIN is a client-side JavaScript SDK. However, it does need to interact with the server when performing operations like uploading and downloading. This article introduces how to deploy an upload server using backend Node.js code.
Please select your frontend language:
- [Javascript](#Javascript) - [Angular](#Angular) - [React-Javascript](#React-Javascript) - [React-TypeScript](#React-TypeScript) - [Vue-Javascript](#Vue-Javascript) - [Vue-Typescript](#Vue-Typescript)
This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-JavaScript.zip. After unzipping it, the directory structure is shown in the image below. ![javascript.png](/assets/imgs/javascript.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite: Please ensure that Node.js is installed. The recommended version is v20.13.1. ### Steps:
  1. Download the server-side Node.js code, unzip it. Under the "Upload" folder, there is a file "server.js". This is the backend page that accepts the uploaded data.

  2. Run the server-side project

    Open your terminal or Command Prompt and execute the following three commands to start the project:

    1). Navigate to the server-side Sample directory:

    cd [path]/Upload
    

    2). Install the dependencies:

    npm install
    

    3). Run the application:

    npm start
    
  3. Modify the client-side upload function In {path}\Sample\Scripts\online_demo_operation.js, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

function Upload() {
  if (DWTObject && DWTObject.HowManyImagesInBuffer > 0) {
    //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
    var strUrl = "http://localhost:2020/Upload";
    var imgAry = [DWTObject.CurrentImageIndexInBuffer];
    DWTObject.HTTPUpload(
      strUrl, 
      imgAry, 
      Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
      Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
      "WebTWAINImage.png", 
      onUploadSuccess, 
      onUploadFailure);
  } else {
    alert("There is no image in buffer.");
  }
}

function onUploadSuccess() {
  alert("Upload successful");
}

function onUploadFailure(errorCode, errorString, sHttpResponse) {
  alert(sHttpResponse.length > 0 ? sHttpResponse : errorString);
}
  1. Copy the "Sample" directory to the web server.

  2. Navigate to http://{server-path}/Sample/index.html in your browser to access the sample.

This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-Angular.zip. After unzipping it, the directory structure is shown in the image below. ![angular.png](/assets/imgs/angular.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite: Please ensure that Node.js is installed. The recommended version is v20.13.1. ### Steps:
  1. Download the server-side Node.js code, unzip it. Under the "Upload" folder, there is a file "server.js". This is the backend page that accepts the uploaded data.

  2. Run the server-side project

    Open your terminal or Command Prompt and execute the following three commands to start the project:

    1). Navigate to the server-side Sample directory:

    cd [path]/Upload
    

    2). Install the dependencies:

    npm install
    

    3). Run the application:

    npm start
    
  3. Modify the client-side upload function In {path}\Sample\src\app\components\tools\dwtService.ts, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

Upload(): Promise<any> {
  return new Promise((res, rej) => {
    if (this._dwtObject && this._dwtObject.HowManyImagesInBuffer > 0) {
      //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
      let strUrl = "http://localhost:2020/Upload";
      let imgAry = [this._dwtObject.CurrentImageIndexInBuffer];
      this._dwtObject.HTTPUpload(
        strUrl, 
        imgAry, 
        Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
        Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
        "WebTWAINImage.png", 
        ()=>{
          res();
        }, (errCode, errString, responseStr) => { 
          rej({
            code: errCode,
            message: errString
          });
        });
     } else {
      rej({
        code: -1,
        message: "There is no image in buffer."
      });
    }
  }
}
  1. Run the client-side project

    Open your terminal or Command Prompt and execute the following three commands to start the project:

    1). Navigate to the Sample directory:

    cd [path]/Sample
    

    2). Install the dependencies:

    npm install
    

    3). Run the application:

    npm start
    
  2. Navigate to http://localhost:4200 in your browser to launch the sample.

This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-React-JavaScript.zip. After unzipping it, the directory structure is shown in the image below. ![react.png](/assets/imgs/react.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite: Please ensure that Node.js is installed. The recommended version is v20.13.1. ### Steps:
  1. Download the server-side Node.js code, unzip it. Under the "Upload" folder, there is a file "server.js". This is the backend page that accepts the uploaded data.

  2. Run the server-side project

    Open your terminal or Command Prompt and execute the following three commands to start the project:

    1). Navigate to the server-side Sample directory:

    cd [path]/Upload
    

    2). Install the dependencies:

    npm install
    

    3). Run the application:

    npm start
    
  3. Modify the client-side upload function In {path}\Sample\src\components\tools\dwtService.js, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

Upload() {
  return new Promise((res, rej) => {
    if (this._dwtObject && this._dwtObject.HowManyImagesInBuffer > 0) {
      //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
      let strUrl = "http://localhost:2020/Upload";
      let imgAry = [this._dwtObject.CurrentImageIndexInBuffer];
      this._dwtObject.HTTPUpload(
        strUrl, 
        imgAry, 
        Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
        Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
        "WebTWAINImage.png", 
        ()=>{
          res();
        }, (errCode, errString, responseStr) => { 
          rej({
            code: errCode,
            message: errString
          });
        });
     } else {
      rej({
        code: -1,
        message: "There is no image in buffer."
      });
    }
  }
}
  1. Run the client-side project

    Open your terminal or Command Prompt and execute the following three commands to start the project:

    1). Navigate to the Sample directory:

    cd [path]/Sample
    

    2). Install the dependencies:

    npm install
    

    3). Run the application:

    npm start
    
  2. Navigate to http://localhost:4200 in your browser to launch the sample.

This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-React-TypeScript.zip. After unzipping it, the directory structure is shown in the image below. ![react-typescript.png](/assets/imgs/react-typescript.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite: Please ensure that Node.js is installed. The recommended version is v20.13.1. ### Steps:
  1. Download the server-side Node.js code, unzip it. Under the "Upload" folder, there is a file "server.js". This is the backend page that accepts the uploaded data.

  2. Run the server-side project

    Open your terminal or Command Prompt and execute the following three commands to start the project:

    1). Navigate to the server-side Sample directory:

    cd [path]/Upload
    

    2). Install the dependencies:

    npm install
    

    3). Run the application:

    npm start
    
  3. Modify the client-side upload function In {path}\Sample\src\components\tools\dwtService.ts, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

Upload(): Promise<any> {
  return new Promise((res, rej) => {
    if (this._dwtObject && this._dwtObject.HowManyImagesInBuffer > 0) {
      //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
      let strUrl = "http://localhost:2020/Upload";
      let imgAry = [this._dwtObject.CurrentImageIndexInBuffer];
      this._dwtObject.HTTPUpload(
        strUrl, 
        imgAry, 
        Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
        Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
        "WebTWAINImage.png", 
        ()=>{
          res();
        }, (errCode, errString, responseStr) => { 
          rej({
            code: errCode,
            message: errString
          });
        });
     } else {
      rej({
        code: -1,
        message: "There is no image in buffer."
      });
    }
  }
}
  1. Run the client-side project

    Open your terminal or Command Prompt and execute the following three commands to start the project:

    1). Navigate to the Sample directory:

    cd [path]/Sample
    

    2). Install the dependencies:

    npm install
    

    3). Run the application:

    npm start
    
  2. Navigate to http://localhost:4200 in your browser to launch the sample.

This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-Vue-JavaScript.zip. After unzipping it, the directory structure is shown in the image below. ![vue.png](/assets/imgs/vue.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite: Please ensure that Node.js is installed. The recommended version is v20.13.1. ### Steps:
  1. Download the server-side Node.js code, unzip it. Under the "Upload" folder, there is a file "server.js". This is the backend page that accepts the uploaded data.

  2. Run the server-side project

    Open your terminal or Command Prompt and execute the following three commands to start the project:

    1). Navigate to the server-side Sample directory:

    cd [path]/Upload
    

    2). Install the dependencies:

    npm install
    

    3). Run the application:

    npm start
    
  3. Modify the client-side upload function In {path}\Sample\src\components\tools\dwtService.js, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

Upload() {
  return new Promise((res, rej) => {
    if (this._dwtObject && this._dwtObject.HowManyImagesInBuffer > 0) {
      //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
      let strUrl = "http://localhost:2020/Upload";
      let imgAry = [this._dwtObject.CurrentImageIndexInBuffer];
      this._dwtObject.HTTPUpload(
        strUrl, 
        imgAry, 
        Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
        Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
        "WebTWAINImage.png", 
        ()=>{
          res();
        }, (errCode, errString, responseStr) => { 
          rej({
            code: errCode,
            message: errString
          });
        });
     } else {
      rej({
        code: -1,
        message: "There is no image in buffer."
      });
    }
  }
}
  1. Run the client-side project

    Open your terminal or Command Prompt and execute the following three commands to start the project:

    1). Navigate to the Sample directory:

    cd [path]/Sample
    

    2). Install the dependencies:

    npm install
    

    3). Run the application:

    npm start
    
  2. Navigate to http://localhost:4200 in your browser to launch the sample.

This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-Vue-TypeScript.zip. After unzipping it, the directory structure is shown in the image below. ![vue-typescript.png](/assets/imgs/vue-typescript.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite: Please ensure that Node.js is installed. The recommended version is v20.13.1. ### Steps:
  1. Download the server-side Node.js code, unzip it. Under the "Upload" folder, there is a file "server.js". This is the backend page that accepts the uploaded data.

  2. Run the server-side project

    Open your terminal or Command Prompt and execute the following three commands to start the project:

    1). Navigate to the server-side Sample directory:

    cd [path]/Upload
    

    2). Install the dependencies:

    npm install
    

    3). Run the application:

    npm start
    
  3. Modify the client-side upload function In {path}\Sample\src\components\tools\dwtService.ts, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

Upload(): Promise<any> {
  return new Promise((res, rej) => {
    if (this._dwtObject && this._dwtObject.HowManyImagesInBuffer > 0) {
      //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
      let strUrl = "http://localhost:2020/Upload";
      let imgAry = [this._dwtObject.CurrentImageIndexInBuffer];
      this._dwtObject.HTTPUpload(
        strUrl, 
        imgAry, 
        Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
        Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
        "WebTWAINImage.png", 
        ()=>{
          res();
        }, (errCode, errString, responseStr) => { 
          rej({
            code: errCode,
            message: errString
          });
        });
     } else {
      rej({
        code: -1,
        message: "There is no image in buffer."
      });
    }
  }
}
  1. Run the client-side project

    Open your terminal or Command Prompt and execute the following three commands to start the project:

    1). Navigate to the Sample directory:

    cd [path]/Sample
    

    2). Install the dependencies:

    npm install
    

    3). Run the application:

    npm start
    
  2. Navigate to http://localhost:4200 in your browser to launch the sample.

### Online Demo

https://demo.dynamsoft.com/web-twain/

--- title: How to deploy your own upload server with PHP? description: How to deploy your own upload server with PHP? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/deploy-your-own-upload-server-with-php.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/deploy-your-own-upload-server-with-php.md --- # Document Saving ## How to Deploy an Upload Server Using PHP Dynamic Web TWAIN is a client-side JavaScript SDK. However, it does need to interact with the server when performing operations like uploading and downloading. This article introduces how to deploy an upload server using backend PHP code.
Please select your frontend language:
- [Javascript](#Javascript) - [Angular](#Angular) - [React-Javascript](#React-Javascript) - [React-TypeScript](#React-TypeScript) - [Vue-Javascript](#Vue-Javascript) - [Vue-Typescript](#Vue-Typescript)
This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-JavaScript.zip. After unzipping it, the directory structure is shown in the image below. ![javascript.png](/assets/imgs/javascript.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite: Please ensure your web server supports PHP. ### Steps:
  1. Download the server-side PHP code, unzip it and copy the aforementioned "Upload" directory to the "Sample" directory. Under the "Upload" root folder, there is a file "SaveToFile.php". This is the backend page that accepts the uploaded data.

  2. Modify the client-side upload function In {path}\Sample\Scripts\online_demo_operation.js, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

function Upload() {
  if (DWTObject && DWTObject.HowManyImagesInBuffer > 0) {
    //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
    var strUrl = "http://{server-path}/Sample/Upload/SaveToFile.php";
    var imgAry = [DWTObject.CurrentImageIndexInBuffer];
    DWTObject.HTTPUpload(
      strUrl, 
      imgAry, 
      Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
      Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
      "WebTWAINImage.png", 
      onUploadSuccess, 
      onUploadFailure);
  } else {
    alert("There is no image in buffer.");
  }
}

function onUploadSuccess() {
  alert("Upload successful");
}

function onUploadFailure(errorCode, errorString, sHttpResponse) {
  alert(sHttpResponse.length > 0 ? sHttpResponse : errorString);
}
  1. Copy the "Sample" directory to the web server.

  2. Navigate to http://{server-path}/Sample/index.html in your browser to access the sample.

This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-Angular.zip. After unzipping it, the directory structure is shown in the image below. ![angular.png](/assets/imgs/angular.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite:
  1. Please ensure that Node.js is installed. The recommended version is v20.13.1.

  2. Please ensure your web server supports PHP.

### Steps:
  1. Download the server-side PHP code, unzip it and copy the "Upload" directory to the "Sample\src\public" directory. Under the "Upload" folder, there is a file "SaveToFile.php". This is the backend page that accepts the uploaded data.

  2. Modify the client-side upload function In {path}\Sample\src\app\components\tools\dwtService.ts, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

Upload(): Promise<any> {
  return new Promise((res, rej) => {
    if (this._dwtObject && this._dwtObject.HowManyImagesInBuffer > 0) {
      //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
      let strUrl = "http://{server-path}/dist/Upload/SaveToFile.php";
      let imgAry = [this._dwtObject.CurrentImageIndexInBuffer];
      this._dwtObject.HTTPUpload(
        strUrl, 
        imgAry, 
        Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
        Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
        "WebTWAINImage.png", 
        ()=>{
          res();
        }, (errCode, errString, responseStr) => { 
          rej({
            code: errCode,
            message: errString
          });
        });
     } else {
      rej({
        code: -1,
        message: "There is no image in buffer."
      });
    }
  }
}
  1. Build the client-side project

    Open your terminal or Command Prompt and execute the following three commands to build the project:

    1). Navigate to the Sample directory:

    cd [path]/Sample
    

    2). Install the dependencies:

    npm install
    

    3). Build the project:

    npm run build
    
  2. Copy the "Sample/dist" directory to the web server.

  3. Navigate to http://{server-path}/dist/index.html in your browser to access the sample.

This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-React-JavaScript.zip. After unzipping it, the directory structure is shown in the image below. ![react.png](/assets/imgs/react.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite:
  1. Please ensure that Node.js is installed. The recommended version is v20.13.1.

  2. Please ensure your web server supports PHP.

### Steps:
  1. Download the server-side PHP code, unzip it and copy the "Upload" directory to the "Sample\public" directory. Under the "Upload" folder, there is a file "SaveToFile.php". This is the backend page that accepts the uploaded data.

  2. Modify the client-side upload function In {path}\Sample\src\components\tools\dwtService.js, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

Upload() {
  return new Promise((res, rej) => {
    if (this._dwtObject && this._dwtObject.HowManyImagesInBuffer > 0) {
      //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
      let strUrl = "http://{server-path}/dist/Upload/SaveToFile.php";
      let imgAry = [this._dwtObject.CurrentImageIndexInBuffer];
      this._dwtObject.HTTPUpload(
        strUrl, 
        imgAry, 
        Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
        Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
        "WebTWAINImage.png", 
        ()=>{
          res();
        }, (errCode, errString, responseStr) => { 
          rej({
             code: errCode,
             message: errString
          });
        });
     } else {
      rej({
         code: -1,
         message: "There is no image in buffer."
      });
    }
  }
}
  1. Build the client-side project

    Open your terminal or Command Prompt and execute the following three commands to build the project:

    1). Navigate to the Sample directory:

    cd [path]/Sample
    

    2). Install the dependencies:

    npm install
    

    3). Build the project:

    npm run build
    
  2. Copy the "Sample/dist" directory to the web server.

  3. Navigate to http://{server-path}/dist/index.html in your browser to access the sample.

This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-React-TypeScript.zip. After unzipping it, the directory structure is shown in the image below. ![react-typescript.png](/assets/imgs/react-typescript.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite:
  1. Please ensure that Node.js is installed. The recommended version is v20.13.1.

  2. Please ensure your web server supports PHP.

### Steps:
  1. Download the server-side PHP code, unzip it and copy the "Upload" directory to the "Sample\public" directory. Under the "Upload" folder, there is a file "SaveToFile.php". This is the backend page that accepts the uploaded data.

  2. Modify the client-side upload function In {path}\Sample\src\components\tools\dwtService.ts, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

Upload(): Promise<any> {
  return new Promise((res, rej) => {
    if (this._dwtObject && this._dwtObject.HowManyImagesInBuffer > 0) {
      //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
      let strUrl = "http://{server-path}/dist/Upload/SaveToFile.php";
      let imgAry = [this._dwtObject.CurrentImageIndexInBuffer];
      this._dwtObject.HTTPUpload(
        strUrl, 
        imgAry, 
        Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
        Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
        "WebTWAINImage.png", 
        ()=>{
          res();
        }, (errCode, errString, responseStr) => { 
          rej({
            code: errCode,
            message: errString
          });
        });
     } else {
      rej({
        code: -1,
        message: "There is no image in buffer."
      });
    }
  }
}
  1. Build the client-side project

    Open your terminal or Command Prompt and execute the following three commands to build the project:

    1). Navigate to the Sample directory:

    cd [path]/Sample
    

    2). Install the dependencies:

    npm install
    

    3). Build the project:

    npm run build
    
  2. Copy the "Sample/dist" directory to the web server.

  3. Navigate to http://{server-path}/dist/index.html in your browser to access the sample.

This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-Vue-JavaScript.zip. After unzipping it, the directory structure is shown in the image below. ![vue.png](/assets/imgs/vue.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite:
  1. Please ensure that Node.js is installed. The recommended version is v20.13.1.

  2. Please ensure your web server supports PHP.

### Steps:
  1. Download the server-side PHP code, unzip it and copy the "Upload" directory to the "Sample\public" directory. Under the "Upload" folder, there is a file "SaveToFile.php". This is the backend page that accepts the uploaded data.

  2. Modify the client-side upload function In {path}\Sample\src\components\tools\dwtService.js, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

Upload() {
  return new Promise((res, rej) => {
    if (this._dwtObject && this._dwtObject.HowManyImagesInBuffer > 0) {
      //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
      let strUrl = "http://{server-path}/dist/Upload/SaveToFile.php";
      let imgAry = [this._dwtObject.CurrentImageIndexInBuffer];
      this._dwtObject.HTTPUpload(
        strUrl, 
        imgAry, 
        Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
        Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
        "WebTWAINImage.png", 
        ()=>{
          res();
        }, (errCode, errString, responseStr) => { 
          rej({
            code: errCode,
            message: errString
          });
        });
     } else {
      rej({
        code: -1,
        message: "There is no image in buffer."
      });
    }
  }
}
  1. Build the client-side project

    Open your terminal or Command Prompt and execute the following three commands to build the project:

    1). Navigate to the Sample directory:

    cd [path]/Sample
    

    2). Install the dependencies:

    npm install
    

    3). Build the project:

    npm run build
    
  2. Copy the "Sample/dist" directory to the web server.

  3. Navigate to http://{server-path}/dist/index.html in your browser to access the sample.

This article assumes that you have downloaded and unzipped this sample: DynamicWebTWAIN-Vue-TypeScript.zip. After unzipping it, the directory structure is shown in the image below. ![vue-typescript.png](/assets/imgs/vue-typescript.png)

Note: The "Sample" directory mentioned in the steps below refers to the "Sample" directory shown in the image.

### Prerequisite:
  1. Please ensure that Node.js is installed. The recommended version is v20.13.1.

  2. Please ensure your web server supports PHP.

### Steps:
  1. Download the server-side PHP code, unzip it and copy the "Upload" directory to the "Sample\public" directory. Under the "Upload" folder, there is a file "SaveToFile.php". This is the backend page that accepts the uploaded data.

  2. Modify the client-side upload function In {path}\Sample\src\components\tools\dwtService.ts, modify the "URL" parameter of HTTPUpload() to match the actual path of the upload server you deployed. The "URL" parameter accepts both absolute and relative paths.

    Refer to the following code snippet:

Upload(): Promise<any> {
  return new Promise((res, rej) => {
    if (this._dwtObject && this._dwtObject.HowManyImagesInBuffer > 0) {
      //Path to the server-side script. You can adjust it according to the actual path of the upload server you deployed.
      let strUrl = "http://{server-path}/dist/Upload/SaveToFile.php";
      let imgAry = [this._dwtObject.CurrentImageIndexInBuffer];
      this._dwtObject.HTTPUpload(
        strUrl, 
        imgAry, 
        Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG,
        Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
        "WebTWAINImage.png", 
        ()=>{
          res();
        }, (errCode, errString, responseStr) => { 
          rej({
            code: errCode,
            message: errString
          });
        });
     } else {
      rej({
        code: -1,
        message: "There is no image in buffer."
      });
    }
  }
}
  1. Build the client-side project

    Open your terminal or Command Prompt and execute the following three commands to build the project:

    1). Navigate to the Sample directory:

    cd [path]/Sample
    

    2). Install the dependencies:

    npm install
    

    3). Build the project:

    npm run build
    
  2. Copy the "Sample/dist" directory to the web server.

  3. Navigate to http://{server-path}/dist/index.html in your browser to access the sample.

### Online Demo

https://demo.dynamsoft.com/web-twain/

--- title: Dynamic Web TWAIN with Annotations description: Dynamic Web TWAIN with Annotations – Hello World source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/dwt-with-annotation.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/dwt-with-annotation.md --- # Dynamic Web TWAIN with Annotations – Hello World Dynamsoft's **Dynamic Web TWAIN (DWT)** is a software development kit (SDK) designed to integrate efficient document scanning workflows into web applications. **Dynamsoft Document Viewer (DDV)** is a versatile web document viewer with support for document annotations. In this guide, we explain how to **use DDV in place of DWT's built-in viewer** to enable **annotations** and provide a superior viewer experience. In this sample, we create a **headless** DWT instance to scan images, and then pass the result to DDV to view, edit, annotate, etc. We then use DWT to save the result - **along with any edits and annotations** - to a file, or upload to the server. ![Flow chart for Dynamic Web TWAIN with Annotations – Hello World](/assets/imgs/dwt-with-ddv.jpg) - Check out [HelloWorld](https://demo.dynamsoft.com/Samples/dwt/web-twian-document-viewer/index.html) online ## 1. Add Dependencies Use the SDK by including the packages below: - Dynamic Web TWAIN: provides scanning, saving, and uploading functionalities. - Dynamsoft Document Viewer: provides improved document viewer and annotation functionalities. ### 1.1 Deliver Dependencies via CDN Deliver the SDK dependencies with either the [jsDelivr](https://jsdelivr.com/) or the [UNPKG](https://unpkg.com/) CDN. - jsDelivr ```html ``` - UNPKG ```html ``` ## 2. Define HTML Elements Define the following elements: - A container to hold the viewer ```html
``` - Buttons to invoke functions ```html ``` ## 3. Initialize the SDK ### 3.1 Initialize Dynamsoft Document Viewer ```javascript // Dynamsoft Document Viewer // Public trial license which is valid for 24 hours // You can request a 30-day trial key from https://www.dynamsoft.com/customer/license/trialLicense/?product=dwtddv Dynamsoft.DDV.Core.license = "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9"; Dynamsoft.DDV.Core.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-document-viewer@3.0.0/dist/engine"; await Dynamsoft.DDV.Core.init(); ``` ### 3.2 Create the Edit Viewer ```javascript // Create a Dynamsoft Document Viewer Edit Viewer to display and edit documents scanned with Dynamic Web TWAIN let editViewer; editViewer = new Dynamsoft.DDV.EditViewer({ container: "container", }); // Create a Dynamsoft Document Viewer document to contain and display images scanned by Dynamic Web TWAIN let ddvDoc; ddvDoc = Dynamsoft.DDV.documentManager.createDocument({ name: "ddvtestDoc" }); // Open the document editViewer.openDocument(ddvDoc.uid); ``` Links to related documentation: - [`How to configure image filter`](https://www.dynamsoft.com/document-viewer/docs/features/advanced/imagefilter.html) - [`Edit Viewer`](https://www.dynamsoft.com/document-viewer/docs/features/viewers/editviewer.html) - [`How to configure your desired uiconfig`](https://www.dynamsoft.com/document-viewer/docs/ui/customize/index.html) API Reference - Dynamsoft Document Viewer: - [`Dynamsoft.DDV.EditViewer`](https://www.dynamsoft.com/document-viewer/docs/api/class/editviewer.html#editviewer) - [`createDocument()`](https://www.dynamsoft.com/document-viewer/docs/api/class/documentmanager.html#createdocument) - [`openDocument()`](https://www.dynamsoft.com/document-viewer/docs/api/class/editviewer.html#opendocument) ### 3.3 Create a Viewerless Dynamic Web TWAIN Instance Reference a CDN like `jsDelivr` to fetch most resources using `Dynamsoft.DWT.ResourcesPath`. Notably these resources exclude DWT Service installers, which exceed the `jsDelivr` CDN per-file size limit. You have a few options to set this path with `Dynamsoft.DWT.ServiceInstallerLocation`: 1. [Install the DWT SDK](https://www.dynamsoft.com/web-twain/downloads/), extract the DWT service installers (under path like `C:\Program Files (x86)\Dynamsoft\Dynamic Web TWAIN SDK 19.2\Resources\dist`), then self-host the DWT Service installers with `Dynamsoft.DWT.ServiceInstallerLocation = "https://example.com/DWT/Resources/dist"`. 2. Use a different CDN with a higher per-file size limit by referencing the location with `Dynamsoft.DWT.ServiceInstallerLocation = "https://unpkg.com/dwt@19.4.1/dist/dist"`. ```javascript // Create Dynamic Web TWAIN object // Public trial license which is valid for 24 hours // You can request a 30-day trial key from https://www.dynamsoft.com/customer/license/trialLicense/?product=dwtddv Dynamsoft.DWT.ProductKey = "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9"; Dynamsoft.DWT.UseDefaultViewer = false; Dynamsoft.DWT.ResourcesPath = "https://cdn.jsdelivr.net/npm/dwt@19.4.1/dist"; // Do not forget to set your installer path Dynamsoft.DWT.ServiceInstallerLocation = "YOUR_INSTALLER_PATH_HERE"; let DWObject; // Create a Dynamic Web TWAIN instance without the built-in viewer Dynamsoft.DWT.CreateDWTObjectEx({ WebTwainId: "dwtId", },function (object) { DWObject = object; }, function (error) { console.log(error); } ); ``` API Reference - Dynamic Web TWAIN: - [`CreateDWTObjectEx()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#createdwtobjectex) ## 4. Use SDK Features ### 4.1 Add Simple Scanning Functionality Use the Dynamic Web TWAIN instance for scanning. Upon scan completion, import the scanned data into DDV for viewing, editing, and annotating. #### 4.1.1 Register the `OnPostTransferAsync` Event ```javascript //Register the OnPostTransferAsync event in the success callback function of CreateDWTObjectEx. Dynamsoft.DWT.CreateDWTObjectEx({ WebTwainId: "dwtId", }, function (object) { DWObject = object; // Call Dynamsoft_OnPostTransferAsync upon completion of every individual page scan DWObject.RegisterEvent("OnPostTransferAsync", Dynamsoft_OnPostTransferAsync); }, function (error) { console.log(error); } ); // Import scanned page into Dynamsoft Document Viewer to display function Dynamsoft_OnPostTransferAsync(outputInfo){ if(DWObject) { let index = DWObject.ImageIDToIndex(outputInfo.imageId); DWObject.ConvertToBlob( [index], Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG, function(blob){ ddvDoc.loadSource(blob); }, function(ec,es){ console.log(es); } ); } } ``` API Reference - Dynamic Web TWAIN: - [`OnPostTransferAsync`](/_articles/info/api/WebTwain_Acquire.md#onposttransferasync) - [`ImageIDToIndex()`](/_articles/info/api/WebTwain_Buffer.md#imageidtoindex) - [`ConvertToBlob()`](/_articles/info/api/WebTwain_IO.md#converttoblob) - Dynamsoft Document Viewer: - [`loadSource()`](https://www.dynamsoft.com/document-viewer/docs/api/interface/idocument/index.html#loadsource) #### 4.1.2 Use Dynamic Web TWAIN to Scan from Document Scanners ```javascript function AcquireImage() { if (DWObject) { DWObject.SelectSourceAsync().then(function () { return DWObject.AcquireImageAsync({ IfCloseSourceAfterAcquire: true }); }).catch(function (exp) { alert(exp.message); }); } } ``` API Reference - Dynamic Web TWAIN: - [`SelectSourceAsync()`](/_articles/info/api/WebTwain_Acquire.md#selectsourceasync) - [`AcquireImageAsync()`](/_articles/info/api/WebTwain_Acquire.md#acquireimageasync) ### 4.2 Add PDF Saving to Local Functionality Use `saveToPdf()` from **DDV** to convert the scanned document to a PDF Blob, then use `saveBlob` from **DWT** to export the document to local as a PDF. ```javascript const pdfSettings = { saveAnnotation: "annotation" }; function SavePDF(){ editViewer.currentDocument.saveToPdf(pdfSettings).then(function(blob){ DWObject.IfShowFileDialog = true; DWObject.saveBlob("WebTWAINImage.pdf", blob).then(function () { console.log("OK"); }).catch(function (err) { console.log(err); }); }); } ``` API Reference - Dynamic Web TWAIN: - [`IfShowFileDialog`](/_articles/info/api/WebTwain_IO.md#ifshowfiledialog) - [`saveBlob()`](/_articles/info/api/WebTwain_IO.md#saveblob) - Dynamsoft Document Viewer: - [`saveToPdf()`](https://www.dynamsoft.com/document-viewer/docs/api/interface/idocument/index.html#savetopdf) ### 4.3 Add Server Upload Functionality Use the `saveToPdf()` API from **DDV** to convert the scanned document to a PDF Blob, then use the `httpUploadBlob()` API from **DWT** to upload the document to the server as a PDF. ```javascript // Can be discarded if already defined previously const pdfSettings = { saveAnnotation: "annotation" }; function Upload(){ editViewer.currentDocument.saveToPdf(pdfSettings).then(function(blob){ let fileName = "WebTWAINImage.pdf"; DWObject.httpUploadBlob( "https://demo.dynamsoft.com/sample-uploads/", blob, fileName ).then(function () { console.log("Upload successful."); }).catch(function (err) { console.log(err); }); }); } ``` Links to related documentation: - [`Uploading Images to the Server`](https://www.dynamsoft.com/web-twain/docs/getstarted/uploading.html) API Reference - Dynamic Web TWAIN: - [`httpUploadBlob()`](/_articles/info/api/WebTwain_IO.md#httpuploadblob) - Dynamsoft Document Viewer: - [`saveToPdf()`](https://www.dynamsoft.com/document-viewer/docs/api/interface/idocument/index.html#savetopdf) ## Review the Complete Code ```html HelloWorld
``` ## Run the Web Application ![Flow chart for Dynamic Web TWAIN with Annotations – Hello World](/assets/imgs/dwt-ddv-helloworld.png) ## Further Reading - [`Use the API to edit images within the control`](https://www.dynamsoft.com/document-viewer/docs/features/viewers/editviewer.html#edit-pages) - [`Use the API to delete or switch images within the control`](https://www.dynamsoft.com/document-viewer/docs/api/interface/idocument/index.html#members)
--- title: How to debug on Dynamic Web TWAIN online demo? description: How to debug on Dynamic Web TWAIN online demo? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/debug-on-online-demo.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/debug-on-online-demo.md --- # Error Troubleshooting ## How to debug on Dynamic Web TWAIN online demo? With the widespread application of the Dynamic Web TWAIN SDK in the market, more and more developers need an effective way to debug. Dynamsoft provides an official demo that enables developers to verify online whether their scanners and code can function properly. This article introduces how to utilize the browser developer tools to test the code through the Dynamic Web TWAIN online demo. **Step 1:** Visit Dynamic Web TWAIN Online Demo: [https://demo.dynamsoft.com/web-twain/](https://demo.dynamsoft.com/web-twain/) **Step 2:** Given that the demo is presented via the iframe element, to acquire the WebTwain instance, you need to make the following configurations. ![image1](/assets/imgs/debug_on_online_demo.png) As an alternative, you can straightforwardly call the `top[0].DWTObject`. **Step 3:** You've now obtained the WebTwain instance. ![image2](/assets/imgs/get_dwtobject_instance.png) And you can test the API as much as you want. Let's take the [ConvertToBase64](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_IO.html#converttobase64) as an example. After you input the code into the console and press Enter to run this code snippet, it will convert the image at index 0 in the buffer (that is, the first image) into a Base64 string. ![image3](/assets/imgs/console_code_test.png) Now that you've had the opportunity to preview how the DWT API operates in the web application, you can explore more features by reviewing the [API documentation]({{site.info}}api/). --- title: Where can I download the Dynamic Web TWAIN Service installers only? description: Where can I download the Dynamic Web TWAIN Service installers only? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/download-service-only.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/download-service-only.md --- View all FAQs about [Project Deployment and End-user Installation]( https://www.dynamsoft.com/web-twain/docs/faq/#project-deployment-and-end-user-installation) # Where can I download the Dynamic Web TWAIN Service installers only? Typically, we recommend that developers retrieve the Dynamic Web TWAIN Service Installers from the downloaded SDK package. This approach guarantees that the version of the Dynamic Web TWAIN Service installed by the user aligns with the current version of the SDK libraries. Let's use Windows as an illustration. After installing the SDK package, you can locate all Dynamic Web TWAIN Service installers for various operating systems in the directory "C:\Program Files (x86)\Dynamsoft\Dynamic Web TWAIN SDK {version number}\Resources\dist".[[Download the SDK](https://www.dynamsoft.com/web-twain/downloads/)] However, considering that more and more enterprise users are using the Dynamic Web TWAIN SDK, it would be a hassle for end users to obtain the Dynamic Web TWAIN Service installer by downloading the SDK if they are unable to acquire the installers from the developer for some reasons. Therefore, you can use the following trick to download the desired Service installers.
- Download via CDN - Download via GitHub
**Step 1:** Visit the CDN site: [https://www.unpkg.com/browse/dwt/dist/dist/](https://www.unpkg.com/browse/dwt/dist/dist/). **Step 2:** For Windows users, please choose ".msi" installer For Mac users, please choose ".pkg" installer For Linux users, please choose ".rpm" or ".deb" installer accordingly ![download_installer](/assets/imgs/download_msi_from_cdn.png) **Step 3:** Click on the "View Raw" button, it will start to download the installer. ![download_raw](/assets/imgs/download_view_raw.png)
**Step 1:** Visit the GitHub site: [https://github.com/Dynamsoft/Dynamic-Web-TWAIN/releases](https://github.com/Dynamsoft/Dynamic-Web-TWAIN/releases). **Step 2:** Scroll down to the **Assets** section. - For Windows, download the **.msi** installer. - For macOS, download the **.pkg** installer. - For Linux, download either the **.rpm** or **.deb** installer, depending on your distribution. ![download_installer](/assets/imgs/download_admin_installer_github.png) > [!IMPORTANT] > If you don't have **administrator privileges** to install the service, you can use our Personal Installer, which can be installed without admin rights.![download_personal_installer](/assets/imgs/download_personal_installer_github.png)
--- title: Can I change the resolution/DPI of an image in the viewer? description: Can I change the resolution/DPI of an image in the viewer? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/change-resolution-of-image.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/change-resolution-of-image.md --- # Image Editing ## Can I change the resolution/DPI of an image in the viewer? You can use the [Resolution](/_articles/info/api/WebTwain_Acquire.md#resolution){:target="_blank"} property to check the resolution while acquiring an image. To change the resolution/DPI in the viewer, you can use the following methods: [DWTObject.SetDPI()](/_articles/info/api/WebTwain_Edit.md#setdpi){:target="_blank"} // Changes the DPI (dots per inch) of the specified image depending on the input resolution parameters --- title: Can I hide the Dynamsoft image viewer and use my own image viewer? description: Can I hide the Dynamsoft image viewer and use my own image viewer? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/hide-image-viewer.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/hide-image-viewer.md --- # Image Viewer ## Can I hide the Dynamsoft image viewer and use my own image viewer? If you want to use your own viewer, you can use [`Dynamsoft.DWT.CreateDWTObjectEx()`](/_articles/extended-usage/advanced-initialization.md#creating-headless-webtwain-instances) to create a `WebTwain` instance that does not come with a viewer. You can also unbind and destroy the viewer of an existing `WebTwain` instance with the [`unbind()`](/_articles/info/api/WebTwain_Viewer.md#unbind) API.
> Prior to using CreateDWTObjectEx(), please disable the [AutoLoad](/_articles/info/api/Dynamsoft_WebTwainEnv.md#autoload) feature. Additionally, avoid calling any [Load](/_articles/info/api/Dynamsoft_WebTwainEnv.md#load) methods either before or after using CreateDWTObjectEx(). This ensures proper functionality and prevents potential conflicts during the initialization.
--- title: Where is the image viewer object defined? description: Where is the image viewer object defined? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/image-viewer-object-defined.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/image-viewer-object-defined.md --- # Image Viewer ## Where is the image viewer object defined? By default, Dynamic Web TWAIN has a viewer component that helps to view data available in the buffer. When you [create an instance of Web Twain](/_articles/extended-usage/advanced-initialization.md#instantiating-webtwain-without-onwebtwainready){:target="_blank"}, the viewer is created automatically with its default available settings. You can customize the viewer settings according to your requirements and replace the default viewer with your customized viewer settings. You can refer to this [link](/_articles/general-usage/viewer-configuration.md#create-the-viewer){:target="_blank"} to read in details about the steps to create/modify the viewer. --- title: Dynamic Web TWAIN prompts the .deb installer for Windows description: Dynamic Web TWAIN prompts the .deb installer for Windows source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/incorrect-installer-for-windowsARM64.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/incorrect-installer-for-windowsARM64.md --- # Error Troubleshooting ## Dynamic Web TWAIN prompts the .deb installer for Windows ### Symptom You may encounter an issue where, on a Windows operating system with ARM64 architecture, you are prompted to download the .deb installer, which is intended for use on Linux operating systems. ### Resolution The issue was patched in version 17.3.1. We highly recommend upgrading your SDK to version 17.3.1 or higher. Otherwise, you will need to manually install the .MSI installer. --- title: How can I save selected images instead of all images to my server or database? description: How can I save selected images instead of all images to my server or database? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/save-selected-images-to-server.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/save-selected-images-to-server.md --- # Document Saving ## How can I save selected images instead of all images to my server or database? The API [SelectedImagesIndices](/_articles/info/api/WebTwain_Buffer.md#selectedimagesindices){:target="_blank"} returns the indices of the selected images. You can pass those indices as a parameter to [HTTPUpload](/_articles/info/api/WebTwain_IO.md#httpupload){:target="_blank"} which uploads files to the server/database. To upload all images in the buffer with HTTPUpload, you can use the API [SelectAllImages](/_articles/info/api/WebTwain_Buffer.md#selectallimages){:target="_blank"} which returns the indices of all images. There are other HTTP upload APIs that can achieve the same. Please refer to this link: [Dynamic Web TWAIN API Reference - IO APIs](/_articles/info/api/WebTwain_IO.md#output){:target="_blank"} --- title: How can I show page number on each image? description: How can I show page number on each image? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/show-page-number.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/show-page-number.md --- # Image Viewer ## How can I show page number on each image? You can set the [showPageNumber](/_articles/info/api/WebTwain_Viewer.md#showpagenumber){:target="_blank"} API to true to show the page number. ```javascript DWTObject.Viewer.showPageNumber = true; ``` **Note**: When [setViewMode](/_articles/info/api/WebTwain_Viewer.md#setviewmode){:target="_blank"} is set to -1 by -1 or [singlePageMode](/_articles/info/api/WebTwain_Viewer.md#singlepagemode){:target="_blank"} is true then this api will not work. --- title: Why am I unable to load the TIFF file into Dynamic Web TWAIN? description: Why am I unable to load the TIFF file into Dynamic Web TWAIN? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/unable-to-load-4-bit-tiff.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/unable-to-load-4-bit-tiff.md --- # Error Troubleshooting ## Why am I unable to load the TIFF file into Dynamic Web TWAIN? ### Symptom When you attempt to import a TIFF file using Dynamic Web TWAIN, it will indicate that the file has been successfully loaded, but the image does not appear in the viewer. ### Cause All versions prior to version 19.0 do not support importing 4-bit color images. If you encounter the issue mentioned above, your file may be using the deprecated JPEG compression standard. ### Resolution Support for 4-bit TIFF format was added in version 19.1. Therefore, please update to version 19.1 to resolve this issue. > If the resolution doesn't work for you, please [contact us](https://www.dynamsoft.com/company/contact/). --- title: How to scan documents on mobile devices? description: How to scan documents on mobile devices? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/how-to-scan-documents-on-mobile-devices.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/how-to-scan-documents-on-mobile-devices.md --- # Capture/Image Source ## How to scan documents on mobile devices? > If you are looking to capture documents using mobile cameras, please see FAQ: [Do you support capturing documents from mobile cameras?](/_articles/faq/support-capture-from-mobile-camera.md) The Dynamic Web TWAIN has introduced a [Remote Scan](https://www.dynamsoft.com/remote-scan/docs/introduction/) feature starting from version [18.2](/_articles/info/schedule/Stable.md#remote-scan-1). It allows end users to access scanners of various protocols (TWAIN, SANE, ICA, eSCL, WIA) on the Intranet through any devices and any popular browsers, without any extra software installed. --- title: Error message - Permission was denied for this request to access the unknown address space description: CORS unknown address space source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/chromium-142-local-network-access-issue.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/chromium-142-local-network-access-issue.md --- # Error Troubleshooting > [!IMPORTANT] > This is an evolving browser behavior. Details in this article may change as Chromium updates Local Network Access. ## Error message - CORS errors caused by local network access permissions in Chromium 142 and later ### Overview Local Network Access (LNA) is a browser security model that has been enforced in Chromium-based browsers since version 142 (released October 28, 2025), including Chrome, Edge, Brave, and Opera. It blocks web apps from reaching local or loopback targets unless the user explicitly grants permission, which can affect Dynamic Web TWAIN Service behavior. These restrictions limit requests from **public network locations** to **local or loopback locations** unless the required site permission is granted. Starting in **Chrome 145**, the site-setting label changed from one local network access permission to two: - `loopback-network` shown as **Apps on device** - `local-network` shown as **Local Network** Dynamic Web TWAIN Service communicates with `localhost` / `127.0.0.1`, so **Apps on device** (`loopback-network`) is the key permission for most deployments. When your page first requests local access, Chromium will show an LNA permission prompt. This FAQ and the symptoms below apply when users dismiss this prompt or click **Block**. ![LNA prompt](/assets/imgs/local-network-access/LNA-prompt.png) ### Symptoms If the initial LNA prompt is dismissed or blocked, you may experience one or more of the following: #### **1) Browser repeatedly prompts to download the service** The browser asks the user to download/install the Dynamic Web TWAIN Service even though it is already installed. ![DWT_installer.png](/assets/imgs/DWT_installer.png) #### **2) Initialization succeeds, but scanning / loading returns blank** Initialization appears successful, but scanned or loaded images are blank. The browser console (`F12` -> `Console`) may show a CORS denial similar to: ```shell Access to fetch at 'https://127.0.0.1:18623/fa/VersionInfo?ts=1761893667670' from origin 'https://your-domain.com' has been blocked by CORS policy: Permission was denied for this request to access the `unknown` address space. ``` This happens because a page on a public origin (for example, `https://your-domain.com`) is trying to access a loopback address (`127.0.0.1`), which Chromium now treats as a protected local-network request. --- #### Version-Specific Behavior Observed behavior depends on Chromium version and Dynamic Web TWAIN (DWT) version: | Browser Version | DWT Version | Resulting Symptom | |------------------|-------------|-----------------------------| | Chromium 142+ | < 18.5.0 | Service Installation Prompt | | Chromium 142+ | >= 18.5.0, < 19.3 | Blank Images after Scanning | | Chromium 142+ | >= 19.3 | Permission Prompt | | Chromium future version blocking WebSocket(*) | Any | Service Installation Prompt | > [!NOTE] > (*) Blocking WebSocket requests is on Chromium's roadmap, and may be enforced in a future release. > Other browsers are also introducing local network permission controls. ### Root Cause Chromium 142 introduced [Local Network Access (LNA)](https://chromestatus.com/feature/5152728072060928), which restricts requests from public network locations to local/loopback network locations unless permission is granted. > [!NOTE] > For background and design rationale, see Chrome's developer blog: [New permission prompt for Local Network Access](https://developer.chrome.com/blog/local-network-access). Under this model, requests from a public origin (a publicly hosted site) to local or loopback targets (including `localhost` and `127.0.0.1`) can be blocked by default. Dynamic Web TWAIN relies on a locally installed service that listens on a loopback address. If browser permission is not granted, communication with that local service fails. ### Resolution > [!WARNING] > This is driven by browser security policy decisions. Dynamic Web TWAIN cannot bypass these restrictions programmatically. > Browser behavior will continue evolving, and temporary workarounds may be removed in future versions. You should plan your deployment and UX flow around current browser permission requirements. ***1. To manually correct this in Chrome*** - Navigate to your Dynamic Web TWAIN page. - Click the lock/settings icon in the browser address bar. - In **Chrome 142-144**, ensure **Local Network Access** (`local-network-access`) is `Allow`. - In **Chrome 145+**, check: - **Apps on device** (`loopback-network`) is `Allow` (required for `localhost` / `127.0.0.1`) - **Local Network** (`local-network`) is `Allow` only if your app also needs private-network device access ![local-network.png](/assets/imgs/local-network-access/local-network.png) > [!NOTE] > Chrome updates permission popup UI frequently. Starting with Dynamic Web TWAIN **v19.3.1**, static screenshots were removed from built-in popups. > For the latest browser-specific screenshots, see: > [https://dynamsoft.github.io/Dynamic-Web-TWAIN/local-network-access.html](https://dynamsoft.github.io/Dynamic-Web-TWAIN/local-network-access.html) ***2. (For Admins) Apply this setting across an enterprise*** Enterprise administrators can deploy Chrome and/or Edge policies to set local-network permission to `Allow` for your website. Please refer to: - [Chrome Enterprise Policy List and Management Documentation](https://chromeenterprise.google/policies/#LocalNetworkAccessAllowedForUrls) - [Microsoft Edge Browser Policy Documentation](https://learn.microsoft.com/en-us/deployedge/microsoft-edge-browser-policies/localnetworkaccessallowedforurls) ***3. Developer Notes*** **a) If running inside an `iframe`** > [!IMPORTANT] > If Dynamic Web TWAIN runs inside a cross-origin iframe, `loopback-network` permissions must be explicitly allowed in the iframe `allow` attribute. > If the iframe is same-origin, no additional iframe permission configuration is required. For Chrome 145+, use `loopback-network` (and `local-network` only if needed). For older versions, include `local-network-access`. ```html ``` **b) (Optional enhancement) Permission check for improved UX** You can optionally query LNA permissions at runtime. This is not required, but it can help you guide users before initialization fails. ```javascript // Helper: query the first supported permission name from a list. async function queryFirstSupportedPermission(names) { for (const name of names) { try { const result = await navigator.permissions.query({ name }); return { name, state: result.state }; } catch (_) { // Not supported in this browser version. } } return null; } (async () => { // Chrome 145+: loopback-network; Chrome 142-144: local-network-access. const loopbackPerm = await queryFirstSupportedPermission([ "loopback-network", "local-network-access" ]); if (!loopbackPerm) { console.log("This browser does not expose the Local Network permission API."); // Fallback: initialize DWT directly. return; } console.log(`Loopback permission (${loopbackPerm.name}): ${loopbackPerm.state}`); if (loopbackPerm.state === "denied") { const currentSite = encodeURIComponent(window.location.origin); const settingsUrl = `chrome://settings/content/siteDetails?site=${currentSite}`; console.log( "Local network permission is denied.\n" + `Open: ${settingsUrl}\n` + "Then allow Local Network for this site." ); return; } if (loopbackPerm.state === "prompt") { alert( "To connect with the local scanning service, Chrome may ask for Local Network permission. " + "Please click Allow when prompted." ); } // Proceed with DWT initialization. // e.g., Dynamsoft.DWT.Load() or CreateDWTObjectEx(...) })(); ``` If permission is not granted, direct users to: > Chrome -> Settings -> Privacy and security -> Site settings -> Local Network / Apps on device ### Product Improvements Related to Local Network Access Starting from v19.3, Dynamic Web TWAIN now includes UX enhancements to better surface local-service connectivity and permission issues. These changes do not alter or bypass Chromium's security model. They make permission-related failures easier to identify and guide users to the correct browser settings. The key improvements include: - **Guide the user to grant local network access** If the service is installed (detected with WebSocket) and the access to the local service is not through or the detected permission is "prompt", prompt the user to grant access. *Dialog 1 - Permission Granting Guidance* ![permission granting dialog](/assets/imgs/local-network-access/permission-granting-dialog.png) - **Explicit detection of blocked local network access** If the permission can be detected and is "denied", a clear dialog explains the cause and directs users to a guide, which tells how to enable the permission in site settings. ![prompt blocked](/assets/imgs/local-network-access/prompt-blocked.png) *Dialog 2 - Site Settings Guidance* - **Clearer messaging during service installation** The service installation dialog explains that connection failure may be caused either by missing service installation or denied local-network permission. ![dialog installation](/assets/imgs/local-network-access/service-installation-dialog.png) *Dialog 3 - Service Installation* - **Latest popup screenshots hosted externally (v19.3.1+)** Because Chromium updates native permission popups frequently, static popup screenshots were removed from this FAQ in v19.3.1. Use this page for the latest screenshots: [https://dynamsoft.github.io/Dynamic-Web-TWAIN/local-network-access.html](https://dynamsoft.github.io/Dynamic-Web-TWAIN/local-network-access.html) These improvements are available starting with Dynamic Web TWAIN v19.3. For older versions, a supplemental JavaScript file can be provided on request by contacting [Dynamsoft Support](mailto:support@dynamsoft.com). > [!NOTE] > This supplemental JavaScript file improves user guidance only and does not change browser permission requirements. ## Other Causes of Failure to Connect to the Service There are other causes of service connection failure. See [another FAQ](/_articles/faq/service-prompting-to-install-repeatedly.md). --- title: Why Do I Get a "File is Damaged and Can’t Be Opened" Error When Using the Dynamic Web TWAIN on macOS? description: Why Do I Get a "File is Damaged and Can’t Be Opened" Error When Using the Dynamic Web TWAIN on macOS? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/file-damaged-on-macos.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/file-damaged-on-macos.md --- # Why Do I Get a "File is Damaged and Can’t Be Opened" Error When Using the Dynamic Web TWAIN on macOS? ### Symptom When attempt to use the scanner on macOS, an error message states “ is damaged and can’t be opened”. ![ds-is-damaged](/assets/imgs/ds-is-damaged.png) ### Reason This issue is caused by macOS Gatekeeper, a security feature that blocks applications that are unsigned or not notarized when the file carries a quarantine attribute. The file itself is not damaged but Gatekeeper prevents it from running. The error message may also show an outdated download time, for example “Safari downloaded this file on `June 18, 2019`”, even on a new computer. This happens because macOS preserves the quarantine metadata when the file has been copied from sources such as: - An old computer - A USB drive - A company server - A backup (e.g., Time Machine restore) ### Resolution This issue is not related to our product but stems from the unsigned driver. - Temporary Fix: Click “OK” on the error dialog. The driver often works normally afterward. - Permanent Fix (if error persists): Remove the “quarantine” attribute via Terminal: - Open Terminal (/Applications/Utilities). - Run this command: ```bash sudo xattr -rd com.apple.quarantine /Applications/{YourDriver}.app ```
> Only disable checks for trusted files. Verify the driver’s source is safe before proceeding.
--- title: Safari 26.2 Regression Causing Dynamic Web TWAIN v19.3 Auto-Reconnect Failure on macOS description: Safari 26.2 Regression Causing Dynamic Web TWAIN v19.3 Auto-Reconnect Failure on macOS source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/safari-26-2-regression.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/safari-26-2-regression.md --- # Safari 26.2 Regression Causing Dynamic Web TWAIN v19.3 Auto-Reconnect Failure on macOS ### Symptom After upgrading to Safari 26.2 on macOS, a compatibility issue was observed with Dynamic Web TWAIN v19.3. When a site installs or updates the Dynamic Web TWAIN v19.3 Service for the first time, the automatic connection and reconnect mechanism fails. A browser refresh is required to restore normal behavior. ### Issue characteristics - Only occurs in Safari 26.2 - Does not occur in Safari 26.1 or earlier versions - Does not occur in Dynamic Web TWAIN versions prior to 19.3 ### Reason Dynamic Web TWAIN 19.3 introduced a new configuration in reconnect requests: `targetAddressSpace: "loopback"`, following the Chrome Local Network Access documentation to explicitly indicate that the request targets the loopback address (127.0.0.1). In Safari 26.1 and earlier, this configuration is ignored and requests are sent normally. In Safari 26.2, `fetch` throws a `TypeError` when this configuration is present, causing the request to fail before being sent. As a result, `reconnect` cannot be implemented even though the Dynamsoft Service is installed and running. ### Update The WebKit team has identified this issue as a regression in Safari 26.2 and has already fixed it. The fix will be included in an upcoming Safari release. --- title: End-User Guide - Dynamic Web TWAIN SDK Documentation description: This article will guide the end users of your web app to use Dynamic Web TWAIN for document scanning. source_url: html: https://www.dynamsoft.com/web-twain/docs/end-user/index.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/end-user/index.md --- # End-User Guide This article aims at guiding you, an end user of your company's web app, to scan documents using Dynamic Web TWAIN. ## Install Service When you visit your company's web app and want to scan for the first time, you may be prompted to install Dynamic Web TWAIN if your IT does not have it installed. Please download the service installer and install it on your device. It is needed to communicate between the scanners and the web app. Service Installation Dialog: ![service installation dialog](/assets/imgs/install-dialog.png) If you still see the dialog after installation, try enabling [access to apps on your device](#allow-access-to-local-apps) and checking the [list of possible reasons](/_articles/faq/service-prompting-to-install-repeatedly.md). ## Allow Access to Local Apps In latest browsers, you may need to grant access to apps on your device to make proper scanning. When it is asking for permission, please click "**Allow**". ![permission dialog](/assets/imgs/end-user/chrome-142-permission-dialog.jpg){: id="permission-dialog"} If you accidentally block the access, you can reset it as shown in the following dialog. ![site settings](/assets/imgs/end-user/chrome-142-site-settings.jpg){: id="site-settings"} The UI may vary according to different browsers and browser versions. The following shows the different UIs.
- Chrome 145+ - Chrome 142-144 - Edge 145+ - Edge 142-144 - FireFox
1. Permission asking dialog: ![permission dialog chrome 145](/assets/imgs/end-user/chrome-145-permission-dialog.jpg) 2. Site settings: ![site settings dialog chrome 145](/assets/imgs/end-user/chrome-145-site-settings.jpg)
1. Permission asking dialog: ![permission dialog](/assets/imgs/end-user/chrome-142-permission-dialog.jpg) 2. Site settings: ![site settings](/assets/imgs/end-user/chrome-142-site-settings.jpg)
1. Permission asking dialog: ![permission dialog](/assets/imgs/end-user/edge-145-permission-dialog.jpg) 2. Site settings: ![site settings](/assets/imgs/end-user/edge-145-site-settings.jpg)
1. Permission asking dialog: ![permission dialog](/assets/imgs/end-user/edge-142-permission-dialog.jpg) 2. Site settings: ![site settings](/assets/imgs/end-user/edge-142-site-settings.jpg)
1. Permission asking dialog: ![permission dialog](/assets/imgs/end-user/firefox-permission-dialog.jpg) 2. Site settings: ![site settings](/assets/imgs/end-user/firefox-site-settings.jpg)
## Perform Scanning Now, visit your app and try to scan documents. Here, we are using Dynamsoft's [online demo](https://demo.dynamsoft.com/web-twain/) for illustration. ![web demo](/assets/imgs/end-user/web-demo.jpg) If it does not detect any scanners, make sure that you have installed the driver. You can find the driver from the scanner manufacturer's support site. Canon's Driver Download Site (e.g.): ![canon driver](/assets/imgs/end-user/canon-driver-download-site.jpg) ## Others If you do not have the permission to make the changes, please contact your IT for help. More resources: * [Configuring the Dynamic Web TWAIN Service](/_articles/extended-usage/dynamsoft-service-configuration.md) * [What does the Dynamic Web TWAIN Service do on the end-user machine?](/_articles/faq/what-does-dynamsoft-service-do-on-end-user-machine.md) * [I have installed the Dynamic Web TWAIN Service on an end-user machine but still got asked to install it repeatedly. Why?](/_articles/faq/service-prompting-to-install-repeatedly.md) * [How to uninstall Dynamic Web TWAIN Service?](/_articles/faq/how-to-uninstall-dynamsoft-service.md)
--- title: Advanced DWT Initialization description: Advanced DWT Initialization source_url: html: https://www.dynamsoft.com/web-twain/docs/extended-usage/advanced-initialization.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/extended-usage/advanced-initialization.md --- # Advanced DWT Initialization > Prerequisite: [DWT Initialization](/_articles/general-usage/initialization.md) As presented in the standard [initialization guide](/_articles/general-usage/initialization.md), DWT instantiates a default `WebTwain` object in its default configuration. Here, we offer some alternative ways to instantiate `WebTwain` objects, as well as ways to alter the configuration of `WebTwain` objects. ## Auto-Loading with CDN/Package Manager Resources The resource files loaded from CDNs and package managers slightly differ from the resource files obtained from the [official SDK](https://www.dynamsoft.com/web-twain/downloads). Namely, `Dynamsoft.DWT.AutoLoad` is `true` in official SDK resources (`dynamsoft.webtwain.config.js`), and `false` otherwise. This property affects whether or not DWT automatically instantiates `WebTwain` instances upon load resources (auto-load). Likewise, `Dynamsoft.DWT.Containers` provides configurations for `WebTwain` instances created during auto-load. This is found in the official SDK resources (`dynamsoft.webtwain.config.js`), and absent otherwise. To enable auto-loading when obtaining resources from CDNs or package manager, we must define these two properties, for example: ### Loading from jsDelivr ```html
``` ### Loading from UNPKG > [!WARNING] > UNPKG may not provide any guarantees of uptime or technical support. ```html
``` APIs used: - [`Dynamsoft.DWT.RegisterEvent()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#registerevent) - [`Dynamsoft.DWT.GetWebTwain()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain) - [`OnWebTwainReady`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainready) - [`Dynamsoft.DWT.ResourcesPath`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#resourcespath) - [`Dynamsoft.DWT.ProductKey`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#productkey) - [`Dynamsoft.DWT.Containers`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#containers) - [`Dynamsoft.DWT.Container`](/_articles/info/api/interfaces.md#Container) - [`Dynamsoft.DWT.AutoLoad`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#autoload) ### Explanation Setting values for `Dynamsoft.DWT.AutoLoad` and `Dynamsoft.DWT.Containers` results in identical startup behavior for resources obtained from CDNs and package managers to resources obtained from the official SDK. > Note: jsDelivr currently has problems delivering the Dynamic Web TWAIN Service installer (`https://cdn.jsdelivr.net/npm/dwt@latest/dist/dist/DynamicWebTWAINServiceSetup.msi`) due to [size restrictions](https://www.jsdelivr.com/documentation#id-configuring-a-default-file-in-packagejson); please consider hosting this particular resource file elsewhere. You can specify the path using [`ServiceInstallerLocation`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#serviceinstallerlocation). UNPKG is currently unaffected. For information about the Dynamic Web TWAIN Service, learn more [here](/_articles/extended-usage/dynamsoft-service-configuration.md). ## Configuring Default `WebTwain` Instances Since [`Dynamsoft.DWT.Containers`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#containers) controls the configuration for the `WebTwain` instance, we can use it to control the initial dimensions of the `Viewer`, and the container that the `Viewer` is bound to. `Dynamsoft.DWT.Containers` is an array of objects of the interface [`Dynamsoft.DWT.Container`](/_articles/info/api/interfaces.md#Container), which looks like this: ``` typescript interface Container { WebTwainId?: string; ContainerId?: string; Width?: string | number; Height?: string | number; } ``` Previously we omitted the `WebTwainId` property. This is simply another identifier which can substitute `ContainerId`, particularly in the case of headless `WebTwain` instances. A `WebTwain` instance must have **at least one** of these two properties defined. To create multiple `WebTwain` instances with `Dynamsoft.DWT.Containers`, simply add elements to the array. Make sure to use different identifiers for the instances to prevent conflicts. ## Instantiating `WebTwain` Without Auto-Load Some use cases call for instantiating `WebTwain` objects on demand. To do this, we use the [`Dynamsoft.DWT.Load()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#load) API to create the `WebTwain` instance. This following example demonstrates this method with resources obtained from a CDN, but resources from other sources also work: ### Sample Code ```html
``` APIs Used: - [`Dynamsoft.DWT.RegisterEvent()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#registerevent) - [`Dynamsoft.DWT.GetWebTwain()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain) - [`OnWebTwainReady`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainready) - [`Dynamsoft.DWT.ResourcesPath`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#resourcespath) - [`Dynamsoft.DWT.ProductKey`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#productkey) - [`Dynamsoft.DWT.Containers`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#containers) - [`Dynamsoft.DWT.Container`](/_articles/info/api/interfaces.md#Container) - [`Dynamsoft.DWT.Load()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#load) ### Explanation > Note: When using resources from the official SDK, we must set `Dynamsoft.DWT.AutoLoad = false` in the `dynamsoft.webtwain.config.js` file. This sample above instantiates a `WebTwain` object upon demand. In this case the button triggers instantiation, which calls [`Dynamsoft.DWT.Load()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#load). `Dynamsoft.DWT.Load()` creates `WebTwain` instances based on the value of `Dynamsoft.DWT.Containers`. `Dynamsoft.DWT.Load()` also triggers the `OnWebTwainReady` event, which allows us to store the `WebTwain` object in the `DWTObject` variable. > Note: `Dynamsoft.DWT.Load()` also triggers `OnWebTwainReady` during auto-load; DWT just invokes `Dynamsoft.DWT.Load()` automatically. ## Instantiating WebTwain Without `OnWebTwainReady` The previous two methods relied on listening to the `OnWebTwainReady` event to grab the `WebTwain` instance, and using `Dynamsoft.DWT.Containers` for the configuration. For more flexibility, DWT offers the [`Dynamsoft.DWT.CreateDWTObject()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#createdwtobject) API. The following sample works with resources obtained from any source: ### Sample Code ```html
``` APIs Used: - [`Dynamsoft.DWT.RegisterEvent()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#registerevent) - [`Dynamsoft.DWT.GetWebTwain()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain) - [`OnWebTwainReady`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainready) - [`Dynamsoft.DWT.ResourcesPath`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#resourcespath) - [`Dynamsoft.DWT.ProductKey`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#productkey) - [`Dynamsoft.DWT.CreateDWTObject()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#createdwtobject) ### Explanation > Note: When using resources from the official SDK, we must set `Dynamsoft.DWT.AutoLoad = false` and `Dynamsoft.DWT.Containers = []` in the `dynamsoft.webtwain.config.js` file to disable auto-loading. This method creates a `WebTwain` instance, and makes it available through the success callback function, rather than registering a callback handler to the `OnWebTwainReady` event. [`Dynamsoft.DWT.CreateDWTObject()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#createdwtobject) also binds the `WebTwain` instance to a container via a container `id`. This method does not provide a way to configure the size of the `Viewer`, so the `Viewer` size must be set after instantiation (e.g. with the `Viewer` [`width`](/_articles/info/api/WebTwain_Viewer.md#width) and [`height`](/_articles/info/api/WebTwain_Viewer.md#width) properties). `Dynamsoft.DWT.CreateDWTObject()` can also set network configurations with an overloaded method like so: ```javascript CreateDWTObject( ContainerId: string, host: string, port: string | number, portSSL: string | number, successCallBack: (DWTObject: WebTwain) => void, failureCallBack: ({code: number, message: string}) => void ): void; ``` ## Creating Headless `WebTwain` Instances The other instantiation methods all create a `Viewer` component in the `WebTwain` instance. To forgo a `Viewer`, or to create one separately after the fact, DWT provides the [`Dynamsoft.DWT.CreateDWTObjectEx()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#createdwtobjectex). This sample demonstrates creating a `WebTwain` instance on demand. This works with resource files obtained from any source. ### Sample Code ```html ``` APIs Used: - [`Dynamsoft.DWT.ResourcesPath`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#resourcespath) - [`Dynamsoft.DWT.ProductKey`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#productkey) - [`Dynamsoft.DWT.CreateDWTObjectEx()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#createdwtobjectex) - [`DWTInitialConfig`](/_articles/info/api/interfaces.md#DWTInitialConfig) - [`SelectSourceAsync()`](/_articles/info/api/WebTwain_Acquire.md#selectsourceasync) - [`AcquireImageAsync()`](/_articles/info/api/WebTwain_Acquire.md#acquireimageasync) - [`IfCloseSourceAfterAcquire`](/_articles/info/api/Device.md#deviceobjectacquireimage) - [`HowManyImagesInBuffer`](/_articles/info/api/WebTwain_Buffer.md#howmanyimagesinbuffer) ### Explanation > Note: When using resources from the official SDK, we must set `Dynamsoft.DWT.AutoLoad = false` and `Dynamsoft.DWT.Containers = []` in the `dynamsoft.webtwain.config.js` file to disable auto-loading. [`Dynamsoft.DWT.CreateDWTObjectEx()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#createdwtobjectex) creates a `WebTwain` instance provided by the [`DWTInitialConfig`](/_articles/info/api/interfaces.md#DWTInitialConfig) interface (this can also configure `host`, `port`, `ssl`). In this example, the object simply defines an identifier. Since this `WebTwain` instance is headless, it cannot be identifier by its container's `id`, so we use the `WebTwainId` property instead. ## Customizing the instances The instances are defined in `dynamsoft.webtwain.config.js`: ``` javascript Dynamsoft.DWT.Containers = [{ ContainerId: 'dwtcontrolContainer', Width: '585px', Height: '513px' }]; ``` `Containers` is an array of the `Container` type. ``` typescript interface Container { WebTwainId?: string; ContainerId?: string; Width?: string | number; Height?: string | number; } ``` Notes: - `WebTwainId` and `ContainerId` are both optional but one must exist as the identifier for that `WebTwain` instance. - `Width` and `Height` determine the initial viewer size of the instance. - When instantiating with `Dynamsoft.DWT.Load` , `ContainerId` , `Width` and `Height` are required. Dynamic Web TWAIN will try to locate an HTML element with the ID defined by `ContainerId` and use `Width` and `Height` as the viewer size. To create multiple instances, simply provide multiple `Containers`. For example, the following code creates two `WebTwain` instances: ``` javascript Dynamsoft.DWT.Containers = [{ ContainerId: 'dwtcontrolContainer1', Width: '585px', Height: '513px' }, { ContainerId: 'dwtcontrolContainer2', Width: '585px', Height: '513px' }]; ``` ## Note on Namespaces DWT operates under the `Dynamsoft` namespace, and most of its features may be found in `Dynamsoft.DWT`. Here is the break-down: - [`Dynamsoft.DWT`](/_articles/info/api/Dynamsoft_WebTwainEnv.md) This contains global methods and properties such as DWT initialization and `WebTwain` instantiation. This also contains enumerations, e.g. [`Dynamsoft.DWT.EnumDWT_PixelType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftenumdwt_pixeltype). - `Dynamsoft.Lib` This contains information such as environment detection results (`Dynamsoft.Lib.env`), and global methods such as `showMask()` and `hideMask()`.
--- title: Dynamic Web TWAIN SDK Features - Read Barcode description: Dynamic Web TWAIN SDK Documentation Read Barcode Page source_url: html: https://www.dynamsoft.com/web-twain/docs/extended-usage/barcode-processing.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/extended-usage/barcode-processing.md --- # Barcode Reader With the increasing use of barcode reading in document management systems, the Barcode Reader add-on for Dynamic Web TWAIN presents an easy and seamless way of integrating one of the industry's best barcode reading components into your document management system. In this section, we will show you how to get started with the add-on and demonstrate how it can be used as a batch document classifier or separator. > NOTE > > Barcode reading can be performed on the client side as well as the server side. For `Dynamic Web TWAIN` , we only consider client-side reading. If you are interested in reading on the server side, you can contact [Dynamsoft Support](/_articles/about/getsupport.md). ## Environment * Windows * macOS * Linux ## How to use ### Step one - Include the add-on To include this add-on is to reference the necessary JavaScript file which is included in the [resources files](/_articles/faq/what-are-the-resources-files.md). > If you are using the [dwt package](https://www.npmjs.com/package/dwt), the barcode reader is already included in the main JavaScript file ( `dynamsoft.webtwain.min.js` or `dynamsoft.webtwain.min.mjs` ) which means you can skip this step. ``` html ``` ### Step two - Start the reading Now that the add-on has been referenced, we can call [`decode()`](/_articles/info/api/Addon_BarcodeReader.md#initruntimesettingswithstring) to start reading barcode(s). ``` javascript function readBarcodes(imageIndex) { if (DWTObject) { DWTObject.Addon.BarcodeReader.decode(imageIndex) .then(function(textResults) { console.log(textResults) }, function(error) { console.log(error) }); } else { console.log('DWTObject is not initialized yet'); } } ``` Note that the barcode reading does take a bit of time, so it'll help to add an indicator as mentioned in [Loading Bar and Backdrop](/_articles/extended-usage/ui-customization.md#loading-bar-and-backdrop) ``` javascript function readBarcodes(imageIndex) { if (DWTObject) { // Add an indicator Dynamsoft.DWT.OnWebTwainPreExecute(); DWTObject.Addon.BarcodeReader.decode(imageIndex) .then(function(textResults) { // Remove the indicator Dynamsoft.DWT.OnWebTwainPostExecute(); console.log(textResults) }, function(error) { // Remove the indicator Dynamsoft.DWT.OnWebTwainPostExecute(); console.log(error) }); } else { console.log('DWTObject is not initialized yet'); } } ``` ### Step three - Check the result Check the structure of the resulting object [here](/_articles/info/api/Addon_BarcodeReader.md#decode). The following code prints out the text contained in the barcode(s) ``` javascript Dynamsoft.DWT.OnWebTwainPreExecute(); DWTObject.Addon.BarcodeReader.decode(imageIndex) .then(function(textResults) { // Remove the indicator Dynamsoft.DWT.OnWebTwainPostExecute(); for (var i = 0; i < textResults.length; i++) { console.log(textResults[i].BarcodeText); } }, function(error) { // Remove the indicator Dynamsoft.DWT.OnWebTwainPostExecute(); console.log(error) }); ``` ## Runtime Settings Most of the time, you simply need to use the default decode method to read most of the barcode images out there. However, you may encounter some barcodes that fail to be read and sometimes you might want to limit which barcode types the reader should pick up, and more. The runtime settings of the add-on gives you access to a wide array of customizable parameters, all of which you can check out with the method [ `getRuntimeSettings()` ](/_articles/info/api/Addon_BarcodeReader.md#getruntimesettings) and change with the method [ `updateRuntimeSettings()` ](/_articles/info/api/Addon_BarcodeReader.md#updateruntimesettings). Now to demonstrate a few typical customization scenarios: ### Specify the Barcode Type(s) to Read By default, the add-on will read all the supported barcode types from the image. (See the `Supported Symbologies` [here](https://www.dynamsoft.com/Products/Barcode-Types.aspx)) If your license only covers a subset of the full list or you want to read specific barcode types, you can use `barcodeFormatIds` and `barcodeFormatIds2` to specify the barcode format(s). For example, to enable only 1D barcode reading, you can use the following code snippet: ``` javascript DWTObject.Addon.BarcodeReader.getRuntimeSettings() .then(function(runtimeSettings) { runtimeSettings.barcodeFormatIds = Dynamsoft.DBR.EnumBarcodeFormat.BF_ONED; return DWTObject.Addon.BarcodeReader.updateRuntimeSettings(runtimeSettings); }, function(error) { console.log(error); }) .then(function(runtimeSettings) { // Add an indicator Dynamsoft.DWT.OnWebTwainPreExecute(); return DWTObject.Addon.BarcodeReader.decode(imageIndex); }, function(error) { console.log(error); }) .then(function(textResults) { // Remove the indicator Dynamsoft.DWT.OnWebTwainPostExecute(); for (var i = 0; i < textResults.length; i++) { console.log(textResults[i].BarcodeText); } }, function(error) { // Remove the indicator Dynamsoft.DWT.OnWebTwainPostExecute(); console.log(error) }); ``` See also [`EnumBarcodeFormat`](https://www.dynamsoft.com/barcode-reader/docs/v9/web/programming/javascript/api-reference/enum/EnumBarcodeFormat.html?ver=9.6.42) and [`EnumBarcodeFormat_2`](https://www.dynamsoft.com/barcode-reader/docs/v9/web/programming/javascript/api-reference/enum/EnumBarcodeFormat_2.html?ver=9.6.42). ### Specify maximum barcode count By default, the add-on will read as many barcodes as it can. To increase the recognition efficiency, you can use `expectedBarcodesCount` to specify the maximum number of barcodes to recognize according to your scenario. ``` javascript // No matter how many barcodes are on the image, stop reading as soon as one barcode is found runtimeSettings.expectedBarcodesCount = 1; DWTObject.Addon.BarcodeReader.updateRuntimeSettings(runtimeSettings); ``` ### Specify a scan Region By default, the add-on will search the whole image for barcodes. This can lead to poor performance especially when dealing with high-resolution images. You can speed up the recognition process by restricting the scanning region. To specify a region, you will need to define an area. The following code shows how to define the region. ``` javascript // The following reads the center of the image (50% vertically and horizontally) runtimeSettings.region.regionTop = 25; runtimeSettings.region.regionBottom = 75; runtimeSettings.region.regionLeft = 25; runtimeSettings.region.regionRight = 75; runtimeSettings.region.regionMeasuredByPercentage = 1; DWTObject.Addon.BarcodeReader.updateRuntimeSettings(runtimeSettings); ``` ### Set the runtime settings using JSON So far, we edited the values of specific runtime settings via accessing each individual setting and adjusting its value. However, the add-on also provides the developer the ability to set everything at once using a JSON string. The method is called [ `initRuntimeSettingsWithString()` ](/_articles/info/api/Addon_BarcodeReader.md#initruntimesettingswithstring). > Some advanced features, such as dedicated configuration of a binarization mode, are only possible when using the method `initRuntimeSettingsWithString()` . Here is a JSON template for your reference: ``` javascript var settings = { "ImageParameter": { "BarcodeFormatIds": ["BF_ALL"], "BinarizationModes": [{ "BlockSizeX": 0, "BlockSizeY": 0, "EnableFillBinaryVacancy": 1, "ImagePreprocessingModesIndex": -1, "Mode": "BM_LOCAL_BLOCK", "ThreshValueCoefficient": 10 }], "DeblurLevel": 9, "Description": "", "ExpectedBarcodesCount": 0, "GrayscaleTransformationModes": [{ "Mode": "GTM_ORIGINAL" }], "ImagePreprocessingModes": [{ "Mode": "IPM_GENERAL" }], "IntermediateResultSavingMode": { "Mode": "IRSM_MEMORY" }, "IntermediateResultTypes": ["IRT_NO_RESULT"], "MaxAlgorithmThreadCount": 4, "Name": "runtimesettings", "PDFRasterDPI": 300, "Pages": "", "RegionDefinitionNameArray": null, "RegionPredetectionModes": [{ "Mode": "RPM_GENERAL" }], "ResultCoordinateType": "RCT_PIXEL", "ScaleDownThreshold": 2300, "TerminatePhase": "TP_BARCODE_RECOGNIZED", "TextFilterModes": [{ "MinImageDimension": 65536, "Mode": "TFM_GENERAL_CONTOUR", "Sensitivity": 0 }], "TextResultOrderModes": [{ "Mode": "TROM_CONFIDENCE" }, { "Mode": "TROM_POSITION" }, { "Mode": "TROM_FORMAT" } ], "TextureDetectionModes": [{ "Mode": "TDM_GENERAL_WIDTH_CONCENTRATION", "Sensitivity": 5 }], "Timeout": 10000 }, "Version": "3.0" }; ``` For a JSON object like `settings` above, you should make it a string first as shown in the code below ``` javascript var JSONString = JSON.stringify(settings); DWTObject.Addon.BarcodeReader.initRuntimeSettingsWithString(JSONString) .then(function(){ return DWTObject.Addon.BarcodeReader.decode(imageIndex); },function(error) { console.log(error) }) .then(function(textResults) { if (textResults.length == 0) { console.log("No barcode found"); } else { for (var i = 0; i < textResults.length; i++) { console.log(textResults[i].BarcodeText); } } }, function(error) { console.log(error) }) ``` ### Built-in modes If you are not sure how to change the `RuntimeSettings` , the add-on also comes with three built-in modes for you to choose from * `speed` : fast but may miss some barcodes * `coverage` : slow but covers most barcodes * `balance` : between `speed` and `coverage` To use one of these modes, simply call `updateRuntimeSettings()` ``` javascript DWTObject.Addon.BarcodeReader.updateRuntimeSettings('coverage').then( /*---*/ ); ``` [Try](https://demo.dynamsoft.com/Samples/dwt/Scan-Documents-and-Read-Barcode/ReadBarcode.html) or [download](https://www.dynamsoft.com/handle-sample?demoSampleId=66&type=2&productId=1000001&link=https%3a%2f%2fdownload2.dynamsoft.com%2fSamples%2fDWT%2fScan-Documents-and-Read-Barcode.zip) an official demo. ### Reset settings You can always go back to the default settings with the method [ `resetRuntimeSettings()` ](/_articles/info/api/Addon_BarcodeReader.md#resetruntimesettings). ## Use barcode to classify and separate documents Using pages with barcodes as document separators and classifying images with the barcode on it are two popular usage scenarios. ### As document separators The following code reads all images and use those with barcodes to separate images into different documents. ``` javascript // `aryIndices` consists of multiple arrays each of which represents a document var aryIndices = [], bBarcodeFound = false, ProcssedImagesCount = 0; j; function ReadBarcode(index) { DWTObject.Addon.BarcodeReader.decode(index) .then(function(results) { ProcssedImagesCount++; if (results.length === 0) { console.log('no barcode found on image index ' + index); if (bBarcodeFound === true) { // If a barcode was found earlier, this image belongs to the current document bBarcodeFound = false; if (aryIndices.length === 0) aryIndices.push([index]); else aryIndices[aryIndices.length - 1].push(index); } else { // If no barcode has been found yet, this image belongs to the first document if (aryIndices.length === 0) aryIndices.push([index]); else aryIndices[aryIndices.length - 1].push(index); } } else { console.log('barcode found on image index ' + index); if (ProcssedImagesCount === DWTObject.HowManyImagesInBuffer) { //If it is the last image, no need to set this flag to true nor create a new document bBarcodeFound = false; } else { bBarcodeFound = true; // Found a barcode, create a new one if (aryIndices.length === 0) aryIndices.push([]); else if (aryIndices[aryIndices.length - 1].length != 0) aryIndices.push([]); } } if (ProcssedImagesCount === DWTObject.HowManyImagesInBuffer) { // Print out the index arrays, each array represents a document console.log(aryIndices); aryIndices = []; } else /* * Read the next image */ ReadBarcode(index + 1); }, function(errorMsg) { console.log(errorMsg); } ); } ReadBarcode(0); ``` ### As document classifier The following code reads all barcodes from all images and puts images which have the same barcode into one document. Images without any barcodes are put into another separate document. ``` javascript // `aryIndices` consists of multiple arrays each of which represents a document var aryIndices = { 'noBarcode': [] }, ProcssedImagesCount = 0; function ReadBarcode(index) { var j, bBarcodeFound = false; DWTObject.Addon.BarcodeReader.decode(index).then(function(results) { ProcssedImagesCount++; if (results.length === 0) { console.log('no barcode found on image index ' + index); aryIndices.noBarcode.push(index); } else { console.log('barcode found on image index ' + index); var barcodeOnThisImage = [], allKeys = []; for (j = 0; j < results.length; j++) { var result = results[j]; var barcodeText = result.barcodeText; // Record all barcodes found on this image if (barcodeOnThisImage.indexOf(barcodeText) === -1) barcodeOnThisImage.push(barcodeText); } Dynamsoft.Lib.each(aryIndices, function(value, key) { allKeys.push(key); }); for (j = 0; j < allKeys.length; j++) { var oKey = allKeys[j]; if (barcodeOnThisImage.indexOf(oKey) != -1) { barcodeOnThisImage.splice(barcodeOnThisImage.indexOf(oKey), 1); var _value = aryIndices[oKey]; if (_value.indexOf(index) === -1) { _value.push(index); aryIndices[oKey] = _value; } } } for (j = 0; j < barcodeOnThisImage.length; j++) { aryIndices[barcodeOnThisImage[j]] = [index]; } } if (ProcssedImagesCount === DWTObject.HowManyImagesInBuffer) { ProcssedImagesCount = 0; var aryTemp = []; Dynamsoft.Lib.each(aryIndices, function(value, key) { aryTemp.push(value); }); aryIndices = aryTemp; console.log(aryIndices); aryIndices = { 'noBarcode': [] }; } else /* * Read the next image */ ReadBarcode(index + 1); }, function(errorMsg) { console.log(errorMsg); } ); } ReadBarcode(0); ``` [Try](https://demo.dynamsoft.com/Samples/dwt/Scan-Documents-and-Separate-them-by-Barcode/Scan-Separate-Barcode.html) or [download](https://www.dynamsoft.com/handle-sample?demoSampleId=102&type=2&productId=1000001&link=https%3a%2f%2fdownload2.dynamsoft.com%2fSamples%2fDWT%2fScan-Documents-and-Separate-them-by-Barcode.zip) the official demo. --- title: Dynamic Web TWAIN SDK Guide - Buffer Caching description: Understand buffer caching in Dynamic Web TWAIN and how it improves scan performance, memory use, and document capture reliability for modern web and mobile apps source_url: html: https://www.dynamsoft.com/web-twain/docs/extended-usage/buffer-caching.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/extended-usage/buffer-caching.md --- # Buffer Caching The DWT image buffer is controlled by the Dynamic Web TWAIN Service(formerly known as Dynamsoft Service). The Dynamic Web TWAIN Service can run in either 32-bit mode or 64-bit mode. Before DWT version 15.0, the service ran in 32-bit mode by default. This meant it could not address more than 2GB of physical memory. Starting in version 15.0, the Dynamic Web TWAIN Service runs as 64-bit by default on 64-bit operating systems, which removes the 2GB memory limit. To limit memory usage, DWT can cache data to disk to free up memory. ## Disk Caching The DWT image buffer handles data using the `DIB` format, which take up a lot of space in memory. For example, one A4 paper scanned in 300 DPI takes around 24MB in memory, which means 2GB of physical memory can only store no more than 85 of these images. As more images are processed, more memory gets used which may pose a threat to other programs on the machine. Due to this, the disk cache function was added. After enabling disk caching, most images will be temporarily cached on the disk, while keeping some active images in the memory to maintain high performance. The disk caching feature is enabled by default, but can be disabled by setting [`IfAllowLocalCache`](/_articles/info/api/WebTwain_Buffer.md#ifallowlocalcache) to `false` . You can also set how much memory `Dynamic Web TWAIN` can use before images start to be cached. By default, **800MB** is used. You can change it using the property [`BufferMemoryLimit`](/_articles/info/api/WebTwain_Buffer.md#buffermemorylimit). > Note: All cached data is encrypted and can only be accessed by `Dynamic Web TWAIN`. When `Dynamic Web TWAIN` is unloaded (like when the browser tab refreshes or closes), the cached data is destroyed and removed from the disk automatically. Although you can scan and load as many images as you like, you may want to handle them in smaller volumes when doing further processing. For example, when dealing with extremely large volumes, you should not try to upload or save the images all at once as that would be too time consuming and prone to errors. ## Save the encrypted image caches in local Dynamic Web TWAIN Service folder In certain scenarios, there may be requirements to store encrypted image caches on a local disk for temporary data storage or backup purposes. For instance, when scanning a large batch of documents, accidentally closing the web page can result in the loss of scanned data, necessitating scanning the documents again. This issue can be mitigated by backing up the data before closing the page. Starting from version 18.5, Dynamic Web TWAIN introduces a new feature that facilitates developers in securely storing image caches in encrypted form within the Dynamic Web TWAIN Service(formerly known as Dynamsoft Service) folder. This feature offers several advantages: - Data is stored securely in encrypted form. - The speed of storing data locally and loading it back into the Dynamic Web TWAIN buffer is fast. - The stored data remains intact even when the `WebTwain` instance is destroyed. > Note: Since the storage folder is located within the Dynamic Web TWAIN Service directory, the stored data will be lost if Dynamic Web TWAIN Service is uninstalled. Upgrading the Dynamic Web TWAIN Service will not affect the storage folder. ### Create a storage folder First of all, you need to create a storage item by [`createLocalStorage()`](/_articles/info/api/WebTwain_IO.md#createlocalstorage) which is used to save the encrypted image caches. For example, ```javascript var folderSettings = { password: "XXXXXXXX", }; // Specify the password of the created storage folder var storageItemUid = await DWTObject.createLocalStorage(folderSettings); ``` Please ensure to set a strong password to enhance data security, especially in multi-user login scenarios. The local directory of the created storage folder is under the service's [intallation folder](/_articles/extended-usage/dynamsoft-service-configuration.md#installation-folder). **Save image caches** To save the specified image(s) to the storage folder, [`saveToLocalStorage()`](/_articles/info/api/WebTwain_IO.md#savetolocalstorage) method is required. ```javascript var bExist = await DWTObject.localStorageExist(storageItemUid); // Determine whether the folder exists if (bExist) { var saveImageSettings = { uid: storageItemUid, password: "XXXXXXXX", indices: [0,1], // The first two images in buffer }; await DWTObject.saveToLocalStorage(saveImageSettings); } else { console.log("The storage folder does not exist."); } ``` **Load image(s) from the storage folder** To load the encrypted image caches into Dynamic Web TWAIN again, please use the method [`loadFromLocalStorage()`](/_articles/info/api/WebTwain_IO.md#loadfromlocalstorage). ```javascript var bExist = await DWTObject.localStorageExist(storageItemUid); // Determine whether the folder exists if (bExist) { var loadImageSettings = { uid: storageItemUid, password: "XXXXXXXX", }; await DWTObject.loadFromLocalStorage(loadImageSettings); } else { console.log("The storage folder does not exist."); } ``` **Remove the storage folder** If you would like to remove the storage folder by programming, the method [`removeLocalStorage()`](/_articles/info/api/WebTwain_IO.md#removelocalstorage) can help. ```javascript var bExist = await DWTObject.localStorageExist(storageItemUid); // Determine whether the folder exists if (bExist) { var removeFolderSettings = { uid: storageItemUid, password: "XXXXXXXX", }; await DWTObject.removeLocalStorage(removeFolderSettings); } else { console.log("The storage folder does not exist."); } ``` --- title: Dynamic Web TWAIN SDK Deployment - Dynamic Web TWAIN Service description: Dynamic Web TWAIN SDK Documentation Dynamic Web TWAIN Service Page source_url: html: https://www.dynamsoft.com/web-twain/docs/extended-usage/dynamsoft-service-configuration.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/extended-usage/dynamsoft-service-configuration.md --- # Configuring the Dynamic Web TWAIN Service The Dynamic Web TWAIN Service is the core piece of Dynamic Web TWAIN. It handles the communication between hardware (scanner, webcam, etc.) and browser, manages the image buffer, and coordinates data between different modules. ## Installation of Dynamic Web TWAIN Service On a desktop, when new users access a web page using Dynamic Web TWAIN SDK for the first time, they will be prompted to install the Dynamic Web TWAIN Service. This is a built-in behavior of the library. The prompt will display the download link. Once the installer is downloaded, the installation process will take just a few seconds. The prompt comes up when you try to [create a WebTwain instance](/_articles/extended-usage/advanced-initialization.md#instantiating-webtwain-without-onwebtwainready). ![Initialization](/assets/imgs/Initialization-1.png) On **Windows and macOS**, double click the downloaded installer to install the service. On **Linux**, instead of double clicking, the downloaded installer needs to be run using one of the following commands: - Debian / Ubuntu ```bash sudo dpkg -i DynamicWebTWAINServiceSetup.deb ``` - Fedora ```bash sudo rpm -ivh DynamicWebTWAINServiceSetup.rpm ``` Once the installation is done, the users can click the orange sentence 'click here to verify completion' or refresh the page to start using Dynamic Web TWAIN. ![Initialization](/assets/imgs/Initialization-2.png) ### Download Links for the Service Installers Here is a table of links for the latest version. | Platform | Download Link | | ------------- | --------------- | | Windows | [Dynamic-Web-TWAIN-Service-Setup.msi](https://demo.dynamsoft.com/DWT/DWTResources/dist/DynamicWebTWAINServiceSetup.msi) | | macOS | [Dynamic-Web-TWAIN-Service-Setup.pkg](https://demo.dynamsoft.com/DWT/DWTResources/dist/DynamicWebTWAINServiceSetup.pkg) | | Linux | [Dynamic-Web-TWAIN-Service-Setup.deb](https://demo.dynamsoft.com/DWT/DWTResources/dist/DynamicWebTWAINServiceSetup.deb)
[Dynamic-Web-TWAIN-Service-Setup-arm64.deb](https://demo.dynamsoft.com/DWT/DWTResources/dist/DynamicWebTWAINServiceSetup-arm64.deb)
[Dynamic-Web-TWAIN-Service-Setup-mips64el.deb](https://demo.dynamsoft.com/DWT/DWTResources/dist/DynamicWebTWAINServiceSetup-mips64el.deb)
[Dynamic-Web-TWAIN-Service-Setup.rpm](https://demo.dynamsoft.com/DWT/DWTResources/dist/DynamicWebTWAINServiceSetup.rpm)| You can find the download links for different versions of service installers on [GitHub](https://github.com/Dynamsoft/Dynamic-Web-TWAIN/releases) or [unpkg](https://app.unpkg.com/dwt/files/dist/dist). ## Installation Folder The service is installed in the following folders on different platforms by default. - Windows: - version 19.0 and later: `C:\Program Files (x86)\Dynamsoft\Dynamic Web TWAIN Service {versionnumber}` - version 18.5.1 and earlier: `C:\Windows\SysWOW64\Dynamsoft\DynamsoftServicex64_{versionnumber}`) - macOS: - version 19.2 and later: `/Users/{username}/Applications/Dynamsoft/Dynamic Web TWAIN Service {versionnumber}` - version 19.0-19.1: `/Applications/Dynamsoft/Dynamic Web TWAIN Service {versionnumber}` - version 18.5.1 and earlier: `/Applications/Dynamsoft/DynamsoftServicex64_{versionnumber}/{installed version No.}`) - Linux: - version 19.0 and later: `/opt/dynamsoft/Dynamic Web TWAIN Service {versionnumber}` - version 18.5.1 and earlier: `/opt/dynamsoft/DynamsoftService` There are some files and folders you may pay attention to: * `log`: the folder where the logs are kept. * `DSConfiguration.ini`: the service's configuration file. * `storage`: the folder used by [`createLocalStorage()`](/_articles/info/api/WebTwain_IO.md#createlocalstorage). ## IP and ports The Dynamic Web TWAIN Service uses `localhost` and `18622` `18625` ports for HTTP connection and `18623` `18626` ports for HTTPS connection. These ports can be configured in the `DSConfiguration.ini` file located in the service's installatin folder. ## Access-Control-Allow-Origin For security purposes, you may want the Dynamic Web TWAIN Service to only respond to requests from specified origins. Starting from Dynamic Web TWAIN version 18.5, this can be achieved by adding `Access-Control-Allow-Origin` in the `DSConfiguration.ini` file. By default, the `Access-Control-Allow-Origin` setting is not configured in the ini file. This means that the Dynamic Web TWAIN Service can respond to requests from any origin. You can set multiple origins by using commas as the separator, and `http://` or `https://` needs to be specified before each origin. If there is a port for the origin, please remember to specify it. If not specified, the default port is 80. No origin: ```bash Access-Control-Allow-Origin=* ``` Single origin: ```bash Access-Control-Allow-Origin=http://192.168.8.212 ``` Multiple origins: ```bash Access-Control-Allow-Origin=http://192.168.8.212, http://192.168.8.126:8033, https://www.dynamsoft.com ``` ![Access-Control-Allow-Origin](/assets/imgs/Access-Control-Allow-Origin.png) After configuring the origins in the `DSConfiguration.ini` file, please set [`IfCheckCORS`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#ifcheckcors) to `true` in `dynamsoft.webtwain.config.js`. When a request comes from a different origin, a CORS error message will be displayed, both in a pop-up and in the console. ![CORS-error-popup](/assets/imgs/CORS-error-popup.png) ![CORS-error-console](/assets/imgs/CORS-error-console.png) ## Web Setup The service provides a web page to know its status and make basic configurations. You can access it through . For security reasons, the web setup is disabled by default. You modify the following line in `DSConfiguration.ini` to enable it. If you cannot find the line, you can add it manually. ```diff - EnableWebSetup=FALSE + EnableWebSetup=TRUE ``` Screenshots: * Default: ![home](/assets/imgs/service-web-setup/home.jpg) * External Access Tab: ![external access setup](/assets/imgs/service-web-setup/external-access-setup.jpg) On the left of the page, you can check the service's status and update the [`LogLevel`](/_articles/info/api/WebTwain_Util.md#loglevel). On the right of the page, you can configure the service through the local access tab and the external access tab. In the local access tab, you can update the SSL certificate for domains bound to `127.0.0.1` ([guide](/_articles/faq/change-dynamsoft-service-certificate.md)). In the external access tab, you can update the following settings: 1. Host: configure an external IP so that it can be accessed by other devices. 2. Firewall exception: add exception rules to the firewall to avoid the traffic being blocked by the firewall (only for Windows). 3. Domain: bind a domain to the IP of your service and configure its SSL certificate. 4. Bonjour service: enable Bonjour service to allow service discovery in local networks. It is needed for the [Remote Scan solution](https://www.dynamsoft.com/remote-scan/docs/introduction/). ## Msg: Dynamic Web TWAIN Service is not installed / Dynamic Web TWAIN is not installed If Dynamic Web TWAIN Service is not installed, users may receive the error 'The Dynamic Web TWAIN module is not installed' when accessing an application that uses Dynamic Web TWAIN. ## Msg: Dynamic Web TWAIN Service installed on your device is outdated If the service is installed but you are using a new version of the JavaScript library, you may encounter this message. You need to install a new version of the service or downgrade the JavaScript library. ## Related Resources: * [What does Dynamic Web TWAIN Service do?](/_articles/faq/what-does-dynamsoft-service-do-on-end-user-machine.md){:target="_blank"} * [I have installed the Dynamic Web TWAIN Service on an end-user machine but still got asked to install it repeatedly. Why?](/_articles/faq/service-prompting-to-install-repeatedly.md){:target="_blank"} * [How to uninstall Dynamic Web TWAIN Service?](/_articles/faq/how-to-uninstall-dynamsoft-service.md){:target="_blank"} * [Can I install Dynamic Web TWAIN Service silently?](/_articles/faq/can-i-install-dynamsoft-service-silently.md){:target="_blank"}
--- title: Dynamic Web TWAIN SDK Basics - Loading Documents from Files description: Dynamic Web TWAIN SDK General Usage Guide - Loading Documents from Files source_url: html: https://www.dynamsoft.com/web-twain/docs/extended-usage/file-import.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/extended-usage/file-import.md --- # Loading Documents from Files > [!TIP] > Prerequisite: [DWT Initialization](/_articles/general-usage/initialization.md) On top of scanning images, DWT can also load documents from files on the file system, or files shared over the network. It can display, edit, and export these documents just the same as scanned images. This flexible design caters to mixed use, scanner-only, or file-only scenarios. We support the following file types: BMP, JPG, TIF, PNG, and PDF. DWT does not support all PDFs due to the complexities of the format, but the PDF rasterizer add-on does provide extra compatibility on top of base support in DWT. We can load in files through the following methods: > [!NOTE] > The PDF rasterizer add-on provides compatibility for a broader range of PDFs. Here we use the add-on script in the `html` head. For any loaded PDFs, the add-on rasterizes every page at the set resolution of 200 DPI. The PDF rasterizer can also selectively rasterize images only - check [`Dynamsoft.DWT.EnumDWT_ConvertMode`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_convertmode) and [`SetReaderOptions()`](/_articles/info/api/Addon_PDF.md#setreaderoptions) for details. ## Loading Files from the Selection UI The most common file loading method is by prompting the user with a file selection interface. DWT brings up this interface slightly differently for desktop and mobile platforms. On desktop browsers, DWT brings up the file selection interface, where users can select files on the local file system, as well as accessible files on the local network. On mobile browsers, the prompt allows users to select files from the local file system, select images from the local file system, or to take a picture. This is done with either the [`LoadImageEx()`](/_articles/info/api/WebTwain_IO.md#loadimageex) or [`LoadImage()`](/_articles/info/api/WebTwain_IO.md#loadimage) API. Here we demonstrate with `LoadImageEx()`: ### Sample Code ```html
``` APIs used: - [`RegisterEvent()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#registerevent) - [`OnWebTwainReady`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainready) - [`GetWebTwain()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain) - [`LoadImageEx()`](/_articles/info/api/WebTwain_IO.md#loadimageex) - [`IfShowFileDialog`](/_articles/info/api/WebTwain_IO.md#ifshowfiledialog) - [`Dynamsoft.DWT.EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype) - [`Dynamsoft.DWT.EnumDWT_ConvertMode`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_convertmode) - [`SetReaderOptions()`](/_articles/info/api/Addon_PDF.md#setreaderoptions) ### Explanation We first enable file selection dialogue with the [`IfShowFileDialog`](/_articles/info/api/WebTwain_IO.md#ifshowfiledialog) property. Then, the call to [`LoadImageEx()`](/_articles/info/api/WebTwain_IO.md#loadimageex) can omit an explicit file path (the `""`). The second argument allows all DWT-supported file formats to appear in the selection dialogue. [`LoadImage()`](/_articles/info/api/WebTwain_IO.md#loadimage), works similarly to `LoadImageEx()`, but it does not specify an image file format: ```javascript DWTObject.LoadImage( "", // File path empty while file selection dialog is enabled function () { console.log("Successfully loaded file"); }, function (errorCode, errorString) { console.log(errorString) } ) ``` ## Loading Files with File Paths > This feature is only supported on desktop. When the web application only needs to load a particular file, DWT can retrieve it using a file path directly, and skip the file selection dialog altogether with the `IfShowFileDialog` property found in the `WebTwain` instance: > Note: This example uses [`LoadImage()`](/_articles/info/api/WebTwain_IO.md#loadimage), but [`LoadImageEx()`](/_articles/info/api/WebTwain_IO.md#loadimageex) works similarly. ### Sample Code ```html
``` APIs used: - [`RegisterEvent()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#registerevent) - [`OnWebTwainReady`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainready) - [`GetWebTwain()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain) - [`LoadImage()`](/_articles/info/api/WebTwain_IO.md#loadimage) - [`IfShowFileDialog`](/_articles/info/api/WebTwain_IO.md#ifshowfiledialog) - [`Dynamsoft.DWT.EnumDWT_ConvertMode`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_convertmode) - [`SetReaderOptions()`](/_articles/info/api/Addon_PDF.md#setreaderoptions) ## Loading Files from Binary Blobs The [`LoadImageFromBinary()`](/_articles/info/api/WebTwain_IO.md#loadimagefrombinary) is used to load images from Blobs. This sample converts a sample to a Blob with another API ([`ConvertToBlob()`](/_articles/info/api/WebTwain_IO.md#converttoblob)) in order to demonstrate loading Blobs - `ConvertToBlob()` is not necessary as a part of the normal workflow. ### Sample Code ```html
``` APIs used: - [`RegisterEvent()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#registerevent) - [`OnWebTwainReady`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainready) - [`GetWebTwain()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain) - [`LoadImageEx()`](/_articles/info/api/WebTwain_IO.md#loadimageex) - [`IfShowFileDialog`](/_articles/info/api/WebTwain_IO.md#ifshowfiledialog) - [`Dynamsoft.DWT.EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype) - [`LoadImageFromBinary()`](/_articles/info/api/WebTwain_IO.md#loadimagefrombinary) - [`ConvertToBlob()`](/_articles/info/api/WebTwain_IO.md#converttoblob) - [`Dynamsoft.DWT.EnumDWT_ConvertMode`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_convertmode) - [`SetReaderOptions()`](/_articles/info/api/Addon_PDF.md#setreaderoptions) ### Explanation This sample code loads an image from a file, and then converts that image into a Blob. This step is done to get an image Blob on hand. `LoadImageFromBinary()` can then load that Blob back into the `WebTwain` instance, which results in a second copy of the image. [`ConvertToBlob()`](/_articles/info/api/WebTwain_IO.md#converttoblob) must specify a particular target image format - in this case PNG. ## Loading Files from Base64 Strings Base64 strings handle similarly to Blobs, but with [`LoadImageFromBase64Binary()`](/_articles/info/api/WebTwain_IO.md#loadimagefrombase64binary). Once again, we use an extra API ([`ConvertToBase64()`](/_articles/info/api/WebTwain_IO.md#convertobase64)) for demonstration purposes. ### Sample Code ```html
``` APIs used: - [`RegisterEvent()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#registerevent) - [`OnWebTwainReady`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainready) - [`GetWebTwain()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain) - [`LoadImage()`](/_articles/info/api/WebTwain_IO.md#loadimage) - [`IfShowFileDialog`](/_articles/info/api/WebTwain_IO.md#ifshowfiledialog) - [`Dynamsoft.DWT.EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype) - [`LoadImageFromBase64Binary()`](/_articles/info/api/WebTwain_IO.md#loadimagefrombase64binary) - [`ConvertToBase64()`](/_articles/info/api/WebTwain_IO.md#convertobase64) - [`Base64Result`](/_articles/info/api/interfaces.md#base64result) - [`Dynamsoft.DWT.EnumDWT_ConvertMode`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_convertmode) - [`SetReaderOptions()`](/_articles/info/api/Addon_PDF.md#setreaderoptions) ### Explanation This sample code loads an image from a file, and then converts that image into a `Base64Result`. This step is done to get a Base64 string on hand. `LoadImageFromBase64Binary()` can then load that `Base64Result` back into the `WebTwain` instance, which results in a second copy of the image. ## Downloading Files over HTTP(S) DWT supports files downloads over HTTP to access files over a network, either with a path to the file using the `HTTPDownload()` API, or a path to a server-side script that returns the file, with the `HTTPDownloadEx()` API. The following sample uses both to retrieve an image hosted by a local web server. ### Sample Code ```html
``` ### Sample Server Script Code ```C# <%@ Page Language="C#"%> <% try { String fileName = "sample.tif"; String filePath = Server.MapPath(".") + "\\files\\" + fileName; System.IO.FileInfo fileInfo = new System.IO.FileInfo(filePath); Response.ClearContent(); Response.ClearHeaders(); Response.Clear(); Response.Buffer = true; String fileNameEncode; fileNameEncode = HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8); fileNameEncode = fileNameEncode.Replace("+", "%20"); String appendedheader = "attachment;filename=" + fileNameEncode; Response.AppendHeader("Content-Disposition", appendedheader); Response.WriteFile(fileInfo.FullName); } catch (Exception) { } %> ``` APIs used: - [`RegisterEvent()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#registerevent) - [`OnWebTwainReady`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainready) - [`GetWebTwain()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain) - [`Dynamsoft.DWT.EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype) - [`HTTPDownload()`](/_articles/info/api/WebTwain_IO.md#httpdownload) - [`HTTPDownloadEx()`](/_articles/info/api/WebTwain_IO.md#httpdownloadEx) - [`Dynamsoft.DWT.EnumDWT_ConvertMode`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_convertmode) - [`SetReaderOptions()`](/_articles/info/api/Addon_PDF.md#setreaderoptions) ### Explanation In the example above, the two APIs request the same file at the same location on the web server. [`HTTPDownload()`](/_articles/info/api/WebTwain_IO.md#httpdownload) requests it using the file path itself. [`HTTPDownloadEx()`](/_articles/info/api/WebTwain_IO.md#httpdownloadEx) is more flexible, and as well as direct file paths, it can also be pointed to any server-side script that returns a file. The sample server script we provide happens to be in C#, but this is not a language requirement. Note that `HTTPDownload()` and `HTTPDownloadEx()` support **HTTPS**. This requires the property [`IfSSL`](/_articles/info/api/WebTwain_IO.md#ifssl) to be set to `true` - please check our API references on [`HTTPDownloadEx()`](/_articles/info/api/WebTwain_IO.md#httpdownloadEx) for more information. ## Loading Files over FTP > This feature is only supported on desktop. DWT can load files retrieved over FTP, and also handle authentication when needed. The sample found below demonstrates loading a file hosted on an FTP server (requiring user authentication). ### Sample Code ```html
``` APIs used: - [`RegisterEvent()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#registerevent) - [`OnWebTwainReady`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainready) - [`GetWebTwain()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain) - [`LoadImageEx()`](/_articles/info/api/WebTwain_IO.md#loadimageex) - [`IfShowFileDialog`](/_articles/info/api/WebTwain_IO.md#ifshowfiledialog) - [`Dynamsoft.DWT.EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype) - [`FTPDownloadEx()`](/_articles/info/api/WebTwain_IO.md#ftpdownloadex) - [`FTPPort`](/_articles/info/api/WebTwain_IO.md#ftpport) - [`FTPUserName`](/_articles/info/api/interfaces.md#ftpusername) - [`FTPPassword`](/_articles/info/api/interfaces.md#ftppassword) - [`Dynamsoft.DWT.EnumDWT_ConvertMode`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_convertmode) - [`SetReaderOptions()`](/_articles/info/api/Addon_PDF.md#setreaderoptions) ## Drag/Dropping Files > This feature is only supported on desktop. Drag/drop is built into the desktop version of the `WebTwain` `Viewer`. Users can drag and drop file icons into the viewer to load files. This feature can be turned on or off with the property [`Viewer.acceptDrop`](/_articles/info/api/WebTwain_Viewer.md#acceptdrop), e.g. `DWTObject.Viewer.acceptDrop = false` prevents the `Viewer` from accepting dropped images. This property is `true` by default. ## Loading Files from the System Clipboard > This feature is only supported on desktop. This following sample loads the most recent file from the system clipboard with the [`LoadDibFromClipboard()`](/_articles/info/api/WebTwain_IO.md#loaddibfromclipboard) API. Note that this API only supports DIB files. ### Sample Code ```html
``` APIs used: - [`RegisterEvent()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#registerevent) - [`OnWebTwainReady`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainready) - [`GetWebTwain()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain) - [`LoadDibFromClipboard()`](/_articles/info/api/WebTwain_IO.md#loaddibfromclipboard) - [`Dynamsoft.DWT.EnumDWT_ConvertMode`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_convertmode) - [`SetReaderOptions()`](/_articles/info/api/Addon_PDF.md#setreaderoptions) - [`CopyToClipboard()`](/_articles/info/api/WebTwain_Edit.md#copytoclipboard) - [`CurrentImageIndexInBuffer`](/_articles/info/api/WebTwain_Buffer.md#currentimageindexinbuffer) ### Explanation In addition to [`LoadDibFromClipboard()`](/_articles/info/api/WebTwain_IO.md#loaddibfromclipboard), we also use [`CopyToClipboard()`](/_articles/info/api/WebTwain_Edit.md#copytoclipboard) to copy the displayed image to the clipboard. The user can then click the paste button to load that image back in. Note that `CopyToClipboard()` does not accept success/failure callbacks.
--- title: Dynamic Web TWAIN SDK Extended Usage Guide description: Extended Usage source_url: html: https://www.dynamsoft.com/web-twain/docs/extended-usage/index.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/extended-usage/index.md --- # Extended Usage Guide This set of guides builds on the fundamental features covered in the standard usage guide. Here we cover topics such as customizing features explained previously (user interface), extending existing features (various `WebTwain` instantiation methods), and exploring advanced features (using the `FileUploader`), and more. ### Table of Contents - [Advanced DWT Initialization](/_articles/extended-usage/advanced-initialization.md) - [Loading Documents from Files](/_articles/extended-usage/file-import.md) - [Configuring System Messages](/_articles/extended-usage/system-message-configuration.md) - [Set Up the Dynamic Web TWAIN Service](/_articles/extended-usage/dynamsoft-service-configuration.md) - [UI Customization](/_articles/extended-usage/ui-customization.md) - [Using the DWT RESTful API](/_articles/extended-usage/restful-api.md) - [Barcode Recognition](/_articles/extended-usage/barcode-processing.md) - [OCR](./ocr.md) - [PDF Handling](/_articles/extended-usage/pdf-processing.md) - [Buffer Caching](/_articles/extended-usage/buffer-caching.md) - [Remote Scan](https://www.dynamsoft.com/remote-scan/docs/introduction/) --- title: Dynamic Web TWAIN SDK Features - OCR description: Dynamic Web TWAIN SDK Documentation OCR Page source_url: html: https://www.dynamsoft.com/web-twain/docs/extended-usage/ocr.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/extended-usage/ocr.md --- # OCR Dynamic Web TWAIN provides an OCR add-on to extract text from scanned images. It utilizes the latest deep learning techniques and delivers high accuracy. All processing occurs locally on end-user devices, with no data uploaded to cloud servers. Read on to learn about how to use it. ## Requirements * Windows 10 versions >= 1809 and all versions of Windows 11 * A license with the OCR module ([contact support to get a 30-day trial license](mailto:support@dynamsoft.com)) * [DynamicWebTWAINOCRResources.zip](https://download2.dynamsoft.com/dwt/DynamicWebTWAINOCRResources.zip) ## Online Demo You can visit the [online demo](https://demo.dynamsoft.com/Samples/dwt/OCR/index.html) ([source code](https://download2.dynamsoft.com/Samples/DWT/Scan-Documents-and-Do-OCR.zip)) to try it. ## How to Use ### Step One - Install the OCR Package Download [DynamicWebTWAINOCRResources.zip](https://download2.dynamsoft.com/dwt/DynamicWebTWAINOCRResources.zip), unzip it and run `Install.cmd` inside the `DynamicWebTWAINOCRPack.zip` file as admin to install the OCR package. It will copy an `ocr` folder to Dynamic Web TWAIN Service's [installation folder](/_articles/extended-usage/dynamsoft-service-configuration.md#installation-folder). The `ocr` folder contains the runtime and model files that are required to perform on-device OCR. > [!NOTE] > * You need to [install Dynamic Web TWAIN Service](/_articles/extended-usage/dynamsoft-service-configuration.md#installation-of-dynamic-web-twain-service) beforehand. > * Since only Windows is supported for now, you have to do this on a Windows client for testing. ### Step Two - Write a Basic Document Scanning Page Create an HTML file with the following content. It can scan documents from scanners as well as loading local images. ```html Dynamic Web TWAIN - OCR Demo
Input:
``` PS: You can find where the resources files are in this [FAQ](/_articles/faq/what-are-the-resources-files.md). ### Step Three - Include the Add-on Reference the add-on's JavaScript with the following code. You can find the file in `DynamicWebTWAINOCRResources.zip`. > If you are using the [npm package](https://www.npmjs.com/package/dwt), the OCR is already included in the main JavaScript file (`dynamsoft.webtwain.min.js` or `dynamsoft.webtwain.min.mjs`), which means you can skip this step. ```html ``` Then, you can run the following to check if it is installed correctly: ```js 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; } ``` APIs used: [`GetInstalledOCRInfo()`](/_articles/info/api/Addon_OCR.md#getinstalledocrinfo) ### Step Four - Detect Page Orientation This is an optional step. If the scanned document is rotated, we can detect its orientation and rotate it. ```js async function CorrectOrientationForOne(index){ let result = await DWTObject.Addon.OCRKit.DetectPageOrientation(index); if (result.angle != 0) { DWTObject.Rotate(index,-result.angle,true); } } ``` APIs used: - [`DetectPageOrientation()`](/_articles/info/api/Addon_OCR.md#detectpageorientation) - [`Rotate()`](/_articles/info/api/WebTwain_Edit.md#rotate) ### Step Five - Recognize Text Recognize the text in one image and print it in a `pre` element. ```html


```

APIs used:

[`Recognize()`](/_articles/info/api/Addon_OCR.md#recognize)

### Step Six - Save as PDF

After recognition, we can save the OCR results and images as a PDF file. It will add an invisible text layer above the original content so that the text becomes selectable and searchable.

```js
let indicesOfAll = DWTObject.SelectAllImages();
await DWTObject.Addon.OCRKit.SaveToPath(indicesOfAll,Dynamsoft.DWT.EnumDWT_OCRKitOutputFormat.PDF_WITH_EXTRA_TEXTLAYER,"output.pdf");
```

APIs used:

[`SaveToPath()`](/_articles/info/api/Addon_OCR.md#savetopath)

### Step Seven - Review the Complete Code

Here is the complete code of the demo.

```html



  Dynamic Web TWAIN - OCR Demo
  
  
  
  
  


  
Input:
Processing:
Output:

  
``` This complete code is different from the [online demo](#online-demo)'s code, which supports regional OCR. You can find the code for the online demo [here](https://download2.dynamsoft.com/Samples/DWT/Scan-Documents-and-Do-OCR.zip). ## FAQ ### What Languages are Supported? The OCR add-on supports multiple languages including English, French, Spanish, German, Italian, and Portuguese. Contact [support](mailto:support@dynamsoft.com) if you need to OCR documents in other languages. ### What are the Hardware Requirements? The OCR add-on requires a 64-bit operating system and at least 4GB of RAM for optimal performance. ### Can I Limit the Region for OCR? Yes. You can specify which regions for OCR using the `rects` option of the [`recognize()`](/_articles/info/api/Addon_OCR.md#recognize) function. ### Will My Document be Uploaded to a Remote Server? No. The OCR process happens locally on your machine. No data is sent to any remote servers. Also, we do not collect data for training AI. ### What is Searchable PDF? A searchable PDF is a type of PDF file where the text content is recognized by a computer. This means you can use the Find function (usually Ctrl+F or Cmd+F) to search for specific words or phrases within the document, just like you would on a webpage or in a Word document. The OCR add-on supports two kinds of searchable PDF output. * Plain-text PDF, which will only keep a text layer of the OCRed text for each page. * Extra-text-layer PDF, which will add an extra invisible text layer of the OCRed text above each page. ### What are OCR Basic and OCR Pro? OCR Basic and OCR Pro are previous OCR add-ons, which are deprecated in v16.2. But they are still usable in the latest version. To differentiate from previous versions, the new OCR added since v19.3 uses `OCRKit` as the namespace. ### Why I Cannot Load Saved PDF Files The searchable PDF saved has a text layer. You need to use [PDF Rasterizer](/_articles/info/api/Addon_PDF.md) to load it. A PDF Rasterizer license is required.
--- title: Dynamic Web TWAIN SDK Features - Handle PDF description: Dynamic Web TWAIN SDK Documentation Handle PDF Page source_url: html: https://www.dynamsoft.com/web-twain/docs/extended-usage/pdf-processing.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/extended-usage/pdf-processing.md --- # Processing PDFs In this next section, we will address all the input and output operations that allow the user to properly handle PDF files. ## Environment * Supported on [Desktop](/_articles/introduction/system-requirements.md). ## Including the PDF addon To include the PDF addon, simply add a reference to the corresponding JavaScript file, included in the [resources folder](/_articles/faq/what-are-the-resources-files.md). ``` html ``` > If you are using the [dwt package](https://www.npmjs.com/package/dwt), the pdf addon is already included in the main JavaScript file ( `dynamsoft.webtwain.min.js` or `dynamsoft.webtwain.min.mjs` ) which means you can skip this step. ## Input ### Open an image-only PDF file If the PDF file only has one image per page, it can load the file by extracting the images. Most of the PDF files are scanned documents. ### Open a PDF file with more than images If the PDF file is not pure image, we need to make use of the PDF Rasterizer (`PDFR` for short) to render the PDF first. > How PDFR works: As the name suggests, `PDFR` rasterizes a PDF file page by page much like a scanner. You set a resolution, and you get the resulting images in that resolution after the rasterization. The following code shows the basic usage ``` javascript var onSuccess = function() { console.log("Loaded a file successfully!"); }; var onFailure = function(errorCode, errorString) { console.log(errorString); }; DWTObject.IfShowFileDialog = true; // PDF Addon is used here to ensure text-based PDF support DWTObject.Addon.PDF.SetReaderOptions({ convertMode: Dynamsoft.DWT.EnumDWT_ConvertMode.CM_RENDERALL, renderOptions:{ renderAnnotations: true; } }); DWTObject.LoadImageEx("", Dynamsoft.DWT.EnumDWT_ImageType.IT_ALL, onSuccess, onFailure); ``` The method [`SetReaderOptions()`](/_articles/info/api/Addon_PDF.md#setreaderoptions) configures how a PDF will be rasterized when being loaded into Dynamic Web TWAIN. #### Other methods * [`GetReaderOptions()`](/_articles/info/api/Addon_PDF.md#getreaderoptions): This method returns the current [`ReaderOptions`](/_articles/info/api/interfaces.md#readeroptions). ## Output as PDF ### Save images as image-based PDFs `Dynamic Web TWAIN` can output one or multiple images in the buffer as image-based PDF file(s). This feature is built into the core module, and no addon is required as was covered in the [output](/_articles/general-usage/image-export/index.md) section. ### PDF save settings However, some advanced features are only possible with the help of the PDF addon. At present, that means configuring the resulting file(s) with the API [ `Write.Setup()` ](/_articles/info/api/Addon_PDF.md#writesetup) as shown below ``` javascript DWTObject.Addon.PDF.Write.Setup({ author: "Dynamsoft-Support-Team", compression: Dynamsoft.DWT.EnumDWT_PDFCompressionType.PDF_JP2000, pageType:Dynamsoft.DWT.EnumPDF_Page_A4, creator: "DWT", creationDate: "D:20200930", keyWords: "TWAIN, DWT, Dynamsoft", modifiedDate: "D:20200930", producer: "Dynamsoft Corporation", subject: "Demoing File", title: "Sample PDF Made by DWT", version: 1.5, quality: 80 }); DWTObject.IfShowFileDialog = true; DWTObject.SaveAllAsPDF(' ', function() {}, function() {}) ``` From version 18.5, `Dynamic Web TWAIN` supports the generation of encrypted PDF files. For example, ``` javascript DWTObject.Addon.PDF.Write.Setup({ author: "Dynamsoft-Support-Team", compression: Dynamsoft.DWT.EnumDWT_PDFCompressionType.PDF_JP2000, pageType:Dynamsoft.DWT.EnumPDF_Page_A4, creator: "DWT", creationDate: "D:20200930", keyWords: "TWAIN, DWT, Dynamsoft", modifiedDate: "D:20200930", producer: "Dynamsoft Corporation", subject: "Demoing File", title: "Sample PDF Made by DWT", version: 1.5, quality: 80, password: "dwtpassword" }); DWTObject.IfShowFileDialog = true; DWTObject.SaveAllAsPDF(' ', function() {}, function() {}) ``` When you set a password prior to generating a PDF file, that password becomes necessary each time you attempt to open the file thereafter. The password does not restrict the usage permissions of the PDF. The encryption algorithm utilized is AES256, ensuring robust security measures. Note: Only the core module license is required to use this method. ## Append Pages to a PDF If you need to append a scanned document to a PDF file and keep the rest pages unmodified. You can use the following code to read a PDF file by setting the `preserveUnmodifiedOnSave` property to `true`. ```js DWTObject.Addon.PDF.SetReaderOptions({ convertMode: Dynamsoft.DWT.EnumDWT_ConvertMode.CM_RENDERALL, preserveUnmodifiedOnSave: true, //only available for v19.0+ renderOptions:{ renderAnnotations: true //enable this to keep annotations } }); ``` Then, it will keep the unmodified pages in the PDF file instead of converting them to images when saving a new PDF file with the scanned documents. ## PDF/A PDF/A is a version of PDF specialized for use in the archiving and long-term preservation of electronic documents. For example, it does not allow using external fonts, which will change the appearance if opening it on another device. Starting from Web TWAIN v19.3, it can save PDF as PDF/A-1b or PDF/A-2b by specifying `pdfaVersion` in [`PDFWSettings`](/_articles/info/api/interfaces.md#pdfwsettings). Here is the code to do this: ```js DWTObject.Addon.PDF.Write.Setup({ pdfaVersion:"pdf/a-1b" }); DWTObject.IfShowFileDialog = true; DWTObject.SaveAllAsPDF(' ', function() {}, function() {}) ``` Both PDF/A-1b and PDF/A-2b are basic conformation level standards. PDF/A-1b is based on PDF version 1.4 and PDF/A-2b is based on PDF version 1.7. PDF/A-2b has the following new features compared to PDF/A-1b: * JPEG 2000 image compression. * support for transparency effects and layers. * embedding of OpenType fonts. * provisions for digital signatures in accordance with the PDF Advanced Electronic Signatures – PAdES standard. * the option of embedding PDF/A files to facilitate archiving of sets of documents with a single file. It is recommended to use PDF/A-2b because of the support for more features. Related FAQ: * [How can I generate PDF/A files?](/_articles/faq/generate-pdf-files.md) * [How can I load PDF/A files into the Dynamic Web TWAIN SDK?](/_articles/faq/load-pdf-files.md) --- title: Using the RESTful API description: RESTful API source_url: html: https://www.dynamsoft.com/web-twain/docs/extended-usage/restful-api.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/extended-usage/restful-api.md --- # Using the RESTful API By default, Dynamic Web TWAIN consists of the Dynamic Web TWAIN Service installed and running on a system, connected to a web application which integrates the Dynamic Web TWAIN SDK. To use DWT to access scanners on other platforms and using other programming languages, you can use the [DWT Service RESTful API](/_articles/info/api/restful.md). This allows desktop, mobile, and server-side applications to access the DWT Service installed on the scanner host (local or server) in a simple, stateless, and standardized manner. The RESTful API simply returns scanned documents as streams of image files to the client, and **does not use the DWT Viewer**. This is because **the RESTful API functions entirely using the DWT Service**, and is viewer-agnostic. You may choose to feed the scanned images to any viewer, including a DWT Viewer in your application that you instantiate separately, if desired. Here is a collection of tutorials on creating sample applications that use the DWT RESTful API in various platforms and languages. - [.NET](https://github.com/Dynamsoft/Dynamic-Web-TWAIN-REST-dotnet) - [Node.js](https://www.dynamsoft.com/codepool/rest-api-node-document-scanning.html) - [Flutter](https://www.dynamsoft.com/codepool/flutter-twain-scanner-digitize-document.html) - [Java](https://www.dynamsoft.com/codepool/java-twain-document-scanning.html) - [Python](https://www.dynamsoft.com/codepool/python-twain-wia-sane-document-scanner.html) --- title: Configuring System Messages description: Configuring System Messages source_url: html: https://www.dynamsoft.com/web-twain/docs/extended-usage/system-message-configuration.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/extended-usage/system-message-configuration.md --- # Configuring System Messages DWT provides various system messages during all parts of runtime. Some of these messages are errors which are useful for debugging/reporting purposes, such as indicating that the [Dynamic Web TWAIN Service](/_articles/faq/what-does-dynamsoft-service-do-on-end-user-machine.md) has not been installed on end user's system. Other messages provide information directly to the end user, such as labelling the image source selection prompt overlay (scanner selection). These system messages are configurable. Notably, we recommend changing these system messages for the purposes of translating the default English messages to other localizations. ## Configuring the `CustomizableDisplayInfo` Object Most system messages are configurable with the `Dynamsoft.DWT.CustomizableDisplayInfo` object, which may be modified within the **`dynamsoft.webtwain.config.js`** configuration resource file. This resource file has a commented-out definition of the object, which contains the default system messages. To alter the default messages, simply un-comment the object and change its properties: ```javascript Dynamsoft.DWT.CustomizableDisplayInfo = { errorMessages: { // launch ERR_MODULE_NOT_INSTALLED: "Error: The Dynamic Web TWAIN module is not installed.", ERR_BROWSER_NOT_SUPPORT: "Error: This browser is currently not supported.", ERR_CreateID_MustNotInContainers: "Error: Duplicate ID detected for creating Dynamic Web TWAIN objects, please check and modify.", ERR_CreateID_NotContainer: "Error: The ID of the DIV for creating the new DWT object is invalid.", ERR_DWT_NOT_DOWNLOADED: "Error: Failed to download the Dynamic Web TWAIN module.", // image view limitReachedForZoomIn: "Error: You have reached the limit for zooming in", limitReachedForZoomOut: "Error: You have reached the limit for zooming out", // image editor insufficientParas: "Error: Not enough parameters.", invalidAngle: "Error: The angle you entered is invalid.", invalidHeightOrWidth: "Error: The height or width you entered is invalid.", imageNotChanged: "Error: You have not changed the current image.", }, // launch generalMessages: { checkingDWTVersion: "Checking WebTwain version ...", updatingDService: "Dynamic Web TWAIN Service is updating ...", downloadingDWTModule: "Downloading the Dynamic Web TWAIN module.", refreshNeeded: "Please REFRESH your browser.", downloadNeeded: "Please download and install the Dynamic Web TWAIN.", DWTmoduleLoaded: "The Dynamic Web TWAIN module is loaded.", }, customProgressText: { // html5 event upload: "uploading...", download: "Downloading...", load: "Loading...", decode: "Decoding...", decodeTIFF: "Decoding tiff...", decodePDF: "Decoding pdf...", encode: "Encoding...", encodeTIFF: "Encoding tiff...", encodePDF: "Encoding pdf...", // image control canvasLoading: "Loading ...", }, // image editor buttons: { titles: { previous: "Previous Image", next: "Next Image", print: "Print Image", scan: "Acquire new Image(s)", load: "Load local Image(s)", 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", }, }, 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!", ], }, }; ``` The messages are grouped into categories: - `errorMessages` mainly contains loading/instantiation error messages. - `customProgressText` are loading messages that appear during processes such as data IO and image encoding/decoding. - `buttons` `Viewer` editor/DDV element tooltip labels? - `dialogText` provides confirmation messages and the source selection message to the user. ## Configuring the `_show_install_dialog()` Function The `Dynamsoft._show_install_dialog()` function defined in the `dynamsoft.webtwain.install.js` resource file generates the [Dynamic Web TWAIN Service](/_articles/faq/what-does-dynamsoft-service-do-on-end-user-machine.md) installation dialog box, pictured here: ![install dialog](/assets/imgs/Initialization-1.png) As the dialog box contains instructions for installing the Dynamic Web TWAIN Service, consider altering the message strings for localization purposes. Generally we discourage directly modifying the resource files, but this dialogue function contains styling and messaging which may be tailored the web application itself. Try not to alter the platform detection logic too greatly, as this may interfere with the Dynamic Web TWAIN Service installation procedure. Please contact the [support team](/_articles/about/getsupport.md) for any further questions. --- title: Dynamic Web TWAIN SDK Features - UI Elements description: Dynamic Web TWAIN SDK Documentation UI Page source_url: html: https://www.dynamsoft.com/web-twain/docs/extended-usage/ui-customization.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/extended-usage/ui-customization.md --- # UI Elements In this section, we'll explore the UI Elements that are built into the `Dynamic Web TWAIN` library for user interactions. Generally speaking, most UI elements are configured in the file **dynamsoft.webtwain.install.js**. This file is already referenced inside the **dynamsoft.webtwain.initiate.js**. ## Installation Dialog ![UI 1](/assets/imgs/Initialization-1.png) This dialog comes up when using `Dynamic Web TWAIN` scanner module under one of the following conditions: * The Dynamic Web TWAIN Service is not installed * The Dynamic Web TWAIN Service is not running * A failure to connect to the Dynamic Web TWAIN Service If needing to disable the default dialog or come up with your own install dialog, you can make changes to `Dynamsoft._show_install_dialog()` in the **dynamsoft.webtwain.install.js** file. ## Indicators ### Loading bar and backdrop ![UI 2](/assets/imgs/UI-8.png) This loading bar and backdrop shows up when creating a `WebTwain` instance or when you try to scan. The functions `Dynamsoft.DWT.OnWebTwainPreExecute()` and `Dynamsoft.DWT.OnWebTwainPostExecute()` are called before and after the process. You can customize the behavior like this ``` javascript Dynamsoft.DWT.OnWebTwainPreExecute = function() { // Show your own progress indicator console.log('An operation starts!'); }; Dynamsoft.DWT.OnWebTwainPostExecute = function() { // Hide the progress indicator console.log('An operation ends!'); }; ``` On the other hand, you can also call the functions `Dynamsoft.DWT.OnWebTwainPreExecute()` and `Dynamsoft.DWT.OnWebTwainPostExecute()` to show and hide the loader bar and backdrop when you need it in your own workflow. If you just want to change the loading bar, you can use the `Dynamsoft.DWT.CustomizableDisplayInfo.loaderBarSource` . ### Progress bar When `Dynamic Web TWAIN` performs a time-consuming task, it'll show a progress bar. This progress bar is either like this ![UI-3](/assets/imgs/UI-7.png) or like this (with a `Cancel` button) ![UI-4](/assets/imgs/UI-9.png) The 1st bar shows up when saving, loading or converting and can be hidden by setting [ `IfShowProgressBar` ](/_articles/info/api/WebTwain_IO.md#ifshowprogressbar) to `false` . Both bars show up when uploading or downloading and can be hidden by setting [ `IfShowCancelDialogWhenImageTransfer` ](/_articles/info/api/WebTwain_IO.md#ifshowcanceldialogwhenimagetransfer) to `false` . For uploading or downloading, you can also build your own progress bar with the help of the built-in event [ `OnInternetTransferPercentage` ](/_articles/info/api/WebTwain_IO.md#oninternettransferpercentage). ``` javascript DWTObject.RegisterEvent('OnInternetTransferPercentage', function(percentage) { console.log(percentage); // Use the percentage to build your own progress bar } ); ``` ## Language ### Error Messages `Dynamic Web TWAIN` has many built-in error messages as shown [here](/_articles/info/api/appendix.md#error-list). Each `ErrorString` has its own `ErrorCode` . To change the language of the message, you can read the `ErrorCode` and output the error string you have customized. For example ``` javascript if (DWTObject.ErrorCode === -2359) { // ErrorString "The index is out of range." // To Spanish console.log("El índice está fuera de rango.") } ``` --- title: Only 24-bit true color bmp and 8-bit gray-scaled images are supported for JPEG compression description: Only 24-bit true color bmp and 8-bit gray-scaled images are supported for JPEG compression source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/JPEG-compression.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/JPEG-compression.md --- # Error Troubleshooting ## Only 24-bit true color bmp and 8-bit gray-scaled images are supported for JPEG compression ### Symptom When you save or upload an image as a JPEG file, you may receive the error. ### Cause You are saving a black and white image as a JPEG file but JPEG standard only allows the compression of grayscale and RGB images. ### Resolution Make sure the pixel type of the image in the buffer is Gray or RGB. If it is not, you can either save it in another format or convert the image to grayscale using the method [ConvertToGrayScale()](/_articles/info/api/WebTwain_Edit.md#converttograyscale). ```javascript if ( /*If save in JPEG*/ ) { //Check whether the current image is B&W //1 is B&W, 8 is Gray, 24 is RGB if (DWTObject.GetImageBitDepth(DWTObject.CurrentImageIndexInBuffer) == 1) //If so, convert the image to Gray DWTObject.ConvertToGrayScale(DWTObject.CurrentImageIndexInBuffer); //Save image in JPEG DWTObject.SaveAsJPEG("DynamicWebTWAIN.jpg", DWTObject.CurrentImageIndexInBuffer); } ``` --- title: Can I install Dynamic Web TWAIN Service silently? description: Can I install Dynamic Web TWAIN Service silently? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/can-i-install-dynamsoft-service-silently.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/can-i-install-dynamsoft-service-silently.md --- View all FAQs about [Project Deployment and End-user Installation]( https://www.dynamsoft.com/web-twain/docs/faq/#project-deployment-and-end-user-installation) # Can I install Dynamic Web TWAIN Service silently? Yes. You can install Dynamic Web TWAIN Service silently by running the appropriate command for your version and operating system.
- [v19.0+](#19plus) - [Versions below 19.0](#19min)
* Windows Run Command Prompt as administrator, then execute: ``` shell msiexec /i "/path/to/DynamicWebTWAINServiceSetup.msi" /qn ``` * macOS ``` shell // Install sudo installer -pkg /path/to/DynamicWebTWAINServiceSetup.pkg -target /Applications // Stop service sudo launchctl unload /Library/LaunchAgents/com.dynamsoft.dynamicwebtwainservicex64.plist // Start service launchctl load /Library/LaunchAgents/com.dynamsoft.dynamicwebtwainservicex64.plist ``` * Linux ``` shell sudo dpkg -i /path/to/DynamicWebTWAINServiceSetup.deb ``` or ``` shell sudo rpm -i path/to/DynamicWebTWAINServiceSetup.rpm ```
* Windows Run Command Prompt as administrator, then execute: ``` shell msiexec /i "/path/to/DynamsoftServiceSetup.msi" /qn ``` * macOS ``` shell // Install sudo installer -pkg /path/to/DynamsoftServiceSetup.pkg -target /Applications // Stop service sudo launchctl unload /Library/LaunchAgents/com.dynamsoft.dynamsoftservicex64.plist // Start service launchctl load /Library/LaunchAgents/com.dynamsoft.dynamsoftservicex64.plist ``` * Linux ``` shell sudo dpkg -i /path/to/DynamsoftServiceSetup.deb ``` or ``` shell sudo rpm -i path/to/DynamsoftServiceSetup.rpm ```
In a controlled environment, you can distribute Dynamic Web TWAIN Service to all client machines at once, as you would with other software. [Group Policy](https://docs.microsoft.com/en-us/troubleshoot/windows-server/group-policy/use-group-policy-to-install-software) is one option for Windows deployments.
--- title: How can I send additional form fields with images to my server or database? description: How can I send additional form fields with images to my server or database? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/additional-form-fields.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/additional-form-fields.md --- # Document Saving ## How can I send additional form fields with images to my server or database? You can use [SetHTTPFormField](/_articles/info/api/WebTwain_IO.md#sethttpformfield){:target="_blank"} to set meta data as form fields and use [HTTPUpload](/_articles/info/api/WebTwain_IO.md#httpupload){:target="_blank"} to send it to the server side with the scanned document. ```javascript // Clear old fields before adding new ones DWTObject.ClearAllHTTPFormField(); DWTObject.SetHTTPFormField("FileType", "Insurance Doc"); ``` You can check out this demo project for sending additional form fields when uploading the scanned document. [SetHTTPFormField](/_articles/info/api/WebTwain_IO.md#sethttpformfield){:target="_blank"} can also be used to send image data in base64 or BLOB to the server side. By design, the method [HTTPUpload()](/_articles/info/api/WebTwain_IO.md#httpupload){:target="_blank"} only contains one file. But as it essentially sends an HTTP form to the server, you can attach multiple files in that form using the methods [ConvertToBlob()](/_articles/info/api/WebTwain_IO.md#converttoblob){:target="_blank"} and [SetHTTPFormField()](/_articles/info/api/WebTwain_IO.md#sethttpformfield){:target="_blank"} . Check out the following snippet on how it is done. NOTE that the method [HTTPUpload()](/_articles/info/api/WebTwain_IO.md#httpupload){:target="_blank"} only has 3 parameters as it doesn't need to specify a file anymore. ```javascript /** * Upload the images specified by their indices in the specified file type as separate files. * @param indices Specify the images * @param type Specify the file type */ function uploadSeparateFiles(indices, type) { var protocol = Dynamsoft.Lib.detect.ssl ? "https://" : "http://", port = window.location.port === "" ? 80 : window.location.port, actionPage = "/upload.aspx"; // path to the server-side script var url = protocol + window.location.hostname + ":" + port + actionPage; if (DWTObject) { var done = 0, count = indices.length; var toBlob = function (index) { var fieldName = "SampleFile_" + index; var fileName = fieldName + getExtension(type); DWTObject.ConvertToBlob( [index], type, function (result, _indices, type) { DWTObject.SetHTTPFormField(fieldName, result, fileName); done++; if (done === count) { DWTObject.HTTPUpload( url, function () { console.log("Success"); }, function (errCode, errString, responseStr) { console.log(errString); } ); } else { toBlob(indices[done]); } }, function (errorCode, errorString) { console.log(errorString); } ); }; toBlob(indices[done]); } } ``` --- title: Uncaught ReferenceError - DVS is not defined description: Uncaught ReferenceError - DVS is not defined source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/DVS-is-not-defined.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/DVS-is-not-defined.md --- # Error Troubleshooting ## Uncaught ReferenceError - DVS is not defined You may see this error if the Dynamic Web TWAIN resources are deployed in a custom manner. The error is thrown when one or more resources cannot be loaded when trying to load the Dynamic Web TWAIN environment. Please make sure the path to Resources folder is defined correctly and that you can find `\*.viewer.js` under the `{ResourcesPath}/src` folder. If `viewer.js` does not exist in the target directory, please verify that the Dynamic Web TWAIN resources are deployed correctly and all files have been deployed. Please refer to [Dynamic Web TWAIN Deployment - Server Deployment](/_articles/general-usage/server-deployment.md){:target="_blank"} for more details on server deployment --- title: HTTP process error description: HTTP process error source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/HTTP-process-error.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/HTTP-process-error.md --- # Error Troubleshooting ## HTTP process error ### Symptom When attempting to upload images using any of the HTTPUpload\*\*\* methods the upload fails and you receive this error. ### Cause 1. The write permission is not granted to the specified directory on the web server. 2. The action page is incorrect or returns something from the web server. 3. The port specified for uploading is incorrect. 4. The size of the images you are trying to upload is larger than the maximum allowed size set by the server. ### Solution 1. Make sure the users who are uploading have permission to write images to the specified directory on the web server. (For example, give "Write" permission to the Authenticated Users.) 2. Check the response string returned from the HTTP server to determine the cause of the HTTP process error. You can get this string by using the [HTTPPostResponseString](/_articles/info/api/WebTwain_IO.md#httppostresponsestring) property. 3. Set the port to the correct one using [HTTPPort](/_articles/info/api/WebTwain_IO.md#httpport). We recommend you get the Port and Server values this way: ```javascript var strHTTPServer = location.hostname; DWTObject.HTTPPort = location.port == "" ? 80 : location.port; ``` - If you have set [IfSSL](/_articles/info/api/WebTwain_IO.md#ifssl) to true, you must set a secure port for the HTTPPort property. For example, ```javascript DWTObject.IfSSL = true; DWTObject.HTTPPort = 443; ``` > For example: If the URL for the scan page is "http://localhost:3253/....", you should set the port to 3253. 4. Check the server-side configuration - Please reset the maximum transferable data size. If you are using `ASP.NET` , you can change the value in the following line in the `Web.Config` file. ```xml // In kilobytes ``` This line may also be required ```xml // In bytes ``` The following is an example config file ```xml ``` If you are using `PHP` , you can change the value in the following lines in the `php.ini` file and `web.config` file: - **php.ini** ```shell file_uploads = On ; Enable file uploads upload_max_filesize = 50M ; Max single file size for uploads post_max_size = 60M ; Max size for POST data (includes all fields and files) max_execution_time = 300 ; Max script execution time (in seconds) ``` - **web.config** ```xml ``` --- title: HTTP request error description: HTTP request error source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/HTTP-request-error.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/HTTP-request-error.md --- # Error Troubleshooting ## HTTP request error ### Symptom When attempting to upload images via HTTP Put the images fail to upload and this error is received. ### Cause - The problem may occur if write permission is not provided on the server. - If you use Tomcat, the value of the `readonly` property is `false` by default, in this case the HTTP Put operation is not allowed. ### Solution - Check the write permission of the server. - Start Internet Information Services (IIS). - Click Web Sites. - Right-click the specified work folder, select Properties. - Select the Write option at the Directory tab. - If you are using Tomcat, the `doPut()` will check to see if the `readonly` property has been changed to `false`. If it has not, the HTTP Put operation is not allowed. Please go to {Tomcat installation directory} -> conf -> web.xml, find the default servlet configuration (org.apache.catalina.servlets. DefaultServlet) and change the `readonly` property to `true` . ```xml readonly false ``` --- title: XMLHttpRequest cannot load XXX description: XMLHttpRequest cannot load XXX source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/XMLHttpRequest-cannot-load.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/XMLHttpRequest-cannot-load.md --- # Error Troubleshooting ## XMLHttpRequest cannot load XXX ### Symptom You get the error ```shell XMLHttpRequest cannot load xxxxx. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://xxxxxxx' is therefore not allowed access. ``` ### Cause You are uploading or downloading to/from a web server which is in a different domain than your current website and that web server doesn't allow accessing from a different domain. ### Solution Try uploading to the same domain or update the server-side configuration to allow cross-domain requests. If you are using IIS, you can refer to the following configuration. ```xml ``` > Note > > After updating the server configuration file, you'll need to restart the server (i.e. IIS). > > If you are downloading a file, you might need to clear the browser cache because a cached file will not be requested again from the server, thus still no 'Access-Control-Allow-Origin' header will be presented. > > If you need to send cookies/credentials (e.g., Windows Authentication), enable credentials via code: > > ```javascript > DWTObject.HTTPRequestswithCredentials = true; // adds withCredentials:true on upload requests > ``` --- title: Is the AcquireImage() method synchronous or asynchronous? description: Is the AcquireImage() method synchronous or asynchronous? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/acquireimage-sync-or-async.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/acquireimage-sync-or-async.md --- # Capture/Image Source ## Is the AcquireImage() method synchronous or asynchronous? [AcquireImage()](/_articles/info/api/WebTwain_Acquire.md#acquireimage){:target="_blank"} is an asynchronous method, regardless of whether it includes a callback function or not. --- title: Can the Dynamic Web TWAIN SDK automatically detect borders of the scanned document and crop it out? description: Can the Dynamic Web TWAIN SDK automatically detect borders of the scanned document and crop it out? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/automatically-detect-border.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/automatically-detect-border.md --- # Capture/Image Source ## Can the Dynamic Web TWAIN SDK automatically detect borders of the scanned document and crop it out? Yes, Dynamic Web TWAIN SDK can automatically detect borders of the scanned document if it is supported by the device and its driver. You can check whether your device supports this capability from its user manual. Please use [IfAutomaticBorderDetection](/_articles/info/api/WebTwain_Acquire.md#ifautomaticborderdetection){:target="_blank"} property to enable this functionality. > Note: Once enabled, the data source (scanner) will automatically detect the borders of the document so that no extra margins are scanned. --- title: Can the Dynamic Web TWAIN SDK automatically rotate upside-down pages during the document scanning process? description: Can the Dynamic Web TWAIN SDK automatically rotate upside-down pages during the document scanning process? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/automatically-rotate-upside-down-pages.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/automatically-rotate-upside-down-pages.md --- # Capture/Image Source ## Can the Dynamic Web TWAIN SDK automatically rotate upside-down pages during the document scanning process? Dynamic Web TWAIN does not auto-rotate pages by default, but you can rotate images in code using the API covered in [this example](/_articles/general-usage/image-processing/image-editing.md#example---rotating-images){:target="_blank"}. If you have the OCR Add-on (v19.3+), you can call [`DetectPageOrientation()`](/_articles/info/api/Addon_OCR.md#detectpageorientation){:target="_blank"} to detect the page orientation from recognized text and use that result to decide how to rotate. Some scanners also offer an AutoDeskew/AutoRotate capability that runs on the device. If your scanner supports it, enable that option (see [our de-skew guidance](/_articles/faq/support-image-deskew.md) for scanner-side setup); otherwise, use the rotation API noted above based on your own detection logic. --- title: Can I add annotation to an image (e.g. add watermark or text)? description: Can I add annotation to an image (e.g. add watermark or text)? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/add-annotation-to-image.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/add-annotation-to-image.md --- # Image Editing ## Can I add annotation to an image (e.g. add watermark or text)? In 2023, Dynamsoft introduced Dynamsoft Document Viewer, a feature-rich web-based document viewer that supports document annotation. When used in conjunction with Dynamic Web TWAIN, it enables users to annotate scanned documents seamlessly. For more information, please refer to: [Dynamic Web TWAIN with Annotations](https://www.dynamsoft.com/web-twain/docs/faq/dwt-with-annotation.html). --- title: How to run Dynamic Web TWAIN ActiveX in Microsoft Edge Internet Explorer (IE) mode description: How to run Dynamic Web TWAIN ActiveX in Microsoft Edge Internet Explorer (IE) mode source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/activeX-in-Edge-IE-mode.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/activeX-in-Edge-IE-mode.md --- View all FAQs about [Project Deployment and End-user Installation]( https://www.dynamsoft.com/web-twain/docs/faq/#project-deployment-and-end-user-installation) # How to run Dynamic Web TWAIN ActiveX in Microsoft Edge Internet Explorer (IE) mode > ActiveX support was removed starting in Dynamic Web TWAIN v19. This article is archived for customers running versions earlier than 19. For supported browsers in v19 and later, please migrate to the HTML5 edition. Microsoft is retiring Internet Explorer 11 on June 15, 2022. To support Dynamic Web TWAIN ActiveX, please configure IE mode in Edge following the steps below. For better browser compatibility, we strongly recommend [updating your web application with our HTML5 edition](/_articles/indepth/development/activex.md#move-away-from-activex){:target="_blank"}. ### Step by step instructions to configure Microsoft Edge IE mode 1. Update Edge Default Browser settings per the screenshot: ![IE Mode 1](/assets/imgs/ieMode-1.png) 2. Download and install Enterprise Mode Site List Manager to add and export a site list to a XML file. ![IE Mode 2](/assets/imgs/ieMode-2.png) 3. Turn on Enterprise Mode using Group Policy 4. Run the following command to force the update of the group policy ``` shell `gpupdate /force` ``` 5. Go to edge://compat/iediagnostic to open the Microsoft Edge Compatibility tab. Check under the Group policy settings to make sure the policy is applied. 6. Run your web application. 7. You can debug the content of an IE mode tab by using IEChooser to open Internet Explorer DevTools: Open the Windows Run dialog box and enter "%systemroot%\system32\f12\IEChooser.exe". For more details, please visit Microsoft's documentation: What is Internet Explorer (IE) mode? --- title: Are admin privileges required to install the end-user component? description: Are admin privileges required to install the end-user component? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/admin-privileges-needed-to-install.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/admin-privileges-needed-to-install.md --- View all FAQs about [Project Deployment and End-user Installation]( https://www.dynamsoft.com/web-twain/docs/faq/#project-deployment-and-end-user-installation) # Are admin privileges required to install the end-user component?
- [v19.0+](#19plus) - [Versions below 19.0](#19min)
Yes, the Dynamic Web TWAIN Service installer is a `.msi` file which requires administrator privileges to install as the install target is `C:\Program Files (x86)`. Once the Dynamic Web TWAIN Service is installed with admin privileges, every user on that machine can has access to the Dynamic Web TWAIN Service. If your organization does not allow end users to have admin privileges, you can contact [Dynamsoft Support](/_articles/about/getsupport.md) to get a special "User Installer" that does not require admin privileges. The "User Installer", will install to the user's `C:\Users\{UserName}\AppData\Roaming\` folder. For Web TWAIN versions lower than 19.3, please be aware that only one user per machine is able to have the service installed via this method. The service cannot be installed to multiple user profiles, and only the user that installs the Services in this manner will have access to the Dynamic Web TWAIN Service.
Yes, the Dynamsoft Service installer is a `.msi` file which requires administrator privileges to install as the install target is `C:\Windows\SysWOW64\`. Once the Dynamsoft Service is installed with admin privileges, every user on that machine can has access to the Dynamsoft Service. If your organization does not allow end users to have admin privileges, you can contact [Dynamsoft Support](/_articles/about/getsupport.md) to get a special "User Installer" that does not require admin privileges. The "User Installer", will install to the user's `C:\Users\{UserName}\AppData\Roaming\` folder. Please be aware that only one user per machine is able to have the service installed via this method. The service cannot be installed to multiple user profiles, and only the user that installs the Services in this manner will have access to the Dynamsoft Service.
--- title: Dynamic Web TWAIN SDK FAQ description: Dynamic Web TWAIN SDK Documentation FAQ source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/index.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/index.md --- # FAQ ## SDK Download/Free Trial 1. [How can I extend my free trial?](/_articles/faq/extend-free-trial.md) 2. [Where can I download an older version of the Dynamic Web TWAIN SDK?](/_articles/faq/download-older-version-sdk.md) 3. [Do you provide free trial versions of the Dynamic Web TWAIN SDK?](/_articles/faq/provide-free-trial-version.md) 4. [Can I run the scanning service on an ARM-based embedded device, such as Raspberry Pi?](/_articles/faq/run-on-arm-based-embedded-device.md) 5. [Do you also provide an SDK download for Linux and Mac developers?](/_articles/faq/sdk-download-for-linux-and-mac.md) 6. [Is the free trial version fully functional?](/_articles/faq/trial-fully-functional.md) 7. [Can I use the Dynamic Web TWAIN SDK to create a PWA application?](/_articles/faq/use-with-PWA.md) ## Capture/Image Source 1. [Download virtual scanner for testing](/_articles/faq/download-virtual-scanner-for-testing.md) 2. [What physical document scanners does the Dynamic Web TWAIN SDK support?](/_articles/faq/what-physical-scanners-are-supported.md) 3. [How can I verify if my physical document scanner works with the Dynamic Web TWAIN SDK?](/_articles/faq/verify-if-device-is-supported.md) 4. [How to use TWACKER to check if your device is TWAIN Compliant?](/_articles/faq/how-to-use-TWACKER-to-check-if-your-device-is-TWAIN-Compliant.md) 5. [How to test if your scanner supports ICA scanning on Mac OS?](/_articles/faq/how-to-test-if-your-scanner-supports-ICA-scanning-on-Mac-OS.md) 6. [How to test if your device is SANE compliant?](/_articles/faq/how-to-test-if-your-device-is-SANE-compliant.md) 7. [How to test if your camera is DirectShow compliant?](/_articles/faq/how-to-test-if-your-camera-is-DirectShow-compliant.md) 8. [Can I set scanning settings without using the default scanner's UI? What pre-scanning settings do you support?](/_articles/faq/setting-scan-settings-without-ui.md) 9. [Can I hide offline scanner devices from the select source list?](/_articles/faq/hide-offline-scanners-from-source-list.md) 10. [Can I hide webcam devices from the select source list?](/_articles/faq/hide-webcam-from-source-list.md) 11. [What are the differences between TWAIN and WIA?](/_articles/faq/difference-between-Twain-and-wia.md) 12. [How to exclude WIA sources in the source list?](/_articles/faq/how-to-exclude-wia-sources-in-the-source-list.md) 13. [How can I set the last selected source as the default source for an end user?](/_articles/faq/last-selected-sourcename.md) 14. [How can I limit all users to use a specific scanner model?](/_articles/faq/limit-to-specific-scanner.md) 15. [Can the Dynamic Web TWAIN SDK automatically remove blank pages during the document scanning process?](/_articles/faq/remove-blank-page-automatically.md) 16. [Can the Dynamic Web TWAIN SDK automatically rotate upside-down pages during the document scanning process?](/_articles/faq/automatically-rotate-upside-down-pages.md) 17. [Can the Dynamic Web TWAIN SDK automatically detect borders of the scanned document and crop it out?](/_articles/faq/automatically-detect-border.md) 18. [Can I set my document scanner to scan x number of pages instead of all pages from the automatic document feeder (ADF)?](/_articles/faq/scan-x-pages-from-automatic-document-feeder.md) 19. [Can the Dynamic Web TWAIN SDK detect whether papers exist on the flatbed?](/_articles/faq/detect-paper-on-flatbed.md) 20. [How can I get a list of supported resolution/DPI values from the document scanner?](/_articles/faq/list-supported-resolution-DPI.md) 21. [How can I use a custom capability of my scanner hardware when there is no direct API to set it?](/_articles/faq/custom-capability.md) 22. [Is there a limit on the number of pages I can scan at a time? Where do you store them after scanning?](/_articles/faq/limit-on-scanned-pages.md) 23. [Document scanning via the Dynamic Web TWAIN SDK is slower than using the native scanner application. How can I speed it up?](/_articles/faq/document-scanning-slow-than-native.md) 24. [Can I use built-in or USB webcam to capture document?](/_articles/faq/use-usb-webcam-to-capture.md) 25. [Can I import existing images or PDF documents using the Dynamic Web TWAIN SDK?](/_articles/faq/import-existing-documents-or-images.md) 26. [Can I download an image from a FTP or HTTP server using the Dynamic Web TWAIN SDK?](/_articles/faq/download-image-from-FTP-or-HTTP-server.md) 27. [How can I trigger an automatic workflow right after document scanning or image importing?](/_articles/faq/trigger-automatic-workflow-after-scanning.md) 28. [Do you support capturing documents from mobile cameras?](/_articles/faq/support-capture-from-mobile-camera.md) 29. [How to scan documents on mobile devices?](/_articles/faq/how-to-scan-documents-on-mobile-devices.md) 30. [Do you support fingerprint or medical imaging devices?](/_articles/faq/fingerprint-medical-imaging.md) 31. [Is the AcquireImage() method synchronous or asynchronous?](/_articles/faq/acquireimage-sync-or-async.md) 32. [Why is my scanner not shown or not responding in the browser?](/_articles/faq/scanner-not-shown-or-not-responding-in-the-browser.md) 33. [How can I support WIA scanner drivers in my application?](/_articles/faq/support-wia-scanner-drivers.md) 34. [Why are my images coming out distorted in MacOS Sonoma?](/_articles/faq/macos-sonoma-distorted-scans.md) ## Image Viewer 1. [Where is the image viewer object defined?](/_articles/faq/image-viewer-object-defined.md) 2. [Can the size of the image viewer auto resize when the browser window size changes?](/_articles/faq/viewer-size-auto-resize.md) 3. [How can I create a thumbnail viewer to view images?](/_articles/faq/create-thumbnail-viewer-to-navigate-images.md) 4. [How can I change the background color of the image viewer?](/_articles/faq/change-background-color.md) 5. [How can I reorder images in the viewer?](/_articles/faq/resort-images-in-viewer.md) 6. [How can I disable drag and drop images in the viewer?](/_articles/faq/disable-drag-and-drop-in-images.md) 7. [How can I show multiple images at a time?](/_articles/faq/show-multiple-images.md) 8. [How can I show page number on each image?](/_articles/faq/show-page-number.md) 9. [How can I resize the view of image (e.g. zoom in/out on an image)?](/_articles/faq/resize-view-of-image.md) 10. [What mouse click events does the viewer support?](/_articles/faq/mouse-click-events-supported.md) 11. [How can I insert an image after a selected image in the viewer?](/_articles/faq/insert-image-after-selected-image.md) 12. [Can I protect sensitive information of an image from being seen?](/_articles/faq/protect-sensitive-information.md) 13. [Can I hide the Dynamsoft image viewer and use my own image viewer?](/_articles/faq/hide-image-viewer.md) 14. [Can I print images from the viewer?](/_articles/faq/print-images-from-viewer.md) 15. [How to get the coordinates of the selected area on an image?](/_articles/faq/coordinates-of-selected-area.md) ## Image Editing 1. [What image editing operations does the Dynamic Web TWAIN SDK support?](/_articles/faq/what-image-editing-operation-supported.md) 2. [How can I show the default image editor tool?](/_articles/faq/show-default-image-editor.md) 3. [Do you support image deskew?](/_articles/faq/support-image-deskew.md) 4. [How can I configure all scanned images to conform to a specific size standard (e.g., A4)?](/_articles/faq/set-page-size.md) 5. [Can I add annotation to an image (e.g. add watermark or text)?](/_articles/faq/add-annotation-to-image.md) 6. [Can I change the resolution/DPI of an image in the viewer?](/_articles/faq/change-resolution-of-image.md) 7. [Can I convert a color image to grayscale or black & white?](/_articles/faq/convert-color-image-to-grayscale.md) 8. [Is there an undo functionality?](/_articles/faq/undo-functionality.md) 9. [How can I remove only the selected images?](/_articles/faq/remove-selected-images.md) ## UI Customization 1. [Is the UI of the Dynamic Web TWAIN SDK fully customizable? What cannot be customized?](/_articles/faq/is-ui-customizable.md) 2. [How can I change the display language of all messages from English to another language?](/_articles/faq/change-display-language.md) 3. [How can I change/hide the spinner which shows during document scanning?](/_articles/faq/change-hide-spinner.md) 4. [How can I change/hide the UI of the progress bar when importing or uploading images?](/_articles/faq/hide-progress-bars.md) 5. [Can I customize UI elements of the built-in image editor?](/_articles/faq/customize-ui-elements-of-image-editor.md) 6. [Can I stop the scanner from showing its default popup when there is a paper jam?](/_articles/faq/stop-default-scanner-popup.md) 7. [Why I cannot hide the loading bar (spinner)?](/_articles/faq/unable-hide-loading-bar.md) ## Document Saving 1. [What image and document formats can I save my documents as?](/_articles/faq/image-document-formats-save.md) 2. [What type of HTTP servers do your support? Do you support other server types?](/_articles/faq/http-servers-support.md) 3. [How can I enable HTTPS support?](/_articles/faq/enable-https-support.md) 4. [How can I get the smallest size of documents in PDF, TIFF or JPEG format?](/_articles/faq/smallest-size-documents.md) 5. [How can I send additional form fields with images to my server or database?](/_articles/faq/additional-form-fields.md) 6. [How can I automatically trigger actions when images arrive on my server side?](/_articles/faq/trigger-actions-server-side.md) 7. [Can I upload documents to a different website domain?](/_articles/faq/upload-documents-to-different-domain.md) 8. [How can I get a response string from my HTTP Server if the upload succeeds or fails?](/_articles/faq/response-string-from-server-on-upload.md) 9. [Can I upload documents via a background service outside the web browser?](/_articles/faq/upload-using-background-service.md) 10. [Can I insert newly scanned pages to an existing document?](/_articles/faq/insert-new-pages-to-existing-document.md) 11. [How can I upload a JSON file to my server?](/_articles/faq/upload-json-files-to-server.md) 12. [How can I save selected images instead of all images to my server or database?](/_articles/faq/save-selected-images-to-server.md) 13. [How to use a blank page as a separator?](/_articles/faq/use-blank-page-as-a-separator.md) 14. [How to upload multiple files at a time?](/_articles/faq/upload-multiple-files-at-a-time.md) 15. [How to deploy your own upload server with ASP.NET?](/_articles/faq/deploy-your-own-upload-server-with-asp.net.md) 16. [How to deploy your own upload server with JSP?](/_articles/faq/deploy-your-own-upload-server-with-jsp.md) 17. [How to deploy your own upload server with Node.js?](/_articles/faq/deploy-your-own-upload-server-with-node.js.md) 18. [How to deploy your own upload server with PHP?](/_articles/faq/deploy-your-own-upload-server-with-php.md) ## Security 1. [Where does the Dynamic Web TWAIN SDK store images on end-user machines? Are they encrypted?](/_articles/faq/where-images-are-stored.md) 2. [Can I prompt the end-user when the Dynamic Web TWAIN SDK attempts to visit any local resources (scanner, camera, or disk drive)?](/_articles/faq/prompt-end-user-when-local-resources-used.md) 3. [When are the locally cached images destroyed?](/_articles/faq/local-cached-images-destroyed.md) 4. [The license key is set in JavaScript. How can I protect it?](/_articles/faq/license-key-protection.md) 5. [Does the Dynamic Web TWAIN SDK use any deprecated technologies like NPAPI or ActiveX?](/_articles/faq/use-deprecated-technology.md) 6. [How can I securely transfer scanned documents to my server?](/_articles/faq/securely-transfer-to-server.md) 7. [Can I generate/load an encrypted file in PDF format?](/_articles/faq/encrypt-pdf-files.md) 8. [Can I limit the size of documents to be uploaded to my server?](/_articles/faq/limit-upload-size-to-server.md) 9. [Is the Dynamic Web TWAIN SDK ISO 27001 compliant?](/_articles/faq/iso-27001-compliant.md) 10. [Is the Dynamic Web TWAIN SDK GDPR compliant?](/_articles/faq/gdpr-compliant.md) 11. [Is the Dynamic Web TWAIN SDK HIPAA compliant?](/_articles/faq/hipaa-compliant.md) 12. [How can I change the certificate of the Dynamic Web TWAIN Service?](/_articles/faq/change-dynamsoft-service-certificate.md) ## Addon 1. [Do I need a separate license for each addon?](/_articles/faq/separate-license-for-addon.md) 2. [When do I need PDF Rasterizer Addon? Can I load existing PDF files into the Dynamic Web TWAIN SDK without the PDF Rasterizer addon?](/_articles/faq/when-is-pdf-rasterizer-needed.md) 3. [How can I load PDF/A files into the Dynamic Web TWAIN SDK?](/_articles/faq/load-pdf-files.md) 4. [Can I load specific page numbers of a PDF file into the viewer?](/_articles/faq/load-specific-page-of-pdf-to-viewer.md) 5. [Do I need the PDF Rasterizer addon to convert scanned documents to PDF files?](/_articles/faq/is-pdf-rasterizer-needed-to-convert-scanned-documents-to-pdf.md) 6. [How can I generate PDF/A files?](/_articles/faq/generate-pdf-files.md) 7. [Does your Barcode Reader addon support patch code?](/_articles/faq/does-barcode-addon-support-patch-code.md) 8. [How can I separate my documents automatically by barcode?](/_articles/faq/separate-documents-by-barcode.md) 9. [Is there any way to speed up the barcode reading process?](/_articles/faq/speed-up-barcode-reading-process.md) 10. [What types of webcams does the Webcam Capture addon support](/_articles/faq/webcam-supported-by-webcam-capture-addon.md) 11. [How can I prompt users for a password when loading a password-protected PDF?](/_articles/faq/prompt-password-for-protected-pdf.md) ## Project Deployment and End-user Installation 1. [What are the Resources files?](/_articles/faq/what-are-the-resources-files.md) 2. [What resources of the SDK should be included in my web application?](/_articles/faq/resources-to-be-included-in-SDK.md) 3. [How can I change the reference path to the Dynamsoft's resources in my project?](/_articles/faq/change-reference-path.md) 4. [What is Remote Scan and how do I enable it?](https://www.dynamsoft.com/remote-scan/docs/introduction/) 5. [How can I use Dynamic Web TWAIN in a Citrix environment?](/_articles/faq/use-dwt-in-citrix-env.md) 6. [Is there any component of the Dynamic Web TWAIN SDK that needs to be installed on end-user machines?](/_articles/faq/component-needs-to-be-installed-on-end-user-machine.md) 7. [What does the Dynamic Web TWAIN Service do on the end-user machine?](/_articles/faq/what-does-dynamsoft-service-do-on-end-user-machine.md) 8. [Are admin privileges required to install the end-user component?](/_articles/faq/admin-privileges-needed-to-install.md) 9. [Can I install Dynamic Web TWAIN Service silently?](/_articles/faq/can-i-install-dynamsoft-service-silently.md) 10. [Is there an easy way to deploy the end-user components to all users?](/_articles/faq/deploy-to-all-users.md) 11. [How to uninstall Dynamic Web TWAIN Service?](/_articles/faq/how-to-uninstall-dynamsoft-service.md) 12. [I have installed the Dynamic Web TWAIN Service on an end-user machine but still got asked to install it repeatedly. Why?](/_articles/faq/service-prompting-to-install-repeatedly.md) 13. [Dynamic Web TWAIN Service installation and uninstallation issue](/_articles/faq/service-installation-issue.md) 14. [Can I use two different websites integrated with two different versions of Dynamic Web TWAIN on the same computer?](/_articles/faq/service-backward-compatibility.md) 15. [How do I upgrade my project to use the latest version of the Dynamic Web TWAIN SDK?](/_articles/faq/upgrade-to-latest-version.md) 16. [How do I upgrade the end-user installation for all end users once I upgrade my project?](/_articles/faq/upgrade-end-user-installations.md) 17. [Can I still use Dynamic Web TWAIN on non-HTTPS (insecure HTTP) sites with Chrome?](/_articles/faq/http-insecure-websites-in-chromium-browser.md) 18. [How to resolve Dynamic Web TWAIN issue in Chrome 101?](/_articles/faq/private-network-access-in-chrome101.md) 19. [Dynamic Web TWAIN – Content-Security-Policy violated](/_articles/faq/content-security-policy-violated.md) 20. [Scanner source is listed on XSane application but not on my web application on Linux machines](/_articles/faq/source-not-listed-on-linux.md) 21. [How to run Dynamic Web TWAIN ActiveX in Microsoft Edge Internet Explorer (IE) mode](/_articles/faq/activeX-in-Edge-IE-mode.md) 22. [The scanner's UI or the system's file dialog does not open when scanning](/_articles/faq/service-is-blocked.md) 23. [How do I know which SDK version I am using?](/_articles/faq/find-SDK-version.md) 24. [Where can I download the Dynamic Web TWAIN Service installers only?](/_articles/faq/download-service-only.md) 25. [Error message - CORS Errors caused by local network access permissions when using Chromium 142 and later](/_articles/faq/chromium-142-local-network-access-issue.md) 26. [macOS Rosetta Discontinuation and Dynamic Web TWAIN Service](/_articles/faq/mac-rosetta-discontinuation.md) ## Error Troubleshooting 1. [General troubleshooting steps](/_articles/faq/general-troubleshooting-steps.md) 2. [General failure](/_articles/faq/general-failure.md) 3. [A connection with the server could not be established](/_articles/faq/connection-couldnt-be-established.md) 4. [HTTP request error](/_articles/faq/HTTP-request-error.md) 5. [HTTP process error](/_articles/faq/HTTP-process-error.md) 6. [Only 24-bit true color bmp and 8-bit gray-scaled images are supported for JPEG compression](/_articles/faq/JPEG-compression.md) 7. [XMLHttpRequest cannot load XXX](/_articles/faq/XMLHttpRequest-cannot-load.md) 8. [Source is connected to the maximum supported number of applications](/_articles/faq/source-connected-to-maximum.md) 9. [Sequence error](/_articles/faq/sequence-error.md) 10. [Request header field dwt-md5 is not allowed by Access-Control-Allow-Headers in preflight response](/_articles/faq/dwt-md5-is-not-allowed.md) 11. [The handle is in the wrong state for the requested operation](/_articles/faq/the-handle-is-in-the-wrong-state-for-the-requested-operation.md) 12. [The connection with the server was terminated abnormally](/_articles/faq/the-connection-with-the-server-was-terminated-abnormally.md) 13. [Syntax error – Unexpected Token "<"](/_articles/faq/syntax-error-unexpected-token.md) 14. [Uncaught ReferenceError - DVS is not defined](/_articles/faq/DVS-is-not-defined.md) 15. [Error message - The current product key does not support XXX, please contact the site administrator](/_articles/faq/error-message-current-product-key-does-not-support.md) 16. [Error message - The current product key does not support current OS for embed device, please contact the site administrator](/_articles/faq/error-message-product-key-does-not-support-current-os.md) 17. [Error message - The current product key is empty or invalid, please contact the site administrator](/_articles/faq/error-message-current-product-key-is-empty-or-invalid.md) 18. [Error message - The current product key is missing the core license, please contact the site administrator](/_articles/faq/error-message-product-key-is-missing-the-core-license.md) 19. [Error message - The domain of your current site does not match the domain bound in the current product key, please contact the site administrator](/_articles/faq/error-message-domain-of-site-doesnt-match-domain-bound-to-product-key.md) 20. [Error message - The current product key is invalid because it's generated with the licenses of a different major version](/_articles/faq/error-message-license-generated-with-license-of-major-version.md) 21. [Error message - The current product key is not for full/trial version, please contact the site administrator](/_articles/faq/error-message-product-key-is-not-for-full-version.md) 22. [Error message – Your Dynamic Web TWAIN product key expired](/_articles/faq/error-message-product-key-expired.md) 23. [Error Message - Failed to load resource: net::ERR\_CERT\_DATE\_INVALID](/_articles/faq/failed-to-load-resource.md) 24. [Error Message - The connection from the insecure (HTTP) web page to the local 'Dynamsoft Service' failed](/_articles/faq/connection-from-the-insecure-HTTP-to-service-failed.md) 25. [Error Message - Source has nothing to capture](/_articles/faq/source-has-nothing-to-capture.md) 26. [Warning Message - Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true](/_articles/faq/chrome-106-107-warning.md) 27. [Error Message - Uncaught TypeError: Cannot read properties of null (reading 'appendChild') or Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'](/_articles/faq/type-error-appendchild.md) 28. [Error Message - User cancelled the operation](/_articles/faq/error-message-user-cancelled-the-operation.md) 29. [The loading bar keeps spinning when capture the image with iPhone.](/_articles/faq/the-loading-bar-keeps-spinning-when-capture-the-image-with-iphone.md) 30. [How to debug on Dynamic Web TWAIN online demo?](/_articles/faq/debug-on-online-demo.md) 31. [Dynamic Web TWAIN prompts the .deb installer for Windows](/_articles/faq/incorrect-installer-for-windowsARM64.md) 32. [Why am I unable to load the TIFF file into Dynamic Web TWAIN?](/_articles/faq/unable-to-load-4-bit-tiff.md) 33. [Error message - CORS Errors caused by local network access permissions when using Chromium 142 and later](/_articles/faq/chromium-142-local-network-access-issue.md) 34. [Error message - File is Damaged and Can’t Be Opened in macOS](/_articles/faq/file-damaged-on-macos.md) 35. [Safari 26.2 Regression Causing Dynamic Web TWAIN v19.3 Auto-Reconnect Failure on macOS](/_articles/faq/safari-26-2-regression.md) ## Licensing and Purchase 1. [Is internet connectivity required to use all licenses?](/_articles/faq/is-internet-connectivity-required.md) 2. [Does the per-server license allow unlimited number of client devices and end users?](/_articles/faq/does-per-server-allow-unlimited.md) 3. [What license should I purchase if I am providing SaaS?](/_articles/faq/which-license-purchase-needed-for-saas.md) 4. [For the per-client-device licensing model, can seats taken by retired/unused devices be released from the license?](/_articles/faq/release-license-seats.md) 5. [Will a client machine take an additional license seat if its operating system is reinstalled?](/_articles/faq/seat-taken-if-os-reinstalled.md) 6. [What if I reach the limit of the granted number of license seats?](/_articles/faq/license-limit-reached.md) 7. [Do you offer lifetime/perpetual licenses?](/_articles/faq/offer-perpetual-license.md) 8. [Do I need to purchase a license for my dev or testing environment?](/_articles/faq/purchase-dev-or-test-license.md) 9. [I need to resell the SDK within my application to my customers. What options do you offer?](/_articles/faq/resell-sdk.md) 10. [Are you flexible to discuss custom licensing models?](/_articles/faq/flexible-to-custom-license.md) 11. [Do you have any local resellers from whom I can purchase a license of the Dynamic Web TWAIN SDK?](/_articles/faq/local-resellers.md) 12. [Do I get free upgrade if there is a newer version available?](/_articles/faq/free-upgrade.md) 13. [What is your discount policy?](/_articles/faq/discount-policy.md) 14. [What's your refund policy?](/_articles/faq/refund-policy.md) ## Annotation 1. [How can I add annotations to an image and then save/upload it?](/_articles/faq/dwt-with-annotation.md) --- title: How can I prompt users for a password when loading a password-protected PDF? description: How can I prompt users for a password when loading a password-protected PDF? source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/prompt-password-for-protected-pdf.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/prompt-password-for-protected-pdf.md --- # Addon ## How can I prompt users for a password when loading a password-protected PDF? Dynamic Web TWAIN does not provide a built-in password prompt UI for encrypted PDFs. You need to handle the prompt and retry flow in your application code. ### Recommended workflow (`LoadImage()` / `LoadImageEx()`) 1. Call [`LoadImage()`](/_articles/info/api/WebTwain_IO.md#loadimage) or [`LoadImageEx()`](/_articles/info/api/WebTwain_IO.md#loadimageex). 2. In the failure callback, treat the error as "password required" only when either condition is true: - (`errorCode` is `-1119` and `errorString` contains `"Failed to read the PDF file because it's encrypted and the correct password is not provided."`) - OR `errorCode` is `-1120`. 3. Prompt the user for a password. 4. Set the password via [`SetReaderOptions()`](/_articles/info/api/Addon_PDF.md#setreaderoptions). 5. Retry loading the same PDF. ### Helper function for password-required errors Use this helper in both API-based loading and drag-and-drop handling: ```javascript function isPasswordRequired(errorCode, errorString) { return ( (errorCode === -1119 && (errorString || "").includes( "Failed to read the PDF file because it's encrypted and the correct password is not provided.", )) || errorCode === -1120 ); } ``` ### `LoadImage()` / `LoadImageEx()` example ```javascript function loadProtectedPdf(path, password) { DWTObject.Addon.PDF.SetReaderOptions({ password: password || "" }); DWTObject.LoadImageEx( path, Dynamsoft.DWT.EnumDWT_ImageType.IT_PDF, function () { console.log("PDF loaded successfully."); }, function (errorCode, errorString) { if (!isPasswordRequired(errorCode, errorString)) { console.error(errorCode, errorString); return; } var userPassword = window.prompt( "This PDF is password-protected. Please enter the password:", "", ); if (!userPassword) return; loadProtectedPdf(path, userPassword); }, ); } ``` ### Drag-and-drop workflow (`OnPostLoad`) Use [`OnPostLoad`](/_articles/info/api/WebTwain_IO.md#onpostload) and check `DWTObject.ErrorCode` / `DWTObject.ErrorString`. ```javascript DWTObject.RegisterEvent("OnPostLoad", function (path, name, type) { if (!isPasswordRequired(DWTObject.ErrorCode, DWTObject.ErrorString)) return; var userPassword = window.prompt( "This PDF is password-protected. Please enter the password:", "", ); if (!userPassword) return; DWTObject.Addon.PDF.SetReaderOptions({ password: userPassword }); if (!path) { alert("Password saved. Please drag and drop the file again."); return; } var fullPath = path + "\\" + name; loadProtectedPdf(fullPath, userPassword); }); ``` > [!NOTE] > `-1119` can represent multiple PDF load issues, so do not use it alone. > Starting in Dynamic Web TWAIN 19.4, encrypted-PDF load failures will use `-1120`. > > In `OnPostLoad`, `path` is empty for drag-and-drop files, so the code cannot directly retry with a file path. > In this case, prompt for password, save it with `SetReaderOptions()`, and ask the user to drag and drop the file again. --- title: macOS Rosetta Discontinuation and Dynamic Web TWAIN Service description: Apple is phasing out Rosetta for Intel apps on Apple Silicon Macs. Learn how this affects the Dynamic Web TWAIN Service and what steps to take. source_url: html: https://www.dynamsoft.com/web-twain/docs/faq/mac-rosetta-discontinuation.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/faq/mac-rosetta-discontinuation.md --- # Error Troubleshooting ## macOS Rosetta Discontinuation and Dynamic Web TWAIN Service ### Overview Apple has announced that Rosetta support for Intel-based applications will be phased out in future macOS releases. Rosetta will remain fully available through macOS 27. Starting with macOS 28, Intel-only applications will no longer be supported. Starting with macOS 26.4, users may also see system notifications warning that Intel-based applications will not be supported in future macOS versions. ![system notification from macOS](/assets/imgs/Intel-based-service.jpg) ### What is Apple’s timeline? | macOS Version | Expected Availability | Rosetta Status | |---|---|---| | macOS 26.4+ | Already released | System notifications appear for Intel-only apps | | macOS 27 | September 2026 | Rosetta remains fully functional — last version to support it | | macOS 28 | 2027 | Intel-only apps will no longer run on Apple Silicon Macs | For the official Apple announcement, see: [Using Intel-based apps on a Mac with Apple silicon — Apple Support](https://support.apple.com/en-us/102527) ### Does Dynamic Web TWAIN Service still work on macOS? Yes. The current version of Dynamic Web TWAIN Service continues to function normally on supported macOS versions, including macOS 26 and macOS 27. ### What is Dynamsoft doing to address this? Dynamsoft has released a Universal Binary version of Dynamic Web TWAIN Service with native Apple Silicon support. **Dynamic Web TWAIN 19.4 is now available**, shipping the Universal Binary service installer that runs natively on Apple Silicon — no Rosetta required. This ensures full compatibility ahead of macOS 27. ### I'm on Dynamic Web TWAIN v18.x. Do I need to upgrade my SDK to v19.4+? Not necessarily. The v19.4 service installer includes the **DWT 18.6 service module**, which is **backward compatible with DWT 18.x**. This means you can install the v19.4 Dynamic Web TWAIN Service on end-user machines to get Apple Silicon native support while continuing to use your existing v18.x SDK integration. You do not need to change your application code or upgrade your JavaScript SDK to v19 just to resolve the Rosetta notification. ### Do end-users need to take any action now? Yes. Now that Dynamic Web TWAIN 19.4 is available, we recommend upgrading the Dynamic Web TWAIN Service on end-user machines to get native Apple Silicon support and eliminate the macOS system notification about Intel-based apps. See the deployment section below for details. ### How do I deploy the updated service to end users? The deployment process is the same as the current service. Download the v19.4 macOS service installer and distribute it to your end users. If you use silent installation or enterprise deployment methods, the process remains the same — only the installer binary changes. For details on deployment options, see: [How to deploy the end-user components to all users](/_articles/faq/deploy-to-all-users.md) ### Do I need to renew my license or maintenance to get the update? - **Active annual license or maintenance plan**: You are entitled to upgrade to v19.4 at no additional cost. Download and deploy the updated service installer now. - **Perpetual license without active maintenance**: You will need to renew your maintenance plan to access the v19.4 release. Please contact [Dynamsoft Sales](https://www.dynamsoft.com/company/contact/) to discuss renewal options. ### Does this affect Intel-based Macs? No. Intel-based Macs run Intel binaries natively without Rosetta. The current service installer continues to work on Intel-based Macs regardless of macOS version. > Note: Apple has announced that macOS 26 is the last macOS release to support Intel-based Mac hardware. --- title: Dynamic Web TWAIN SDK Features - Exporting Images description: Dynamic Web TWAIN SDK Image Export Documentation source_url: html: https://www.dynamsoft.com/web-twain/docs/general-usage/image-export/index.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/general-usage/image-export/index.md --- # Exporting Images > Prerequisite: [DWT Initialization](/_articles/general-usage/initialization.md) > Prerequisite: [Managing the Image Buffer](/_articles/general-usage/image-processing/buffer-management.md) DWT provides a variety of simple methods to export data both externally (uploading to the server) and locally (i.e. within the web application to expose to other web components). DWT provides built-in APIs to support uploading scanned (and otherwise imported) images to the server via both `HTTP` and `FTP`. Locally, DWT can save images to the end user's file system in a many supported file formats. Read on for explanations and examples. ### Table of Contents - [Uploading to the Web Server](/_articles/general-usage/image-export/server-upload.md) - [Exporting Locally](/_articles/general-usage/image-export/local-export.md) --- title: Dynamic Web TWAIN SDK Features - Exporting Locally description: Dynamic Web TWAIN SDK Documentation Local Export source_url: html: https://www.dynamsoft.com/web-twain/docs/general-usage/image-export/local-export.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/general-usage/image-export/local-export.md --- # Exporting Locally > Prerequisite: [DWT Initialization](/_articles/general-usage/initialization.md)
> Prerequisite: [Managing the Image Buffer](/_articles/general-usage/image-processing/buffer-management.md) DWT offers several methods to save images from the `WebTwain` image buffer locally. This includes saving the images to files on the end user's file system, exporting from the image buffer to binary Blobs and Base64 strings, and also printing to connected printers. ## Saving Locally The `WebTwain` image buffer can output images directly to disk, and supports `BMP` , `JPG` , `TIF` , `PNG` and `PDF` formats. Of note, `TIF` and `PDF` come with multi-image support. Learn more about supported file formats [here]({{site.getstarted}}filetype.html). Each file format has its own file saving API, as shown here: - [`SaveAsBMP()`](/_articles/info/api/WebTwain_IO.md#saveasbmp) - [`SaveAsJPEG()`](/_articles/info/api/WebTwain_IO.md#saveasjpeg) - [`SaveAsPDF()`](/_articles/info/api/WebTwain_IO.md#saveaspdf) - [`SaveAsPNG()`](/_articles/info/api/WebTwain_IO.md#saveaspng) - [`SaveAsTIFF()`](/_articles/info/api/WebTwain_IO.md#saveastiff) - [`SaveSelectedImagesAsMultiPagePDF()`](/_articles/info/api/WebTwain_IO.md#saveselectedimagesasmultipagepdf) - [`SaveSelectedImagesAsMultiPageTIFF()`](/_articles/info/api/WebTwain_IO.md#saveselectedimagesasmultipagetiff) - [`SaveAllAsPDF()`](/_articles/info/api/WebTwain_IO.md#saveallaspdf) - [`SaveAllAsMultiPageTIFF()`](/_articles/info/api/WebTwain_IO.md#saveallasmultipagetiff) Note that multi-page saving requires separate APIs from their single page counterparts. ## Exporting to Binary The image buffer can export images as Blobs or Base64 strings, which are useful for processing images outside of DWT, whether for [custom image upload logic](/_articles/general-usage/image-export/server-upload.md), or other purposes within the web application. ### Exporting to Blob [`ConvertToBlob()`](/_articles/info/api/WebTwain_IO.md#ConvertToBlob) converts selected images to a Blob, as demonstrated here: ``` javascript DWTObject.ConvertToBlob( [0, 1, 2], Dynamsoft.DWT.EnumDWT_ImageType.IT_PDF, function(result, indices, type) { console.log(result.size); }, function(errorCode, errorString) { console.log(errorString); } ); ``` APIs used: - [`ConvertToBlob()`](/_articles/info/api/WebTwain_IO.md#ConvertToBlob) - [`Dynamsoft.DWT.EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype) Here, `ConvertToBlob()` takes a zero-indexed array of image indices (of the image buffer) which indicates the images it exports, and uses the [`Dynamsoft.DWT.EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype) enum to specify the file format (in this case, single-page PDF). Just as when saving to files locally, use the dedicated multi-page enums when saving multi-page `PDF`s and `TIF`s. The Blob accessible through the `result` argument of the success callback. ### Exporting to Base64 String Likewise, [`ConvertToBase64()`](/_articles/info/api/WebTwain_IO.md#converttobase64) outputs a Base64 string: ``` javascript DWTObject.ConvertToBase64( [0, 1, 2], Dynamsoft.DWT.EnumDWT_ImageType.IT_PDF, function(result, indices, type) { console.log(result.getData(0, result.getLength())); }, function(errorCode, errorString) { console.log(errorString); } ); ``` APIs used: - [`ConvertToBase64()`](/_articles/info/api/WebTwain_IO.md#converttobase64) - [`Dynamsoft.DWT.EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype) The Base 64 string accessible through the `result` argument of the success callback. Note that this is a [Base64Result](/_articles/info/api/interfaces.md#base64result) object. ## Print Finally, DWT can also print directly to a printer through the [ `Print()` ](/_articles/info/api/WebTwain_IO.md#print) API. This API brings all images from the image buffer into the browser's print dialog. Alternatively, while running on Windows, the API can also take an argument to use the Windows OS print dialog instead.
--- title: Dynamic Web TWAIN SDK Features - Uploading Images to Web Server description: Dynamic Web TWAIN SDK Documentation Output Page source_url: html: https://www.dynamsoft.com/web-twain/docs/general-usage/image-export/server-upload.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/general-usage/image-export/server-upload.md --- # Uploading Images to the Web Server > Prerequisite: [DWT Initialization](/_articles/general-usage/initialization.md)
> Prerequisite: [Managing the Image Buffer](/_articles/general-usage/image-processing/buffer-management.md) DWT contains data upload APIs that allow uploading to web servers with just a few lines of code. DWT supports uploading via both `HTTP` and `FTP`. ## Uploading over `HTTP` DWT provides a variety of built-in `HTTP ` upload APIs. Here, we demonstrate using [`HTTPUpload()`](/_articles/info/api/WebTwain_IO.md#httpupload)to upload all ### Sample Code ```html

``` APIs used: - [`RegisterEvent()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#registerevent) - [`OnWebTwainReady`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainready) - [`SelectSourceAsync()`](/_articles/info/api/WebTwain_Acquire.md#selectsourceasync) - [`AcquireImageAsync()`](/_articles/info/api/WebTwain_Acquire.md#acquireimageasync) - [`IfCloseSourceAfterAcquire`](/_articles/info/api/Device.md#deviceobjectacquireimage) - [`SelectAllImages()`](/_articles/info/api/WebTwain_Buffer.md#selectallimages) - [`SelectedImagesIndices`](/_articles/info/api/WebTwain_Buffer.md#selectedimagesindices) - [`HTTPUpload()`](/_articles/info/api/WebTwain_IO.md#httpupload) - [`HTTPPort`](/_articles/info/api/WebTwain_IO.md#httpport) - [`IfSSL`](/_articles/info/api/WebTwain_IO.md#ifssl) - [`Dynamsoft.DWT.EnumDWT_UploadDataFormat`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_uploaddataformat) - [`Dynamsoft.DWT.EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype) ### Explanation This sample uploads the scanned images to the server as a PDF in binary form, and hands the data off to the server for further processing. Note that the upload handler script (here `https://demo.dynamsoft.com/sample-uploads/`) must be defined in order to receive the data accordingly, but is otherwise language- and logic-agnostic. Read our [server-side scripting guide](/_articles/general-usage/server-side-scripting.md) for more information. We use [`HTTPUpload()`](/_articles/info/api/WebTwain_IO.md#httpupload) to perform the following tasks: > Note: Only `PDF` and `TIF` support multi-page documents. When using other image formats, `HTTPUpload()` can only upload one image per API call - it will fail when selecting more than one image. - Target images in the buffer specified by the `indices` array for uploading. - We can only use more than one index when the target image format is `PDF` or `TIF`. - Encode the images in the image format specified by `type`. In this case, we call it with the `Dynamsoft.DWT.EnumDWT_ImageType.IT_PDF` enum to encode to PDF. - This API supports `BMP` , `JPG` , `TIF` , `PNG` and `PDF` formats. Learn more about supported file formats [here]({{site.getstarted}}filetype.html). - Only `TIF`s and `PDF`s support multi-page files, and they use the `Dynamsoft.DWT.EnumDWT_ImageType.IT_TIF` and `Dynamsoft.DWT.EnumDWT_ImageType.IT_PDF` values, respectively. - Convert the encoded images into a type specified by the `Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary` (either binary or Base64 strings). In this case we convert to binary. - Create an HTTP Form and perform an asynchronous HTTP (Ajax) request to send the form to the server-side script at the location specified by `url`. - Wait for the confirmation from the server, then execute the callback. - Note that `HTTPUpload()` appends the correct file extension to the file name if it does not detect the correct ending in the `fileName` argument. For example, passing `example.jpg` for a `PDF` results in the file `example.jpg.pdf`, whereas passing the correct `example.pdf` in the first place will not result in changes to the file name. Before calling `HTTPUpload()`, we first select all images in the buffer using `SelectAllImages()`. `HTTPUpload()` receives the full list of image indices from `SelectedImagesIndices`. Also, note that `HTTPUpload()` supports `HTTPS` when there is an SSL certificate. In this case, the sample upload site supplies an SSL certificate, so we enable `HTTPS` with `Dynamsoft.DWT.IfSSL = true`. (the default value is `false`) DWT provides other `HTTP` uploading APIs as well, such as for specifically uploading multi-page PDFs, or for uploading via `HTTP` post requests, among others. Read more about them in detail in our [API reference](/_articles/info/api/WebTwain_IO.md). ### Using Existing Upload Logic with DWT We can also continue to use existing AJAX-style upload logic to upload images from DWT. The following example block assumes the existing logic is AJAX and uses [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData/FormData): ``` javascript function uploadThroughAJAX(imageBufferIndices, fileFormat) { DWTObject.ConvertToBlob( imageBufferIndices, fileFormat, function(result, _indices, fileFormat) { var url = "https://YOUR-SITE:PORT/PATH/TO/SCRIPT.aspx"; var fileName = "SampleFile" + getExtension(fileFormat); var formData = new FormData(); formData.append('RemoteFile', result, fileName); var response = await fetch(url, {method: "POST", body: formData}); // Check response }, function(errorCode, errorString) { console.log(errorString); } ); } function getExtension(fileFormat) { switch (fileFormat) { case Dynamsoft.DWT.EnumDWT_ImageType.IT_BMP: return ".bmp"; case Dynamsoft.DWT.EnumDWT_ImageType.IT_JPG: return ".jpg"; case Dynamsoft.DWT.EnumDWT_ImageType.IT_TIF: return ".tif"; case Dynamsoft.DWT.EnumDWT_ImageType.IT_PNG: return ".png"; case Dynamsoft.DWT.EnumDWT_ImageType.IT_PDF: return ".pdf"; default: return ".unknown"; } } ``` APIs used: - [`ConvertToBlob()`](/_articles/info/api/WebTwain_IO.md#converttoblob) #### Explanation The only DWT API used in this example is [`ConvertToBlob()`](/_articles/info/api/WebTwain_IO.md#converttoblob), which takes care of file format encoding and binary conversion of the images, with a given array of image buffer indices and a file format enum. ## Uploading over FTP Aside from `HTTP`, DWT also supports `FTP`, which is much simpler to use. The [`FTPUpload()`](/_articles/info/api/WebTwain_IO.md#ftpupload) is used to upload a single image like so: ``` javascript DWTObject.FTPUserName = 'username'; DWTObject.FTPPort = 21; DWTObject.FTPPassword = 'password'; DWTObject.FTPUpload( '192.168.8.222', //The FTP Host imageIndex, 'test.pdf', // The path & name of the file function () { console.log('Successful FTP upload'); }, function (errorCode, errorString) { console.log('Failed FTP upload'); } ); ``` APIs used: - [ `FTPUserName` ](/_articles/info/api/WebTwain_IO.md#ftpusername) - [ `FTPPort` ](/_articles/info/api/WebTwain_IO.md#ftpport) - [ `FTPPassword` ](/_articles/info/api/WebTwain_IO.md#ftppassword) - [ `FTPUpload()` ](/_articles/info/api/WebTwain_IO.md#ftpupload) Note that the FTP port (and credentials) are set using `WebTwain` instance properties, unlike the host address which is passed as an argument. DWT provides other HTTP upload APIs, for example, to better handle multi-page files (in the case of `TIF` and `PDF` formats). Please read more in our [API reference](/_articles/info/api/WebTwain_IO.md). ## `FileUploader` The `FileUploader` is a special feature that uploads files using the Dynamic Web TWAIN Service, rather than directly from the web application. This is useful for uploading large amounts of data which may otherwise degrade browser performance. Here is a quick run-down of its operation: 1. `Dynamic Web TWAIN` will prepare the file to upload with the method [ `GenerateURLForUploadData()` ](/_articles/info/api/WebTwain_Util.md#generateurlforuploaddata) 2. Create a File Uploader instance with the method [ `Init()` ](/_articles/info/api/Dynamsoft_FileUploader.md#init) 3. Create an upload job with [ `CreateJob()` ](/_articles/info/api/Dynamsoft_FileUploader.md#createjob) - Define the target URL [ `ServerUrl` ](/_articles/info/api/Dynamsoft_FileUploader.md#serverurl) - Define the upload content [ `SourceValue` ](/_articles/info/api/Dynamsoft_FileUploader.md#sourcevalue) - (Optional) Define callback functions [ `OnUploadTransferPercentage` ](/_articles/info/api/Dynamsoft_FileUploader.md#onuploadtransferpercentage) , [ `OnRunSuccess` ](/_articles/info/api/Dynamsoft_FileUploader.md#onrunsuccess), [ `OnRunFailure` ](/_articles/info/api/Dynamsoft_FileUploader.md#onrunfailure) 4. Run the job 5. Wait for the confirmation from the server Check out how to use the Uploader in the following code snippets ``` html
``` Check out [Server-side Scripting](/_articles/general-usage/server-side-scripting.md) for more information on the target URL.
--- title: Dynamic Web TWAIN SDK Basics - Managing the Image Buffer description: Dynamic Web TWAIN SDK General Usage Guide - Managing the Image Buffer source_url: html: https://www.dynamsoft.com/web-twain/docs/general-usage/image-processing/buffer-management.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/general-usage/image-processing/buffer-management.md --- # Managing the Image Buffer > Prerequisite: [DWT Initialization](/_articles/general-usage/initialization.md) Images scanned by a `WebTwain` instance are stored inside the `WebTwain`'s image buffer, which stores images in memory in the `DIB` format. This guide explains commonly-used features to manipulate the data, from reordering pages, to retrieving metadata, and more. ## Querying Buffer Status The first step in managing the buffer is to examine its state. Images in the buffer can be identified both with its index (which may change over time), or by its image ID, which is immutable once an image enters the buffer. These buffer state querying APIs are typically used in conjunction with other buffer APIS, such as image reordering and image tagging, which we will come to discuss. - [`DWTObject.HowManyImagesInBuffer`](/_articles/info/api/WebTwain_Buffer.md#howmanyimagesinbuffer) holds the number of images in the buffer of the `WebTwain` instance. - [`MaxImagesInBuffer`](/_articles/info/api/WebTwain_Buffer.md#maximagesinbuffer) controls the maximum number of images allowed within the buffer. The default value is 32767. - [`DWTObject.CurrentImageIndexInBuffer`](/_articles/info/api/WebTwain_Buffer.md#currentimageindexinbuffer) returns the index of the currently active image (which is also the one being displayed by the `Viewer`). This property can also be used to **set** the active image by setting it to a different index. - [`IndexToImageID(imageIndex)`](/_articles/info/api/WebTwain_Buffer.md#indextoimageid) and [ `ImageIDToIndex(imageID)` ](/_articles/info/api/WebTwain_Buffer.md#imageidtoindex) can get the image ID (a string) of an image at a given position in the buffer index (a number), and vice versa. - Images in the buffer also have an internal URL with which they can be referenced (in [desktop browsers only]({{site.getstarted}}platform.html#browsers-on-desktop-devices)). This comes in two flavors: - [`GetImageURL(imageIndex)`](/_articles/info/api/WebTwain_Buffer.md#getimageurl) retrieves the URL of the image at the specified index using the `https://` scheme. This is useful to display images outside the `WebTwain` `Viewer`. - [`GetImagePartURL(imageIndex)`](/_articles/info/api/WebTwain_Buffer.md#getimageparturl) retrieves the URL of the image at the specified index, but using the `dwt://` scheme, which can only be used by other DWT APIs. - [`GetSkewAngle(imageIndex)`](/_articles/info/api/WebTwain_Buffer.md#getskewangle) estimates the skew angle of scanned documents in degrees. This can be used to de-skew scanned images, which may be useful for last minute touch-ups. (see image rotation in our [image editing guide](/_articles/general-usage/image-processing/image-editing.md#example---rotating-images)) - [`GetSkewAngleEx(imageIndex, leftmost, topmost, rightmost, bottommost)`](/_articles/info/api/WebTwain_Buffer.md#getskewangleex) calculates the skew angle of a rectangle (specified by its outermost pixel coordinates) within the image. This feature is only supported in [desktop browsers]({{site.getstarted}}platform.html#browsers-on-desktop-devices). Some buffer management APIs work on images that have been "selected", for example, calculating the disk space required by selected images. The user may also select images through the `Viewer` interface, which also visually indicates selected images. The selection APIs are described below: - [`SelectImages(indexArray)`](/_articles/info/api/WebTwain_Buffer.md#selectimages) selects images using an array of image indices. Note that there is no dedicated API for selecting a single image, so we use the form `SelectImages([singleImageIndex])` instead. - [`SelectAllImages()`](/_articles/info/api/WebTwain_Buffer.md#selectallimages) selects all the images in the buffer. - [`SelectedImagesIndices`](/_articles/info/api/WebTwain_Buffer.md#selectedimagesindices) is a read-only array containing the indices of the currently selected images. ## Reordering Images The `WebTwain` instance provides a set of simple buffer reordering APIs to move images around. Note that users also have the option to click and drag images in the `Viewer` to reorder images as well. The following sample demonstrates moving images, switching images, and removing images in the buffer. ### Sample Code ```html





``` APIs used: - [`Dynamsoft.DWT.RegisterEvent()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#registerevent) - [`Dynamsoft.DWT.GetWebTwain()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain) - [`OnWebTwainReady`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainready) - [`cursor`](/_articles/info/api/WebTwain_Viewer.md#cursor) - [`setViewMode()`](/_articles/info/api/WebTwain_Viewer.md#setviewmode) - [`AcquireImageAsync()`](/_articles/info/api/WebTwain_Acquire.md#acquireimageasync) - [`IfCloseSourceAfterAcquire`](/_articles/info/api/Device.md#deviceobjectacquireimage) - [`MoveImage()`](/_articles/info/api/WebTwain_Buffer.md#moveimage) - [`SwitchImage()`](/_articles/info/api/WebTwain_Buffer.md#switchimage) - [`RemoveImage()`](/_articles/info/api/WebTwain_Buffer.md#removeimage) - [`RemoveAllImages()`](/_articles/info/api/WebTwain_Buffer.md#removeallimages) - [`HowManyImagesInBuffer`](/_articles/info/api/WebTwain_Buffer.md#howmanyimagesinbuffer) - [`SelectImages()`](/_articles/info/api/WebTwain_Buffer.md#selectimages) - [`RemoveAllSelectedImages()`](/_articles/info/api/WebTwain_Buffer.md#removeallselectedimages) ### Explanation After scanning a few images using DWT, the user can use buttons to move images around within the buffer. These APIs identify images using their indices within the buffer (zero-indexed). These APIs return their success state upon completion, as they do not support success callbacks. Note that this sample wraps the API to check for the number of images within the buffer before attempting to move images. This prevents moving or selecting invalid indices. For illustration purposes, we set the `Viewer` to show multiple images at a time, and changed the cursor shape for this sample. ## Tagging Images DWT can tag images for custom grouping, sorting, and other data management tasks, using the [TagImages()](/_articles/info/api/WebTwain_Buffer.md#tagimages) API. Tags are strings associated with images for identification purposes. Images may have multiple tags as well. ### Setting Tags For example, we may tag individual images with the "title" tag to identify title pages with [TagImages()](/_articles/info/api/WebTwain_Buffer.md#tagimages), like so: ```javascript DWTObject.TagImages([0, 1], "title"); ``` This applies the tag to the first and second images in the buffer (zero-indexed). If image indices are not known ahead of time, it's also useful to apply the tag to the currently displayed image in the viewer, via the [`CurrentImageIndexInBuffer`](/_articles/info/api/WebTwain_Buffer.md#currentimageindexinbuffer) property. This allows the user to tag the image upon inspection. ```javascript DWTObject.TagImages([DWTObject.CurrentImageInBuffer], "title"); ``` Rather than applying tags to existing images, it is possible to tag images as they enter the buffer via [SetDefaultTag()](/_articles/info/api/WebTwain_Buffer.md#setdefaulttag). By changing the default tag in reaction to application state, the web application can create rich image tagging logic: ```javascript DWTObject.SetDefaultTag("title"); ``` Every image entering the buffer after this will automatically receive this tag. ### Organizing Images with Tags Tags are only useful if they can be interacted with. Once images have been tagged, we can filter them by their tags. For example, a user may need to display only the title pages for preview purposes. Once title pages have been tagged (either as they were scanned or after the fact), we can use [FilterImagesByTag()](/_articles/info/api/WebTwain_Buffer.md#filterimagesbytag) to selectively display just the title pages: ```javascript DWTObject.FilterImagesByTag("title"); ``` Once the user finishes with the preview, DWT can revert to displaying all images by clearing the filter with [ClearFilter()](/_articles/info/api/WebTwain_Buffer.md#clearfilter): ```javascript DWTObject.ClearFilter(); ``` Be sure to visit our [buffer API reference](/_articles/info/api/WebTwain_Buffer.md) to learn more about various tagging features. ## Organizing Images with Documents Documents are another way to organize images within the image buffer. We may create multiple documents to group images, but unlike tags, images can each only belong to one document. Documents also preserve image order. First, we create a document with [CreateDocument()](/_articles/info/api/WebTwain_Buffer.md#createdocument): ```javascript DWTObject.CreateDocument("documentName"); ``` To add images into the document, we first open the document with [OpenDocument()](/_articles/info/api/WebTwain_Buffer.md#opendocument), and specifying the document by name: ```javascript DWTObject.OpenDocument("documentName"); ``` Subsequently, all images entering the buffer will belong to this document. Only one document may be open at a time - opening another document would close the previously open one. We may also move images after they have entered documents, for example, to copy images from one document to another with [CopyToDocumentAsync()](/_articles/info/api/WebTwain_Buffer.md#coppytodocumentasync): ```javascript DWTObject.CopyToDocumentAsync("sourceDocumentName", "destinationDocumentName", sourceIndices, targetIndex) ``` Which copies the selected images from `sourceDocumentName` with `sourceIndices` and moves them to the destination at the `targetIndex`. This API has a few overloads to specify targets and sources in different ways, refer to our [documentation](/_articles/info/api/WebTwain_Buffer.md#coppytodocumentasync) for more details. DWT also provides other document-related APIs, check them out in our [buffer API reference](/_articles/info/api/WebTwain_Buffer.md). ## Querying Image Data DWT provides APIs to quickly retrieve image metadata. The following retrieves data for an image at the specified buffer index: * Pixel bit depth: [`GetImageBitDepth(imageIndex)`](/_articles/info/api/WebTwain_Buffer.md#getimagebitdepth) * Image pixel height: [`GetImageHeight(imageIndex)`](/_articles/info/api/WebTwain_Buffer.md#getimageheight) * Image pixel width: [`GetImageWidth(imageIndex)`](/_articles/info/api/WebTwain_Buffer.md#getimagewidth) * Horizontal image resolution (in DPI): [`GetImageXResolution(imageIndex)`](/_articles/info/api/WebTwain_Buffer.md#getimagexresolution) * Vertical image resolution (in DPI): [`GetImageYResolution(imageIndex)`](/_articles/info/api/WebTwain_Buffer.md#getimageyresolution) Additionally, the following APIs used calculate image sizes are only supported by [desktop browsers]({{site.getstarted}}platform.html#browsers-on-desktop-devices): * Calculate the number of bytes the image would take up when resized to the specified dimensions: [ `GetImageSize(imageIndex, width, height)` ](/_articles/info/api/WebTwain_Buffer.md#getimagesize) * Calculate the number of bytes the image would take up upon conversion to a specific image format: [ `GetImageSizeWithSpecifiedType(imageIndex, imageType)` ](/_articles/info/api/WebTwain_Buffer.md#getimagesizewithspecifiedtype) * Refer to [Dynamsoft.DWT.EnumDWT_ImageType](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype) for image formats. * Calculate the total number of bytes of all selected images given an expected file format: [ `GetSelectedImagesSize(imageType)` ](/_articles/info/api/WebTwain_Buffer.md#getselectedimagessize) * Refer to [Dynamsoft.DWT.EnumDWT_ImageType](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype) for image formats. * Images must first be selected by index via [SelectImages()](/_articles/info/api/WebTwain_Buffer.md#selectimages). There must be at least one image selected for a valid call to `GetImageSize()`. ## Detecting Blank Pages The buffer also comes with a set of APIs specifically to detect blank pages: - [`IsBlankImage(imageIndex)`](/_articles/info/api/WebTwain_Buffer.md#isblankimage) determines whether or not the given page is blank. This is relatively accurate. - [`IsBlankImageExpress(imageIndex)`](/_articles/info/api/WebTwain_Buffer.md#isblankimageexpress) detects whether or not the given page is blank, but it trades worse accuracy for higher speed. - [`IsBlankImageAsync(imageIndex, { minBlockHeight, maxBlockHeight })`](/_articles/info/api/WebTwain_Buffer.md#isblankimageasync) can optionally detect blank pages with a certain tolerance for markings within the specified size range. > Tip: At times, blank page detection APIs will still fail to detect some pages as blank. We can loosen the detection tolerance by reading [`BlankImageCurrentStdDev`](/_articles/info/api/WebTwain_Buffer.md#blankimagecurrentstddev) to get the tolerance for the current image, then increasing the tolerance by setting a new value for the [`BlankImageMaxStdDev`](/_articles/info/api/WebTwain_Buffer.md#blankimagemaxstddev) property. Note that the first property is read-only for safety reasons. ## Using Buffer Event Callbacks The image buffer provides event callbacks which can be used to customize buffer behavior. Listeners can be attached to these events via the `WebTwain` object's [RegisterEvent()](/_articles/info/api/WebTwain_Util.md#registerevent) API. Note that this is distinct from the global [RegisterEvent()](/_articles/info/api/Dynamsoft_WebTwainEnv.md#registerevent) which is called from `Dynamsoft.DWT`. - [`OnBufferChanged`](/_articles/info/api/WebTwain_Buffer.md#onbufferchanged) triggers whenever the state of the buffer changes. The details on how the buffer changes are provided in [`BufferChangeInfo`](/_articles/info/api/interfaces.md#bufferchangeinfo): ```javascript DWTObject.RegisterEvent('OnBufferChanged', function (bufferChangeInfo: BufferChangeInfo) { } ): boolean; ``` - [`OnBitmapChanged`](/_articles/info/api/WebTwain_Buffer.md#onbitmapchanged) triggers whenever image data changes. Specifically, when: - an image enters the buffer - an image is removed from the buffer - an image image in the buffer is edited * [`OnTopImageInTheViewChanged`](/_articles/info/api/WebTwain_Buffer.md#ontopimageintheviewchanged) triggers when the first image visible in the `Viewer` changes. (The viewer may be configured to show more than one image at a time, see the [`Viewer` guide](/_articles/general-usage/viewer-configuration.md) for details). ```javascript DWTObject.RegisterEvent( 'OnBitmapChanged', function( updatedIndices, operationType, currentIndex) { console.log(updatedIndices); } ) ``` * [ `OnIndexChangeDragDropDone` ](/_articles/info/api/WebTwain_Buffer.md#onindexchangedragdropdone) triggers when the user reorders images by dragging them around using the `Viewer`. These events are useful for enhancing and customizing the graphical user experience.
--- title: Dynamic Web TWAIN SDK Basics - Editing Images description: Dynamic Web TWAIN SDK General Usage Guide - Image Editing source_url: html: https://www.dynamsoft.com/web-twain/docs/general-usage/image-processing/image-editing.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/general-usage/image-processing/image-editing.md --- # Editing Images > Prerequisite: [DWT Initialization](/_articles/general-usage/initialization.md)
> Prerequisite: [Managing the Image Buffer](/_articles/general-usage/image-processing/buffer-management.md) DWT provides a wide range of common image editing features to modify scanned documents in web applications. The editing APIs are straight-forward for developers to implement rich editing features. ## Example - Rotating Images We first demonstrate the use of our image rotation API, which allows users to rotate scanned images and immediately view the results in the `Viewer`. We also provide a list of other editing APIs which can be easily substituted into the sample shown below. ### Sample Code ```html


``` APIs used: - [`Dynamsoft.DWT.RegisterEvent()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#registerevent) - [`Dynamsoft.DWT.GetWebTwain()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain) - [`OnWebTwainReady`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainready) - [`Rotate()`](/_articles/info/api/WebTwain_Edit.md#rotate) - [`CurrentImageIndexInBuffer`](/_articles/info/api/WebTwain_Buffer.md#currentimageindexinbuffer) This sample rotates an image with the [`Rotate()`](/_articles/info/api/WebTwain_Edit.md#rotate) by the specified number of degrees. This can be applied to any scanned image given its index, but usually it is best to apply it to the image currently being viewed. We use the [`CurrentImageIndexInBuffer`](/_articles/info/api/WebTwain_Buffer.md#currentimageindexinbuffer) property to grab the index of the displayed image to rotate it in view of the user. We can also choose to preserve the size of the image by cutting off rotated edges as is done in the sample, or shrink the image during rotation to retain the edges. Note that the two callbacks are optional arguments. ## Example - Changing Interpolation Methods Many DWT editing APIs can use different built-in image interpolation methods to suit different usage scenarios. To demonstrate these interpolation methods,we use the extended rotation API, which uses a specified interpolation method during the rotation. Use the following sample to see it in action: ```html


``` APIs used: - [`Dynamsoft.DWT.RegisterEvent()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#registerevent) - [`Dynamsoft.DWT.GetWebTwain()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain) - [`OnWebTwainReady`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainready) - [`RotateEx()`](/_articles/info/api/WebTwain_Edit.md#rotateex) - [`CurrentImageIndexInBuffer`](/_articles/info/api/WebTwain_Buffer.md#currentimageindexinbuffer) - [`Dynamsoft.DWT.EnumDWT_InterpolationMethod`](/_articles/info/api/WebTwain_Buffer.md#currentimageindexinbuffer) ### Explanation The function call is similar to the sample with the regular `Rotate()` API, just with an added parameter for the interpolation method. The interpolation method is defined by the [`Dynamsoft.DWT.EnumDWT_InterpolationMethod`](/_articles/info/api/WebTwain_Buffer.md#currentimageindexinbuffer) enumeration. Though [`RotateEx()`](/_articles/info/api/WebTwain_Edit.md#rotateex) can use the numeric directly, we recommend using the enumeration for legibility. ## Common Editing APIs These four groups of commonly used editing features may be called in a similar fashion, as demonstrated above. They can all be optionally called with success and failure callbacks. ### Rotating Images - `DWTObject.Rotate(imageIndex, degrees)` Rotate an image at the specified image index in the image buffer using an interpolation method specified by `Dynamsoft.DWT.EnumDWT_InterpolationMethod`: - `DWTObject.RotateEx(imageIndex, degrees, interpolationMethod)` Rotate the specified image 90 degrees counterclockwise: - `DWTObject.RotateLeft(imageIndex)` Rotate the specified image 90 degrees clockwise: - `DWTObject.RotateRight(imageIndex)` Flip the specified image vertically: - `DWTObject.Flip(imageIndex)` Flip the specified image horizontally: - `DWTObject.Mirror(imageIndex)` ### Cutting, Cropping, and Copying Images - Crop a rectangular area from the specified image using outermost pixel coordinates: `DWTObject.Crop(imageIndex, leftmost, topmost, rightmost, bottommost)` - Copy the specified image to the system clipboard: `DWTObject.CopyToClipboard(imageIndex)` - Copy the specified image to the system clipboard and remove the image from the image buffer: `DWTObject.CutToClipboard(imageIndex)` - Crop a rectangular area from the specified image using outermost pixel coordinates, and send it to the clipboard of the operating system: `DWTObject.CropToClipboard(imageIndex, leftmost, topmost, rightmost, bottommost)` - Crop a rectangular area from the specified image using outermost pixel coordinates, and send it to the clipboard of the operating system. Then, remove the area from the image: `DWTObject.CutFrameToClipboard(imageIndex, leftmost, topmost, rightmost, bottommost)` - Remove a rectangular area from the specified image using outermost pixel coordinates: `DWTObject.Erase(imageIndex, leftmost, topmost, rightmost, bottommost)` ### Resizing Images - Scale the specified image to the given length and width (in pixel distances), using an interpolation method specified by `Dynamsoft.DWT.EnumDWT_InterpolationMethod`: `DWTObject.ChangeImageSize(imageIndex, newWidth, newHeight, interpolationMethod)` - Scale the image to the given width in pixel distance (and retaining the height) by adding a margin or removing part of the image: `DWTObject.SetImageWidth(imageIndex, newWidth)` ### Converting Image Resolution, Color mode, and Pixel Bit Depth - Alter the bit depth of the specified image (bit depths are either 1, 4, 8, or 24). `highQuality` is a boolean quality toggle: `DWTObject.ChangeBitDepth(imageIndex, bitDepth, highQuality)` - Change the resolution of the specified image to the given DPI. `resample` is a boolean resampling toggle, and `Dynamsoft.DWT.EnumDWT_InterpolationMethod` determines the interpolation used: `DWTObject.SetDPI(imageIndex, xResolution, yResolution, resample, interpolationMethod)` - Convert the specified image to black-and-white: `DWTObject.ConvertToBW(imageIndex)` - Convert the specified image to grayscale `DWTObject.ConvertToGrayScale(imageIndex)` - Invert the colors of the specified image `DWTObject.Invert(imageIndex)`
--- title: Dynamic Web TWAIN SDK Basics - Processing Images description: Dynamic Web TWAIN SDK General Usage Guide - Processing Images source_url: html: https://www.dynamsoft.com/web-twain/docs/general-usage/image-processing/index.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/general-usage/image-processing/index.md --- # Processing Images DWT has a large host of image processing tools when using it as a web-based document viewer. These include powerful image editing APIs, combined with a comprehensive buffer management system. We may use the viewer to visualize changes in the buffer in real time. Read on to learn more about data handing and image editing. ### Table of Contents - [Managing the Image Buffer](/_articles/general-usage/image-processing/buffer-management.md) - [Editing Images](/_articles/general-usage/image-processing/image-editing.md) --- title: Dynamic Web TWAIN SDK General Usage Guide description: Dynamic Web TWAIN SDK General Usage Guide source_url: html: https://www.dynamsoft.com/web-twain/docs/general-usage/index.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/general-usage/index.md --- # General Usage Guide Here we present a comprehensive guide on how to develop a web application with scanning capabilities using DWT. ### Table of Contents - [Loading Library Resources](/_articles/general-usage/resource-loading.md) - [License](/_articles/general-usage/license.md) - [Initializing DWT](/_articles/general-usage/initialization.md) - [Acquiring Images from Scanners](/_articles/general-usage/scanner-image-acquisition.md) - [Configuring the Viewer](/_articles/general-usage/viewer-configuration.md) - [Processing Images](/_articles/general-usage/image-processing/index.md) - [Exporting Images](/_articles/general-usage/image-export/index.md) - [Server-Side Scripting](/_articles/general-usage/server-side-scripting.md) - [Deploying to the Server](/_articles/general-usage/server-deployment.md) These guides cover all simple tools required to scan, view, and edit images, and then send them to the web server. Check out our Hello World guide [here](/_articles/hello-world/index.md) for a quick demonstration of these tools. Start by learning how to initialize DWT in your web application. After that, feel free to read the other sections in no particular order. --- title: Dynamic Web TWAIN SDK Basics - Initializing DWT description: Dynamic Web TWAIN SDK General Usage Guide - Initializing DWT source_url: html: https://www.dynamsoft.com/web-twain/docs/general-usage/initialization.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/general-usage/initialization.md --- # Initializing DWT > Prerequisite: [Loading Library Resources](/_articles/general-usage/resource-loading.md) This article explores how to initialize the **DWT SDK** (**DWT**) for use in a web application. The main goal is to instantiate the **`WebTwain`** object, which is the entrypoint to most DWT functionalities, such as image scanning, image viewing, file uploading, and more. To load resources using other methods (via CDN or package manager), read our [resource loading guide](/_articles/extended-usage/advanced-initialization.md). ## Sample Code The following is a minimal amount of sample code needed to create a web application that initializes DWT loading resource files found in our [official SDK](https://www.dynamsoft.com/web-twain/downloads). ```html
``` APIs used: - [`Dynamsoft.DWT.RegisterEvent()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#registerevent) - [`Dynamsoft.DWT.GetWebTwain()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain) - [`OnWebTwainReady`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainready) > DWT resides in the `Dynamsoft` namespace. Specifically, most DWT features reside within `Dynamsoft.DWT`. ### Running the Sample Code For demonstration purposes, save the sample in an HTML file (e.g. `helloWorld.html`) in a new directory. Then, open the HTML file in a browser, and the DWT UI should display a loading animation. To **verify** that the `WebTwain` object has been instantiated, you can uncomment the verification code block. Otherwise, click [here](/_articles/general-usage/server-deployment.md) to learn how to deploy DWT on your web server. > If your environment does not have **Dynamic Web TWAIN Service** installed or local network access is not granted, a prompt will appear to ask you to install the service. You can learn more about what the service does [here](/_articles/faq/what-does-dynamsoft-service-do-on-end-user-machine.md). Below is more detail on what happens during initialization and how to retrieve the `WebTwain` object. ## Explanation Initializing DWT means making its features available for use, e.g. so the web application can scan, view, and upload images. This process begins with loading the resource files. By default, initialization also performs a few other tasks as outlined below. ### The `WebTwain` and `Viewer` Objects During DWT initialization under default configurations, DWT **instantiates** a `WebTwain` object, as well as a `Viewer` object as a member of that `WebTwain` object. The `WebTwain` object contains most DWT APIs. Furthermore, the `Viewer` within the `WebTwain` object represents the viewer UI, so the `Viewer` is used to control UI features such as displaying scan previews, editing scanned images, etc. The `Viewer` is bound to the following html element: ```html
``` Make sure that this `div` exists in the DOM. The `WebTwain` instance also uses the `id` as an identifier. We use this identifier to get the `WebTwain` instance with [`GetWebTwain()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain). ## Retrieving the `WebTwain` Object It is important to access the `WebTwain` object only after it has been instantiated. We can do this by registering the [`OnWebTwainReady`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainready) event, then invoking [`GetWebTwain()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain) in the callback function. This ensures that we do not try to access the `WebTwain` object before it is instantiated. Once we can access the `WebTwain` object, we can proceed to use powerful features within DWT. ## Further Reading For advanced DWT initialization methods, including changing default configurations, or instantiating a `WebTwain` instance without a `Viewer`, take a look at the [advanced initialization guide](/_articles/extended-usage/advanced-initialization.md).
--- title: Dynamic Web TWAIN SDK License description: Dynamic Web TWAIN SDK Documentation License Page source_url: html: https://www.dynamsoft.com/web-twain/docs/general-usage/license.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/general-usage/license.md --- # Using License Keys Dynamic Web TWAIN (DWT) requires a valid license key to function. License keys authorize the use of DWT, as well as any configured add-on modules. ## Use Trial Licenses You can request a trial license of Dynamic Web TWAIN through our customer portal, and we will email you your trial license key. You can also contact our [support team](https://www.dynamsoft.com/company/contact/) for new licenses and/or trial license extensions. ### Configure Trial License Keys License keys are configured in the [`Dynamsoft.DWT.ProductKey`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#productkey) property. (**Note**: prior to version 17.0, this property was `Dynamsoft.WebTwainEnv.ProductKey`). The configuration differs depending on how a project loads DWT resource files (see [loading library resources](/_articles/general-usage/resource-loading.md) for more details). Trial key strings typically have the `t0076` prefix.
- [Official SDK](#trial-keys-with-sdk) - [Package Managers](#trial-keys-with-package-managers)
1. Locate the `dynamsoft.webtwain.config.js` file (or search for `ProductKey`). 2. Assign the license key string to [`Dynamsoft.DWT.ProductKey`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#productkey): ```javascript Dynamsoft.DWT.ProductKey = 't0076******'; // Use an offline trial key ``` 3. Load (or reload, if replacing an existing key) the web application and see that it starts scanning.
When using package managers such as `npm`, be sure to check out our web framework samples. Roughly speaking, it involves setting `Dynamsoft.DWT.ProductKey` before calling either [`Dynamsoft.DWT.Load()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#load) or [`Dynamsoft.DWT.CreateDWTObjectEx()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#createdwtobjectex): - [Use Web TWAIN in Angular](/_articles/indepth/development/angular.md) - [Use Web TWAIN in React](/_articles/indepth/development/react.md) - [Use Web TWAIN in Vue](/_articles/indepth/development/vue.md)
## Using Full Licenses Contact our [sales team](https://www.dynamsoft.com/store/dynamic-web-twain/) to purchase full licenses for Dynamic Web TWAIN. Use our customer portal to manage full licenses. Full licenses are either offline licenses, or DLS-connected licenses. DLS-connected licenses contact DLS servers for authentication purposes - please see [Dynamsoft License Server](https://www.dynamsoft.com/license-server/docs/about/index.html) for more details. Full licenses may also be configured with add-on modules. ### Acquiring Full Keys
- [DLS-Connected Keys](#get-dls-keys) - [Offline Keys](#get-offline-keys)
DLS-connected license keys begin with the `DLS` prefix. Learn more about the Dynamsoft Licensing Server [here](https://www.dynamsoft.com/license-server/docs/about/activate.html). 1. Without add-ons: activate the license in the customer portal, then acquire the DLS key. This key only authorizes the use of the core DWT module. 2. With add-ons: activate the license and configure the core DWT module along with add-ons into one project in DLS, then acquire the DLS key. This authorizes the use of the add-on modules on top of the core module.
Offline license keys usually begin with the `f00` prefix. 1. Without add-ons: activate the license in the customer portal, then acquire the offline key. This key only authorizes the use of the core DWT module. 2. With add-ons: activate the license in the customer portal, then acquire the offline keys. This may result in multiple license keys - one for the base DWT module, and separate ones for the add-ons. To use multiple keys in a single project, concatenate them (in any order) into a single string, separated with semicolons.
### Configuring Full License Keys To use a full license key, set the value of [`Dynamsoft.DWT.ProductKey`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#productkey) to the key string. (**Note**: prior to version 17.0, this property was `Dynamsoft.WebTwainEnv.ProductKey`) The configuration differs depending on how a project loads DWT resource files (see [loading library resources](/_articles/general-usage/resource-loading.md) for more details).
- [DLS-Connected Keys](#use-dls-keys) - [Offline Keys](#use-offline-keys) - [Multiple Offline Keys](#use-multiple-offline-keys) - [Package Managers](#full-keys-with-package-managers)
1. Locate the `dynamsoft.webtwain.config.js` file (or search for `ProductKey`). 2. Assign the license key string to [`Dynamsoft.DWT.ProductKey`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#productkey): ```javascript Dynamsoft.DWT.ProductKey = 'DLS******'; // Use an online key ``` 3. Load (or reload, if replacing an existing key) the web application and see that it starts scanning.
1. Locate the `dynamsoft.webtwain.config.js` file (or search for `ProductKey`). 2. Assign the license key string to [`Dynamsoft.DWT.ProductKey`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#productkey): ```javascript Dynamsoft.DWT.ProductKey = 'f00******;'; // Use an offline key ``` 3. Load (or reload, if replacing an existing key) the web application and see that it starts scanning.
Offline license keys with add-ons should be concatenated (in any order) into a single string, separated with semicolons, and assigned to the same property (e.g. `f00******;f00******`). 1. Locate the `dynamsoft.webtwain.config.js` file (or search for `ProductKey`). 2. Assign the license key string to [`Dynamsoft.DWT.ProductKey`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#productkey): ```javascript Dynamsoft.DWT.ProductKey = 'f00******;f00******'; // Use multiple offline keys ``` 3. Load (or reload, if replacing an existing key) the web application and see that it starts scanning.
When using package managers such as `npm`, be sure to check out our web framework samples. Roughly speaking, it involves setting `Dynamsoft.DWT.ProductKey` before calling either [`Dynamsoft.DWT.Load()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#load) or [`Dynamsoft.DWT.CreateDWTObjectEx()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#createdwtobjectex): - [Use Web TWAIN in Angular](/_articles/indepth/development/angular.md) - [Use Web TWAIN in React](/_articles/indepth/development/react.md) - [Use Web TWAIN in Vue](/_articles/indepth/development/vue.md)
## License Agreement View the Dynamic Web TWAIN License Agreement here.
--- title: Dynamic Web TWAIN SDK Basics - Loading Library Resources description: Dynamic Web TWAIN SDK General Usage Guide - Loading Library Resources source_url: html: https://www.dynamsoft.com/web-twain/docs/general-usage/resource-loading.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/general-usage/resource-loading.md --- # Loading Library Resources Before using the **Dynamic Web TWAIN SDK** (DWT), the web application must first load its resource files. These resource files may be gathered from three locations, with slightly different characteristics. DWT provides **core resources** (i.e. core functionality) that load directly into the web application. This in turn loads **supporting resources**, which include add-ons, css, and more - read about them in detail [here](/_articles/faq/what-are-the-resources-files.md). ## Note on File Size The installers for the [Dynamic Web TWAIN Service](/_articles/extended-usage/dynamsoft-service-configuration.md) are numerous and take up a lot of disk space. We may save disk space by removing unused installers for unused platforms/architectures if called for, whether for deployment or for development environments. The official SDK installers store the installers under the `/dist` directory, and the package managers/CDNs keep them under `/dist/dist`. For example, if the web application does not support end users on Linux-based platforms, we may elect to remove `DynamicWebTWAINServiceSetup.deb`, `DynamicWebTWAINServiceSetup.rpm`, etc. ## Loading from Official SDK Package The official [DWT installer](https://www.dynamsoft.com/web-twain/downloads) installs the SDK with a 30-day free trial (license key included), and contains the resource scripts, along with SDK documentation, and samples. This method is useful for developers to quickly evaluate the SDK. The resource files may be obtained from the following locations after installation: - On Windows: `C:\Program Files (x86)\Dynamsoft\Dynamic WebTWAIN SDK {version number}\Resources` - On Linux: Where you extracted the SDK archive file to - `{extracted directory}/Dynamic Web TWAIN SDK {version number}/Resources` - On MacOS: `/Applications/Dynamsoft/Dynamic Web TWAIN SDK {version number}/Resources` In which case they load like so: ```html ``` This method organizes the resources a little differently compared to the files from the CDNs and the package managers. Here, the **core resources** are loaded using two JavaScript files, which do not contain add-ons. These two files load other **supporting resource files** in turn (such as add-on resource files, css, and more - read about them in detail [here](/_articles/faq/what-are-the-resources-files.md)) found in the SDK directories. Here is a quick introduction to the core resource files: - `dynamsoft.webtwain.initiate.js` - This file contains the core DWT JavaScript library. - `dynamsoft.webtwain.config.js` - This file contains basic DWT configurations, e.g. configuring the product key, changing the initial dimensions of the image viewer, etc. Though these core resource files do not contain add-ons, we may load add-on resource files from the `{local SDK directory}/Resources/addon` directory. (just make sure that the license key permits the use of the add-on(s)) The 30-day trial license key that comes with the install includes all add-ons. ## Loading from CDN The most straight-forward method of loading resources is to fetch them from CDNs. (Both CDNs provide identical files) DWT resource files are hosted on [jsDelivr](https://jsdelivr.com/) and [UNPKG](https://unpkg.com/). Unlike our official SDK package, the CDNs require the user to supply a license key. See our [licensing page](/_articles/general-usage/license.md) for more details, and request a trial license [here](https://www.dynamsoft.com/customer/license/trialLicense/?product=dwt). The resources obtained from the package managers differ slightly from the ones found in the official SDK package, in that it has the property `Dynamsoft.DWT.AutoLoad = false`, whereas it is `true` in the official SDK package. This property controls initialization behavior; read our [initialization guide](/_articles/extended-usage/advanced-initialization.md) to learn more. Simply create a `script` element like so: ### Loading from [UNPKG](https://unpkg.com/dwt@latest/dist/dynamsoft.webtwain.min.js) ```html ``` APIs used: - [`Dynamsoft.DWT.ResourcesPath`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#resourcespath) - [`Dynamsoft.DWT.ProductKey`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#productkey) ### Loading from [jsDelivr](https://cdn.jsdelivr.net/npm/dwt@latest/dist/dynamsoft.webtwain.min.js) Note that jsDelivr currently has problems delivering the Dynamic Web TWAIN Service installer (`https://cdn.jsdelivr.net/npm/dwt@latest/dist/dist/`) due to [size restrictions](https://www.jsdelivr.com/documentation#id-configuring-a-default-file-in-packagejson); please consider hosting this particular resource file elsewhere. UNPKG is currently unaffected. For information about the Dynamic Web TWAIN Service, learn more [here](/_articles/extended-usage/dynamsoft-service-configuration.md). ```html ``` APIs used: - [`Dynamsoft.DWT.ResourcesPath`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#resourcespath) - [`Dynamsoft.DWT.ProductKey`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#productkey) ### Explanation These two CDNs provide the file `dynamsoft.webtwain.min.js`, which contains the core of the DWT library, as well as add-ons (e.g. [PDF Rasterizer](https://www.dynamsoft.com/web-twain/pdf-to-image-javascript/) and others). The remaining resources are loaded in from the same path, which should be declared as a property. Note that an appropriate license key is required to use the add-on(s). ## Loading from Package Managers The resources obtained from the package managers differ slightly from the ones found in the official SDK package, in that it has the property `Dynamsoft.DWT.AutoLoad = false`, whereas it is `true` in the official SDK package. This property controls initialization behavior; read our [initialization guide](/_articles/extended-usage/advanced-initialization.md) to learn more. Just like the CDNs, the package managers require the users to supply a license key. See our [licensing page](/_articles/general-usage/license.md) for more details, and request a trial license [here](https://www.dynamsoft.com/customer/license/trialLicense/?product=dwt). The DWT package is hosted on both `npm` and `yarn` (both packages are identical), and the installation commands are as follows: ### Installing from `npm`: ```shell npm install dwt ``` ### Installing from `yarn`: ```shell yarn add dwt ``` The package managers provide dynamsoft.webtwain.min.mjs, which is an ECMAScript module containing core DWT resources, including add-on functionality. The files provided are the same regardless of the package manager used. The licensing restrictions for using add-on functionality are the same as those for files loaded from the CDN. This file is loaded as an ECMAScript module: ```html import Dynamsoft from 'dwt'; Dynamsoft.DWT.ResourcesPath = "your-resources-path"; // Load supporting resources from here Dynamsoft.DWT.ProductKey = "your-product-key"; ``` APIs used: - [`Dynamsoft.DWT.ResourcesPath`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#resourcespath) - [`Dynamsoft.DWT.ProductKey`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#productkey) ### Official Sample Check out the following sample project: * [dwt-angular-advanced](https://github.com/dynamsoft-dwt/dwt-angular-advanced) * [dwt-react-advanced](https://github.com/Dynamsoft/web-twain-react-advanced) * [dwt-vue](https://github.com/Dynamsoft/web-twain-vue-advanced) --- title: Dynamic Web TWAIN SDK Basics - Acquiring Images from Scanners description: Dynamic Web TWAIN SDK General Usage Guide - Acquiring Images from Scanners source_url: html: https://www.dynamsoft.com/web-twain/docs/general-usage/scanner-image-acquisition.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/general-usage/scanner-image-acquisition.md --- # Acquiring Images from Scanners > Prerequisite: [DWT Initialization](/_articles/general-usage/initialization.md) DWT can import images in a few different ways, the most common which is to acquire images from image sources, which are scanners and other imaging hardware. (We can also load image files, both from the local file system and over the network, as explained [here](/_articles/extended-usage/file-import.md)) After the web application has initialized DWT and instantiated a `WebTwain` object, the `WebTwain` object can perform image acquisition, which is a term that includes scanning and file input. We will first go over scanning in this section. Note that we also provide an add-on for webcam-based scanning, which you can learn more about [here](/_articles/info/api/Addon_Webcam.md). ## Acquisition from All Available Scanners Here, we present a web application with full image scanning capabilities. The user can click the "Scan" button to select a detected scanner, then set scanning options. Once image acquisition finishes, `WebTwain` `Viewer` displays the image in the web application. ### Sample Code ```html
``` APIs used: - [`RegisterEvent()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#registerevent) - [`OnWebTwainReady`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainready) - [`GetWebTwain()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain) - [`SelectSourceAsync()`](/_articles/info/api/WebTwain_Acquire.md#selectsourceasync) - [`AcquireImageAsync()`](/_articles/info/api/WebTwain_Acquire.md#acquireimageasync) - [`IfCloseSourceAfterAcquire`](/_articles/info/api/Device.md#deviceobjectacquireimage) ### Explanation #### Selecting the Data Source Upon calling the `AcquireImage()` function through the button click, `SelectSourceAsync()` opens up the source selector UI. The promise resolves once the user selects the desired data source and closes the UI, upon which the `WebTwain` instance opens the data source. > Note: An imaging device typically refers to physical hardware that provides image data, most notably scanners. An image/data source refers to the logical representation of imaging devices, which allows software to interface with the imaging device. #### Acquiring the Image Next up, calling `SelectSourceAsync()` on the `WebTwain` instance initiates image acquisition from the previously opened data source. This step opens up the data source UI, which is specific to the selected data source. Once the user selects scan options and confirms the scan, the data source UI closes, and DWT sends the scan command. Once the `WebTwain` instance acquires the image, the instance's `Viewer` component displays the image on the web page. Finally, `AcquireImageAsync()` closes the data source after completing the scan, because we passed it a [`DeviceConfiguration`](/_articles/info/api/interfaces.md#DeviceConfiguration) argument, where we set `IfCloseSourceAfterAcquire` to `true`. ## Specifying Scanner Protocol `SelectSourceAsync()` can take an [`EnumDWT_DeviceType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_devicetype) argument to specify data sources using particular scanning protocols, and show only those data sources in the source selection UI. This may be useful in an internal use scenario where there is knowledge about the scanner hardware being used with DWT. For example, to show only eSCL data sources, we use the `Dynamsoft.DWT.EnumDWT_DeviceType.ESCLSCANNER` enum like so: ```javascript function AcquireImage() { if (DWTObject) { DWTObject.SelectSourceAsync(Dynamsoft.DWT.EnumDWT_DeviceType.ESCLSCANNER) .then(function () { return DWTObject.AcquireImageAsync({ IfCloseSourceAfterAcquire: true, }); }) .catch(function (exp) { alert(exp.message); }); } } ``` ## Specifying Scanning Options Many use cases require a pre-specified set of scanning options (such as, but not limited to color mode and resolution) to be applied on the scan. We can pass these arguments to the image source using the [`DeviceConfiguration`](/_articles/info/api/interfaces.md#DeviceConfiguration) passed to `AcquireImageAsync()`. For example, these object properties specify the following: - `IfShowUI: false` turns off the **image source UI** (the second menu) to prevent the user from overriding the scan configuration. - `PixelType: Dynamsoft.DWT.EnumDWT_PixelType.TWPT_BW` sets the color mode to binary (black and white) using the [`Dynamsoft.DWT.EnumDWT_PixelType`](/_articles/info/api//Dynamsoft_Enum.md#dynamsoftdwtenumdwt_pixeltype) enum. - `Resolution: 200` sets the image resolution to 200 DPI. Modifying the previous `AcquireImage()` function results in this: ```javascript function AcquireImage() { if (DWTObject) { DWTObject.SelectSourceAsync() .then(function () { return DWTObject.AcquireImageAsync({ IfShowUI: false, IfCloseSourceAfterAcquire: true, PixelType: Dynamsoft.DWT.EnumDWT_PixelType.TWPT_BW, Resolution: 200, }); }) .catch(function (exp) { alert(exp.message); }); } } ``` These parameters will configure the scan using pre-set values, and also prevent user error by not allowing the user to override these settings. ## Further Reading We demonstrated how to use APIs to scan documents from a web application, along with some simple customizations. For more extensive customizations, read more in our [advanced guides](/_articles/extended-usage/index.md). You can also consult our [FAQ](/_articles/faq/index.md) for better product knowledge and troubleshooting.
--- title: Dynamic Web TWAIN SDK Deployment - Server Deployment description: Dynamic Web TWAIN SDK Documentation Server Deployment Page source_url: html: https://www.dynamsoft.com/web-twain/docs/general-usage/server-deployment.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/general-usage/server-deployment.md --- # Deploy your application on the server Once you have finished integrating `Dynamic Web TWAIN` in your application, you can deploy it on your server to test it. As far as `Dynamic Web TWAIN` is concerned, all related files are to be served as static files which makes the deployment very easy. ## How-to The Resources folder is typically found in the following location after the installation: - Windows: C:\Program Files (x86)\Dynamsoft\Dynamic Web TWAIN SDK {Version Number}\ - macOS: Applications > Dynamsoft > Dynamic Web TWAIN SDK {Version Number} The deployment of Dynamic Web TWAIN is easy. Simply copy the Resources folder to your web server. Learn more on [Set ResourcesPath](#set-resourcespath) ## Technical details ### Make sure the static files can be served correctly `Dynamic Web TWAIN` comes with lots of static resources files, for the full list, check out [What are the Resources files](/_articles/faq/what-are-the-resources-files.md). The following table shows each file type and its MIME type which must be configured in your webserver in order for that type of file(s) to be correctly served to the client browsers. | File Type | MIME Type | Required by | |:-:|:-:|:-:| | `.js` | `application/javascript` | All Browsers | | `.css` | `text/css` | All Browsers | | `.wasm` | `application/wasm` | [WASM Browsers]({{site.getstarted}}Platform.html#wasm-browsers) | | `.msi` | `application/octet-stream` | [Browsers on Windows]({{site.getstarted}}Platform.html#browsers-on-windows) | | `.pkg` | `application/pkg-mac` | [Browsers on macOS]({{site.getstarted}}Platform.html#browsers-on-macos) | | `.deb` | `application/x-debian-package` | [Browsers on Linux]({{site.getstarted}}Platform.html#browsers-on-linux) | | `.rpm` | `application/x-redhat-package-manager` | [Browsers on Linux]({{site.getstarted}}Platform.html#browsers-on-linux) | ### Enable HTTPS If you need to use any of the following features, you must enable HTTPS on the server. * Upload or Download via SSL * Any other features that require a secure connection For how to enable HTTPS, please check out the manual of your webserver. ### Set ResourcesPath The global API [ `Dynamsoft.DWT.ResourcesPath` ](/_articles/info/api/Dynamsoft_WebTwainEnv.md#resourcespath) sets a relative or absolute path that tells `Dynamic Web TWAIN` where to look for the resources files at runtime. Its default value is `Resources` which means all these files are put in a directory called *Resources* that is in the same location as the web page on which `Dynamic Web TWAIN` is running. This is the simplest situation possible. However, in most cases, it's a lot more complicated and you must make sure the correct value is set. #### How to know ResourcesPath is wrong When you set `ResourcesPath` wrong, static files such as `dynamsoft.webtwain.install.js` , `dynamsoft.viewer.css` will fail to load and you see 404 errors in the browser console. #### Change ResourcePath using an absolute path If you wish to use an absolute path to include the library, this is supported. ``` html ``` #### Change ResourcePath using a relative path If you do not wish to use an absolute path, you can [change the reference path](/_articles/faq/change-reference-path.md) to a relative path. ```javascript Dynamsoft.DWT.ResourcesPath = "New folder/Resources"; ``` #### Relocate the folder holding the client installer files As of DWT 18.4, you can now relocate the folder that houses the Dynamic Web TWAIN Service(formerly known as Dynamsoft Service) installer files to a location outside of the Resources folder. The below example relocates the Resources folder to a projectfiles folder in the same project, and refers externally to find the client installer files. ```javascript Dynamsoft.DWT.ResourcesPath = "../projectfiles/DWTResources"; Dynamsoft.DWT.ServiceInstallerLocation` = "https://example.com/DWTInstallers"; ``` --- title: Dynamic Web TWAIN SDK Development - Server Scripts description: Dynamic Web TWAIN SDK Documentation Server Scripts Page source_url: html: https://www.dynamsoft.com/web-twain/docs/general-usage/server-side-scripting.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/general-usage/server-side-scripting.md --- # Server-side Scripting `Dynamic Web TWAIN` is a 100% client-side library. However, it does need to interact with the server when doing operations like **Upload**, **Download**, etc. While the scripts are scattered in the documentation, we'll try to cover some important ones in this article. ## How to process uploaded files As mentioned in our [image upload guide](/_articles/general-usage/image-export/server-upload.md), `Dynamic Web TWAIN` sends an HTTP POST request to the server when doing an upload. The file in the POST Form has the name `RemoteFile` by default. If you wish to change that, you can use [ `HttpFieldNameOfUploadedImage` ](/_articles/info/api/WebTwain_IO.md#httpfieldnameofuploadedimage). The following assumes the default `RemoteFile` is used and that [extra Form fields](/_articles/faq/additional-form-fields.md) might accompany the file. ### Upload via CSharp #### Regular upload ``` csharp string strImageName, strImageSize; HttpFileCollection files = HttpContext.Current.Request.Files; /** * Writes the file to the disk */ HttpPostedFile uploadfile = files["RemoteFile"]; strImageName = uploadfile.FileName; string strImageSavePath = Server.MapPath(".") + "\\Dynamsoft_Upload\\"; if (!System.IO.Directory.Exists(strImageSavePath)) { System.IO.Directory.CreateDirectory(strImageSavePath); } String strInputFile = strImageSavePath + strImageName; uploadfile.SaveAs(strInputFile); /** * The following writes the fields to a file */ string path = strInputFile.Substring(0, strInputFile.Length - 4) + "_1.txt"; int fieldsCount = HttpContext.Current.Request.Form.Count; if(fieldsCount > 0){ if (!System.IO.File.Exists(path)) { using (System.IO.FileStream fs = new System.IO.FileStream(path, System.IO.FileMode.Create, System.IO.FileAccess.Write)) { using (System.IO.StreamWriter sw = new System.IO.StreamWriter(fs, Encoding.UTF8)) { for (int i = 0; i < fieldsCount; i++) { // Create a file to write to. sw.WriteLine(HttpContext.Current.Request.Form.Keys[i] + " : " + HttpContext.Current.Request.Form[HttpContext.Current.Request.Form.Keys[i]] + Environment.NewLine); } } } } } ``` #### Segmented upload ``` csharp String filename = Request["filename"]; String range = Request.Headers["Content-Range"]; String md5 = Request.Headers["dwt-md5"]; if (range != null) { /** * The header "Content-Range" signals that it's segmented * The following stitches the segments together. */ string[] ary = range.Replace("bytes ", "").Replace("-", "/").Split('/'); int start, end, size; start = Convert.ToInt32(ary[0]); end = Convert.ToInt32(ary[1]); size = Convert.ToInt32(ary[2]); String strImageName = ""; HttpFileCollection files = HttpContext.Current.Request.Files; HttpPostedFile uploadfile = files["RemoteFile"]; if (!Directory.Exists(Server.MapPath(".") + "\\Images")) Directory.CreateDirectory(Server.MapPath(".") + "\\Images"); if (filename == null || filename == "") filename = uploadfile.FileName; if (uploadfile != null) { if (!Directory.Exists(Server.MapPath(".") + "\\Images")) Directory.CreateDirectory(Server.MapPath(".") + "\\Images"); strImageName = Server.MapPath(".") + "\\Images\\" + filename; Stream ifs = uploadfile.InputStream; byte[] bytes = null; bytes = new byte[ifs.Length]; ifs.Read(bytes, 0, (int)ifs.Length); FileStream fs; if (File.Exists(strImageName)) { fs = new FileStream(strImageName, FileMode.Open, FileAccess.Write, FileShare.ReadWrite); } else { fs = new FileStream(strImageName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite); } if (start > fs.Length) { fs.Seek(0, SeekOrigin.End); for (long i = 0; i < (fs.Length - start); i++) fs.WriteByte(0); } fs.Seek(start, SeekOrigin.Begin); fs.Write(bytes, 0, bytes.Length); fs.Flush(); fs.Close(); } } else { // Compatible with regular uploads HttpFileCollection files = HttpContext.Current.Request.Files; HttpPostedFile uploadfile = files["RemoteFile"]; if (filename == null || filename == "") { filename = uploadfile.FileName; } uploadfile.SaveAs(Server.MapPath(".") + "\\Images\\" + filename); } ``` #### Save to MS SQL ``` csharp //Connect to SQL String serverName = "YOUR-SERVER-NAME"; String userName = "test"; String password = "Aa000000"; String dbName = "dwtsample"; String tableName = "uploadedimages"; System.Data.SqlClient.SqlConnection tmpConn = new System.Data.SqlClient.SqlConnection("Data Source = " + serverName + ";User ID = " + userName + ";Pwd = " + password + ";"); String sqlCreateDBQuery = string.Format("SELECT database_id FROM sys.databases WHERE Name = '{0}'", dbName); using (tmpConn) { using (System.Data.SqlClient.SqlCommand sqlCmd = new System.Data.SqlClient.SqlCommand(sqlCreateDBQuery, tmpConn)) { tmpConn.Open(); object resultObj = sqlCmd.ExecuteScalar(); int databaseID = 0; if (resultObj != null) { int.TryParse(resultObj.ToString(), out databaseID); } // Database doesn't exist, create one if (databaseID == 0) { String sql_newdb = "CREATE DATABASE " + dbName; using (System.Data.SqlClient.SqlCommand sqlcmd_newdb = new System.Data.SqlClient.SqlCommand(sql_newdb, tmpConn)) { sqlcmd_newdb.ExecuteScalar(); } } } tmpConn.Close(); } System.Data.SqlClient.SqlConnection Connection = new System.Data.SqlClient.SqlConnection("Data Source = " + serverName + ";User ID = " + userName + ";Pwd = " + password + ";Initial Catalog =" + dbName + ";"); using (Connection) { Connection.Open(); String sql_checkTable = @"IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='" + tableName + "') SELECT 1 ELSE SELECT 0"; using (System.Data.SqlClient.SqlCommand sqlcmd_checkTable = new System.Data.SqlClient.SqlCommand(sql_checkTable, Connection)) { object result_obj = sqlcmd_checkTable.ExecuteScalar(); int table_exists = 0; if (result_obj != null) { int.TryParse(result_obj.ToString(), out table_exists); } // Table doesn't exist, create one if (table_exists == 0) { String sql_newTable = @"CREATE TABLE " + tableName + " (id int NOT NULL IDENTITY (1, 1), document_name varchar(255) NOT NULL, document_data image NOT NULL) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]"; using (System.Data.SqlClient.SqlCommand sqlcmd_newTable = new System.Data.SqlClient.SqlCommand(sql_newTable, Connection)) { sqlcmd_newTable.ExecuteScalar(); } } } /** * Convert the uploaded file to a byte array */ int iFileLength; HttpFileCollection files = HttpContext.Current.Request.Files; HttpPostedFile uploadfile = files["RemoteFile"]; String strImageName = uploadfile.FileName; iFileLength = uploadfile.ContentLength; Byte[] inputBuffer = new Byte[iFileLength]; System.IO.Stream inputStream; inputStream = uploadfile.InputStream; inputStream.Read(inputBuffer, 0, iFileLength); inputStream.Close(); /** * Save the byte array to the database */ String sql_insertData = "INSERT INTO " + tableName + " (document_name, document_data) VALUES (@document_name, @document_data)"; using (System.Data.SqlClient.SqlCommand sqlcmd_insertData = new System.Data.SqlClient.SqlCommand(sql_insertData, Connection)) { sqlcmd_insertData.Parameters.Add("@document_data", System.Data.SqlDbType.Binary, iFileLength).Value = inputBuffer; sqlcmd_insertData.Parameters.Add("@document_name", System.Data.SqlDbType.VarChar, 255).Value = strImageName; sqlcmd_insertData.ExecuteScalar(); } Connection.Close(); } ``` ### Upload via PHP #### Upload and save to the disk ``` php $fileTempName = $_FILES['RemoteFile']['tmp_name']; $fileSize = $_FILES['RemoteFile']['size']; $fileName = "Dynamsoft_Upload\\" . $_FILES['RemoteFile']['name']; $fileName = iconv("UTF-8", "gb2312", $fileName); $count = count($_POST); if ($count > 0) { $_fieldsTXT = fopen(substr($fileName, 0, strlen($fileName) - 4) . "_1.txt", "w"); $_fields = ""; foreach ($_POST as $key => $value) { $_fields = "FieldsTrue:"; fwrite($_fieldsTXT, $key . " : " . $value . PHP_EOL); } } if (file_exists($fileName)) { $fWriteHandle = fopen($fileName, 'w'); } else { $fWriteHandle = fopen($fileName, 'w'); } $fReadHandle = fopen($fileTempName, 'rb'); $fileContent = fread($fReadHandle, $fileSize); fwrite($fWriteHandle, $fileContent); fclose($fWriteHandle); ``` #### Save to MySQL ``` php // Interacting with MySQL $servername = "127.0.0.1"; $username = "root"; $password = "awesome"; $dbname = "dwtsample"; $tablename = "uploadedimages"; // Create connection $conn = new mysqli($servername, $username, $password); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } else { // Check Database Existence $db_selected = mysqli_select_db($conn, $dbname); if(!$db_selected) { // Create database $sql_newDB = "CREATE DATABASE ".$dbname; if ($conn->query($sql_newDB) === TRUE) { // echo "Database created successfully"; } else { die("Error creating database: " . $conn->error); } } mysqli_select_db($conn, $dbname); // Check Table Existence $sql_showtable = "SHOW TABLES LIKE '".$tablename."'"; $rowcount = mysqli_num_rows($conn->query($sql_showtable)); if ($rowcount > 0) { // echo "the table exists"; } else { // sql to create table $sql_newtable = "CREATE TABLE ".$tablename." ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, document_name VARCHAR(30) NOT NULL, document_data longblob NOT NULL, reg_date TIMESTAMP )"; if ($conn->query($sql_newtable) === TRUE) { // echo "Table ".$tablename." created successfully"; } else { die("Error creating table: " . $conn->error); } } $fileTempName = $_FILES['RemoteFile']['tmp_name']; $fileSize = $_FILES['RemoteFile']['size']; $fileName = $_FILES['RemoteFile']['name']; $fReadHandle = fopen($fileTempName, 'rb'); $fileContent = fread($fReadHandle, $fileSize); fclose($fReadHandle); $sql_insertdata = "INSERT INTO ".$tablename." (document_name,document_data) VALUES ('".$fileName."','".addslashes($fileContent)."')"; if ($conn->query($sql_insertdata) === TRUE) { // echo "File saved in db successfully."; } else { die("Error saving file: " . $conn->error); } $conn->close(); } ``` ### Upload via JSP #### Use JSP packages to save the uploaded file The following packages are required ``` jsp <%@ page language="java" import="java.io.*,java.util.*,org.apache.commons.fileupload.*,org.apache.commons.fileupload.disk.*,org.apache.commons.fileupload.servlet.*"%> ``` The code to save the file to the disk ``` java // Create a factory for disk-based file items DiskFileItemFactory factory = new DiskFileItemFactory(); // Configure a repository (to ensure a secure temp location is used) ServletContext servletContext = this.getServletConfig().getServletContext(); File repository = (File) servletContext.getAttribute("javax.servlet.context.tempdir"); // Set factory constraints factory.setRepository(repository); // Sets the threshold beyond which files are written to disk factory.setSizeThreshold(1000000000); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); // Set overall request size constraint upload.setSizeMax(-1); // Parse the request List items = upload.parseRequest(request); // Process the uploaded items Iterator iter = items.iterator(); String _fields = ""; String fileName = ""; long sizeInBytes = 0; String _temp_Name = application.getRealPath("/Dynamsoft_Upload"); File _fieldsTXT = new File(_temp_Name); if(!_fieldsTXT.exists()) { boolean result = _fieldsTXT.createNewFile(); System.out.println("File create result:"+result); } Writer objWriter = new BufferedWriter(new FileWriter(_fieldsTXT)); while (iter.hasNext()) { FileItem item = iter.next(); // Process a regular form field if (item.isFormField()) { _fields = "FieldsTrue:"; String fieldName = item.getFieldName(); String value = item.getString(); try { //File appending objWriter.write(fieldName + " : " + value); objWriter.write(System.getProperty( "line.separator" )); } catch (Exception e) { e.printStackTrace(); } } // Process a file upload else { if(_fields.equals("FieldsTrue:")){ objWriter.flush(); objWriter.close(); } else{ objWriter.flush(); objWriter.close(); _fieldsTXT.delete(); } String fieldName = item.getFieldName(); fileName = item.getName(); String contentType = item.getContentType(); boolean isInMemory = item.isInMemory(); sizeInBytes = item.getSize(); if(fileName!=null && sizeInBytes!=0){ String _temp_Name2 = application.getRealPath("/Dynamsoft_Upload/" + fileName); File uploadedFile = new File(_temp_Name2); if(!uploadedFile.exists()) { boolean result = uploadedFile.createNewFile(); System.out.println("File create result:"+result); } try { item.write(uploadedFile); } catch (Exception e) { e.printStackTrace(); } if(_fieldsTXT.exists()) { String _temp_Name3 = application.getRealPath("/action/Dynamsoft_Upload/" + fileName.substring(0,fileName.length()-4) + "_1.txt"); _fieldsTXT.renameTo(new File(_temp_Name3)); } } } } ``` #### Save to Oracle The following packages are required ``` jsp <%@ page language="java" import="java.sql.*,java.io.*,java.util.*,org.apache.commons.fileupload.*,org.apache.commons.fileupload.disk.*,org.apache.commons.fileupload.servlet.*"%> ``` The code to save the file to Oracle ``` java // Prepare credentials for connecting to Oracle, here we use Oracle express (XE) String strDBUser = "dwtDB"; //database,schema name as well String strDBPassword = "NotRealPWD"; String strDriverName = "oracle.jdbc.driver.OracleDriver"; String strConnString = "jdbc:oracle:thin:@127.0.0.1:1521:XE"; Connection conn=null; // Test Database Connection try { Class.forName(strDriverName).newInstance(); conn = DriverManager.getConnection(strConnString, strDBUser, strDBPassword); conn.setAutoCommit(true); } catch(Exception e) { out.println("An exception occurred: " + e.getMessage()); } String fileName = ""; long sizeInBytes = 0; // Create a factory for disk-based file items DiskFileItemFactory factory = new DiskFileItemFactory(); // Configure a repository (to ensure a secure temp location is used) ServletContext servletContext = this.getServletConfig().getServletContext(); File repository = (File) servletContext.getAttribute("javax.servlet.context.tempdir"); // Set factory constraints factory.setRepository(repository); // Sets the size threshold beyond which files are written directly to disk. factory.setSizeThreshold(1000000000); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); // Set overall request size constraint upload.setSizeMax(-1); // Parse the request List items = upload.parseRequest(request); // Process the uploaded items Iterator iter = items.iterator(); while (iter.hasNext()) { try{ FileItem item = iter.next(); // Process a regular form field if (item.isFormField()) {} // Process a file upload else { fileName = item.getName(); sizeInBytes = item.getSize(); if(fileName != null && sizeInBytes != 0){ /** * Get the input stream (the file) */ InputStream stream_Input = item.getInputStream(); byte[] buff = new byte[8000]; int bytesRead = 0; ByteArrayOutputStream stream_BAO = new ByteArrayOutputStream(); while((bytesRead = stream_Input.read(buff)) != -1) { stream_BAO.write(buff, 0, bytesRead); } byte[] data = stream_BAO.toByteArray(); ByteArrayInputStream stream_BAI = new ByteArrayInputStream(data); stream_Input.close(); /** * Save the stream into Oracle */ PreparedStatement preparedStatement = conn.prepareStatement("insert into dwtsample(id, document_name, document_data) values(s_tblImage.NextVal, ?, ?)"); preparedStatement.setString(1, fileName); preparedStatement.setBinaryStream(2, stream_BAI, stream_BAI.available()); preparedStatement.executeUpdate(); preparedStatement.close(); conn.close(); } } } catch(Exception e) { } } ``` ### Upload via ColdFusion ``` html ``` ### Upload to Node Express Server ``` javascript var formidable = require('formidable'); var util = require('util'); var express = require('express'); var fs = require('fs'); var app = express(); app.use(express.static(__dirname)); app.use(function(req, res, next) { res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Methods", "PUT, POST, GET, DELETE, OPTIONS"); res.header("Access-Control-Allow-Headers", "*"); res.header("Access-Control-Allow-Credentials", true); next(); }); app.post('/upload', function(req, res) { var form = new formidable.IncomingForm(); form.parse(req, function(err, fields, files) { fs.readFile(files.RemoteFile.path, function(err, data) { // save file from temp dir to new dir var newPath = __dirname + "/uploaded/" + files.RemoteFile.name; fs.writeFile(newPath, data, function(err) { if (err) throw err; console.log('file saved'); res.end(); }); }); }); }) var server = app.listen(2020, function() { var host = server.address().address; var port = server.address().port; console.log('listening at http://%s:%s', host, port); }) ``` ### Upload via MVC Controller ``` csharp [HttpPost] public Boolean Upload() { HttpFileCollectionBase files = HttpContext.Request.Files; HttpPostedFileBase uploadfile = files.Get("RemoteFile"); var uploads = Path.Combine(HostingEnvironment.ApplicationPhysicalPath,"UploadedImages"); if (!Directory.Exists(uploads)) { Directory.CreateDirectory(uploads); } Boolean fileUploaded = false; for (var i = 0; i < files.Count; i++) { var file = files[i]; if (file.ContentLength > 0) { var filePath = Path.Combine(uploads, file.FileName); file.SaveAs(filePath); fileUploaded = true; } } return fileUploaded; } ``` ### Upload to Azure ``` csharp DateTime utc = DateTime.Now.ToUniversalTime(); // (1) Prepare your data String accountName = "dynamsoft"; String accountKey = ""; String baseUrl = "http://dynamsoft.blob.core.windows.net/dwt/"; String resourceName = Request["imageName"]; String path = "/dwt"; DateTime utc_start = utc.AddSeconds(-10); // 10 seconds before String start = utc_start.GetDateTimeFormats('s')[0].ToString() + ".0000000Z"; DateTime utc_expires = utc.AddSeconds(1200);// 20 minutes later String expires = utc_expires.GetDateTimeFormats('s')[0].ToString() + ".0000000Z"; // (2) generate signature String strToSign1 = "w"; String strToSign2 = start; String strToSign3 = expires; String strToSign4 = "/" + accountName + path; String strToSign5 = ""; String strSign = String.Format("{0}\n{1}\n{2}\n{3}\n{4}", strToSign1, strToSign2, strToSign3, strToSign4, strToSign5); // decoding byte[] tobedecodedbytes = System.Convert.FromBase64String(accountKey); System.Security.Cryptography.HMACSHA256 hmac = new System.Security.Cryptography.HMACSHA256(tobedecodedbytes); hmac.Initialize(); byte[] buffer = Encoding.UTF8.GetBytes(strSign); byte[] arrMAC = hmac.ComputeHash(buffer); String strSig = System.Convert.ToBase64String(arrMAC); // (3) generate SAS the query start = Server.UrlEncode(start); expires = Server.UrlEncode(expires); strSig = Server.UrlEncode(strSig); String strParams = String.Format("sp=w&st={0}&se={1}&sr=c&sig={2}", start, expires, strSig); String url = baseUrl + resourceName + "?" + strParams; Response.Write(url); ``` ### Resend the uploaded file by email The following code uses ASP. NET (CSharp) * Configure the server (Gmail as an example) ``` xml ‹system.net› ‹mailSettings› ‹smtp from="***@gmail.com"› ‹network host="smtp.gmail.com" port="25" userName="***@gmail.com" password="***" enableSsl="true"/› ‹/smtp› ‹/mailSettings› ‹/system.net› ``` * Make use of the `System.Net.Mail` namespace ``` csharp using System.Net.Mail; ``` * Add code to email the file as an attachment ``` csharp HttpFileCollection files = HttpContext.Current.Request.Files; HttpPostedFile uploadfile = files["RemoteFile"]; SmtpClient client = new SmtpClient(); MailAddress from = new MailAddress("***@gmail.com", " Test", System.Text.Encoding.UTF8); MailAddress to = new MailAddress("***@gmail.com"); MailMessage message = new MailMessage(from, to); message.Body = "This is a test email sent by ASP.NET"; message.BodyEncoding = System.Text.Encoding.UTF8; message.Subject = "Just Testing"; message.SubjectEncoding = System.Text.Encoding.UTF8; // Create the file attachment Attachment data = new Attachment(uploadfile.InputStream, uploadfile.FileName); message.Attachments.Add(data); client.Send(message); data.Dispose(); ``` ## Download a file The following scripts are used for [downloading from a URL which points to a server-side script](/_articles/general-usage/scanner-image-acquisition.md#the-url-points-to-a-server-side-script) ### Download via CSharp #### Get a file on the disk ``` csharp String fileName = "sample.tif"; String filePath = Server.MapPath(".") + "\\files\\" + fileName; System.IO.FileInfo fileInfo = new System.IO.FileInfo(filePath); Response.ClearContent(); Response.ClearHeaders(); Response.Clear(); Response.Buffer = true; String fileNameEncode; fileNameEncode = HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8); fileNameEncode = fileNameEncode.Replace("+", "%20"); String appendedheader = "attachment;filename=" + fileNameEncode; Response.AppendHeader("Content-Disposition", appendedheader); Response.WriteFile(fileInfo.FullName); ``` #### Get a file from MS SQL > Check out [Save to MS SQL](#save-to-ms-sql) for code on making the connection to the SQL. ``` csharp // ...Code to connect to MS SQL // `strImageID` specify the file to download String sql_getData = "SELECT * FROM " + tableName + " WHERE id = " + strImageID; using (System.Data.SqlClient.SqlCommand sqlcmd_getData = new System.Data.SqlClient.SqlCommand(sql_getData, Connection)) { System.Data.SqlClient.SqlDataReader sdrRecordset = sqlcmd_getData.ExecuteReader(); sdrRecordset.Read(); String imgName = sdrRecordset["document_name"].ToString(); String imgNameExtension = imgName.Substring(imgName.LastIndexOf(".")); // Reads the file data as byte array byte[] byFileData = (byte[])sdrRecordset["document_data"]; sdrRecordset.Close(); Connection.Close(); sdrRecordset = null; Response.Clear(); Response.Buffer = true; switch(imgNameExtension) { // Sets the correct content type case "bmp": Response.ContentType = "image/bmp"; break; case "jpg": Response.ContentType = "image/jpg"; break; case "tif": Response.ContentType = "image/tiff"; break; case "png": Response.ContentType = "image/png"; break; case "pdf": Response.ContentType = "application/pdf"; break; default: break; } try { // Write the file back String fileNameEncode; fileNameEncode = HttpUtility.UrlEncode(imgName, System.Text.Encoding.UTF8); fileNameEncode = fileNameEncode.Replace("+", "%20"); String appendedheader = "attachment;filename=" + fileNameEncode; Response.AppendHeader("Content-Disposition", appendedheader); Response.OutputStream.Write(byFileData, 0, byFileData.Length); } catch (Exception exc) {} Response.Flush(); Response.Close(); } ``` ### Download via PHP #### Get a file out of MySQL > Check out [Save to MySQL](#save-to-mysql) for code on making the connection to MySQL. ``` php // ...Code to connect to MySQL // `$strImageID` specify the file to download $sql_getData = "SELECT * FROM ".$tablename." WHERE id = ".$strImageID; $result = $conn->query($sql_getData); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $documentName = $row["document_name"]; $strImageExtName = substr($documentName, strlen($documentName) - 3); $documentData = $row["document_data"]; } } $conn->close(); //Begin writing headers header("Content-Description: File Transfer"); $header="Content-Disposition: attachment; filename=".$documentName.";"; header($header); header("Content-Transfer-Encoding: binary"); // Sets the correct content type if($strImageExtName == "bmp"){ header('Content-Type: image/bmp'); }else if($strImageExtName == "jpg"){ header('Content-Type: image/jpg'); }else if($strImageExtName == "tif"){ header('Content-Type: image/tiff'); }else if($strImageExtName == "png"){ header('Content-Type: image/png'); }else if($strImageExtName == "pdf"){ header('Content-Type: application/pdf'); } // Write the file back echo $documentData; ``` ### Download via JSP #### Get a file out of Oracle > Check out [Save to Oracle](#save-to-oracle) for code on making the connection to MySQL. ``` java // ...Code to connect to Oracle // `strImageID` specify the file to download Statement sql_getData = conn.createStatement(); ResultSet res_getData = sql_getData.executeQuery("select * from dwtsample where id =" + strImageID); String documentName = ""; String strImageExtName = ""; String strImg=""; if (res_getData.next()){ documentName = res_getData.getString("document_name"); strImageExtName = documentName.substring(documentName.lastIndexOf(".") + 1); Blob blob = res_getData.getBlob("document_data"); InputStream steam_Input = blob.getBinaryStream(); if (steam_Input != null) { // Gets the file as a byte array BufferedInputStream stream_BufferInput = new BufferedInputStream(steam_Input); byte[] byte_buf = new byte[(int)blob.length()]; stream_BufferInput.read(byte_buf); stream_BufferInput.close(); conn.close(); response.setHeader("Content-disposition", "attachment; filename=\"" + documentName + "\""); response.setHeader("Content-Length", String.valueOf(byte_buf.length)); // Sets the correct content type if(strImageExtName == "bmp"){ response.setContentType("image/bmp"); }else if(strImageExtName == "jpg"){ response.setContentType("image/jpg"); }else if(strImageExtName == "tif"){ response.setContentType("image/tiff"); }else if(strImageExtName == "png"){ response.setContentType("image/png"); }else if(strImageExtName == "pdf"){ response.setContentType("application/pdf"); } // Write the file back OutputStream stream_Output = response.getOutputStream(); stream_Output.write(byte_buf, 0, byte_buf.length); stream_Output.flush(); stream_Output.close(); } else { out.println(""); } } ``` --- title: Dynamic Web TWAIN SDK Basics - Customizing the Viewer description: Dynamic Web TWAIN SDK General Usage Guide - Customizing the Viewer source_url: html: https://www.dynamsoft.com/web-twain/docs/general-usage/viewer-configuration.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/general-usage/viewer-configuration.md --- # Configuring the Viewer > Prerequisite: [DWT Initialization](/_articles/general-usage/initialization.md) The `Viewer` component of the `WebTwain` instance is responsible for displaying scanned documents, and all other UI features. This guide explains how to configure `Viewer` behavior. ## Configuring Viewer Instantiation ### Configuring Built-in Viewers The default `WebTwain` instance automatically creates its own `Viewer` instance with default settings - the `Viewer` is bound to the HTML `
` element with `id=dwtcontrolContainer` and specified display size, which are defined by the `Dynamsoft.DWT.Containers`. We go over this process in detail in the [DWT Initialization](/_articles/general-usage/initialization.md) article. We can configure the `Viewer`'s `id` and display size by altering the configuration resource file `dynamsoft.webtwain.config.js`. Modify the existing `Dynamsoft.DWT.Containers` property as shown below: #### Sample Code ##### Relevant Snippet from `dynamsoft.webtwain.config.js` ```javascript Dynamsoft.DWT.Containers = [{ ContainerId: 'customDivID', // New default div id Width: '800px', // New initial Viewer pixel width Height: '600px' // New initial Viewer pixel height }] ``` ##### HTML ```html
``` APIs used: - [`Dynamsoft.DWT.Containers`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#containers) - [`Dynamsoft.DWT.RegisterEvent()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#registerevent) - [`Dynamsoft.DWT.GetWebTwain()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain) - [`OnWebTwainReady`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainready) - [`SelectSourceAsync()`](/_articles/info/api/WebTwain_Acquire.md#selectsourceasync) - [`AcquireImageAsync()`](/_articles/info/api/WebTwain_Acquire.md#acquireimageasync) - [`IfCloseSourceAfterAcquire`](/_articles/info/api/Device.md#deviceobjectacquireimage) #### Explanation In the DWT configuration resource file, we changed the `
` container ID to `customDivID`, and set new dimensions for the default `Viewer` using the [`Dynamsoft.DWT.Containers`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#containers) property. (which contains [Containers](/_articles/info/api/interfaces.md#Container)) During DWT initialization, not only does the `containerId` bind the default `Viewer`, it also acts as an identifier for the default `WebTwain` instance. Consequently, we must use `customDivID` with [`Dynamsoft.DWT.GetWebTwain()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain) to get the default `WebTwain` instance once it has been created. ### Binding a `Viewer` to a `WebTwain` Instance To further customize a `Viewer`, we create a `WebTwain` instance that does not have a `Viewer` component, then bind a custom `Viewer` to it. In this example, we create a `WebTwain` instance with a viewer that also displays thumbnails to its side. ##### Relevant Snippet from `dynamsoft.webtwain.config.js` ```javascript Dynamsoft.DWT.Containers = [] Dynamsoft.DWT.AutoLoad = false; ``` ##### HTML ```html
``` APIs used: - [`Dynamsoft.DWT.Containers`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#containers) - [`Dynamsoft.DWT.CreateDWTObjectEx()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#createdwtobjectex) - [`DWTInitialConfig`](/_articles/info/api/interfaces.md#dwtinitialconfig) - [`Viewer.bind()`](/_articles/info/api/WebTwain_Viewer.md#bind) - [`Viewer.createThumbnailViewer()`](/_articles/info/api/WebTwain_Viewer.md#createthumbnailviewer) - [`Viewer.show()`](/_articles/info/api/WebTwain_Viewer.md#show) - [`ThumbnailViewer`](/_articles/info/api/interfaces.md#thumbnailviewer) - [`SelectSourceAsync()`](/_articles/info/api/WebTwain_Acquire.md#selectsourceasync) - [`AcquireImageAsync()`](/_articles/info/api/WebTwain_Acquire.md#acquireimageasync) - [`IfCloseSourceAfterAcquire`](/_articles/info/api/Device.md#deviceobjectacquireimage) #### Explanation To demonstrate `Viewer` binding, we first create a `Viewer`-less (headless) `WebTwain` instance. We must first prevent DWT from creating a default-configured `WebTwain` instance (auto-loading) during its initialization stage, as this instance comes with a `Viewer`. We can clear [`Dynamsoft.DWT.Containers`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#containers) and set [`Dynamsoft.DWT.AutoLoad`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#autoload) `false` in the configuration `dynamsoft.webtwain.config.js` resource file to prevent auto-loading. We then use [`CreateDWTObjectEx()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#createdwtobjectex) to create the desired custom `WebTwain` instance without a `Viewer`. In the success callback of `CreateDWTObjectEx()`, we then customize its features, namely its `Viewer` and `ThumbnailViewer`. This is the key point of this sample. [`bind()`](/_articles/info/api/WebTwain_Viewer.md#bind) simultaneously creates the `Viewer` instance, binds it to the `WebTwain` instance that it was called from, and also binds it to the HTML container by container `id`. This `Viewer` instance is then accessible using the `Viewer` property from the `WebTwain` instance. For example, `DWTObject.Viewer.height` is the height of the `Viewer`. Likewise, **after** the `Viewer` has been instantiated and bound, we can create a thumbnail viewer in the `Viewer` by accessing the [`createThumbnailViewer()`](/_articles/info/api/WebTwain_Viewer.md#createthumbnailviewer) function provided within the `Viewer` instance. Finally, we display both the `Viewer` and `ThumbnailViewer` on screen with their respective `show()` APIs. > Note: The `Viewer` is always bound to a `WebTwain` instance. As such, the `Viewer` and its properties must always be accessed as a property of a `WebTwain` instance. ## Interacting with the Viewer Users can interact with the `Viewer` graphically to work with scanned documents. These interactions also have APIs which can be called directly. Here is a non-exhaustive list of commonly used interactive features, along with their associated APIs (accessed from its parent `WebTwain` instance): - [`Viewer.next()`](/_articles/info/api/WebTwain_Viewer.md#next): Display the page after the current one - [`Viewer.previous()`](/_articles/info/api/WebTwain_Viewer.md#previous): Display the page before the current one - [`Viewer.first()`](/_articles/info/api/WebTwain_Viewer.md#first): Display the first page - [`Viewer.last()`](/_articles/info/api/WebTwain_Viewer.md#last): Display the last page - [`Viewer.goToPage()`](/_articles/info/api/WebTwain_Viewer.md#last): Display the n-th page - [`Viewer.setViewMode()`](/_articles/info/api/WebTwain_Viewer.md#setviewmode): Specify the dimensions of the grid of images to display at once - [`Viewer.fitWindow()`](/_articles/info/api/WebTwain_Viewer.md#fitWindow): Fit the image to the `Viewer` - [`Viewer.zoom`](/_articles/info/api/WebTwain_Viewer.md#zoom): Set the image display magnification factor, only when `setViewMode` is -1 x -1 - [`Viewer.setSelectedAreas()`](/_articles/info/api/WebTwain_Viewer.md#setselectedareas): Select a rectangular region on the displayed page - [`Viewer.unbind()`](/_articles/info/api/WebTwain_Viewer.md#unbind): Unbind and delete the `Viewer` Here is a rudimentary sample that demonstrates page movement APIs: ### Sample Code ```html



``` APIs used: - [`RegisterEvent()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#registerevent) - [`OnWebTwainReady`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainready) - [`GetWebTwain()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain) - [`SelectSourceAsync()`](/_articles/info/api/WebTwain_Acquire.md#selectsourceasync) - [`AcquireImageAsync()`](/_articles/info/api/WebTwain_Acquire.md#acquireimageasync) - [`IfCloseSourceAfterAcquire`](/_articles/info/api/Device.md#deviceobjectacquireimage) - [`SelectSourceAsync()`](/_articles/info/api/WebTwain_Acquire.md#selectsourceasync) - [`AcquireImageAsync()`](/_articles/info/api/WebTwain_Acquire.md#acquireimageasync) - [`IfCloseSourceAfterAcquire`](/_articles/info/api/Device.md#deviceobjectacquireimage) --- title: Dynamic Web TWAIN SDK HelloWorld - Editing Images description: Dynamic Web TWAIN SDK HelloWorld - Editing Images source_url: html: https://www.dynamsoft.com/web-twain/docs/hello-world/editing.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/hello-world/editing.md --- # Editing Images >[!TIP] > Prerequisites: Hello World - Specifying Scan Settings DWT offers a number of image manipulation features used after image acquisition and before uploading or exporting. These include but are not limited to rotation, cropping, and resizing. In this example, we will demonstrate image color mode conversion and image rotation in HelloWorld. ## Add Image Binarization Add this line in the `HelloWorld.html` body to create a color mode conversion button: ```html ``` Then, define `binarizeImage()` in the `script` element: ```javascript function binarizeImage() { DWTObject.ConvertToBW(DWTObject.CurrentImageIndexInBuffer); } ``` APIs used: - [`ConvertToBW()`](/_articles/info/api/WebTwain_Edit.md#convertToBW){:target="\_blank" rel="noreferrer noopener"} - [`CurrentImageIndexInBuffer`](/_articles/info/api/WebTwain_Buffer.md#currentimageindexinbuffer){:target="\_blank" rel="noreferrer noopener"} ## Add Image Rotation Add two buttons for 90 degree clockwise and anti-clockwise image rotation: ```html ``` Define the rotation functions in the `script` element: ```javascript function rotateCW() { DWTObject.RotateRight(DWTObject.CurrentImageIndexInBuffer); } function rotateCCW() { DWTObject.RotateLeft(DWTObject.CurrentImageIndexInBuffer); } ``` APIs used: - [`RotateRight()`](/_articles/info/api/WebTwain_Edit.md#rotateright){:target="\_blank" rel="noreferrer noopener"} - [`RotateLeft()`](/_articles/info/api/WebTwain_Edit.md#rotateleft){:target="\_blank" rel="noreferrer noopener"} - [`CurrentImageIndexInBuffer`](/_articles/info/api/WebTwain_Buffer.md#currentimageindexinbuffer){:target="\_blank" rel="noreferrer noopener"} ## Review the Code ```html
``` ## Run the Application ### Open the application in your browser ![Initial state of the Hello World Edit sample](/assets/imgs/HelloWorldEdit.png) ### Press the Scan button ![Hello World Edit sample with an image scanned from the TWAIN Virtual Scanner](/assets/imgs/HelloWorldEditBW1.png) ### Convert the image to black and white Click the ConvertToBW button and the image will change to black and white: ![Hello World Edit sample with previous image binarized](/assets/imgs/HelloWorldEditBW2.png) ### Rotate the image Using the Rotate CW and Rotate CCW buttons, rotate the image. - Rotating the converted image once using the rotateCW button: ![HelloWorldEditCW button](/assets/imgs/HelloWorldEditRotateCW.png) - Rotating the converted image once using the rotateCCW button: ![Hello World Edit sample with previously binarized image rotated counter-clockwise](/assets/imgs/HelloWorldEditRotateCCW.png) Congratulations, you have completed the Hello World tutorial for DWT! # Previous Articles If you would like to review any of the previous steps, you can review: - [Scanning an image](/_articles/hello-world/scanning.md) - [Uploading images to the server](/_articles/hello-world/uploading.md) - [Setting scan parameters](/_articles/hello-world/scan-settings.md) # Next Article Now that you had a chance to look at what DWT can do, you can learn about how to use DWT in your web application in detail with our [general developer guide](/_articles/general-usage/index.md).
--- title: Dynamic Web TWAIN SDK HelloWorld description: Dynamic Web TWAIN SDK HelloWorld source_url: html: https://www.dynamsoft.com/web-twain/docs/hello-world/index.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/hello-world/index.md --- # Hello World This Hello World guide will help you build a web-based scanning application with DWT in under 30 minutes. To start, you can download a 30-day free trial of our DWT SDK [here](https://www.dynamsoft.com/web-twain/downloads/). To see a video version of this guide, find the video on [YouTube](https://www.youtube.com/watch?v=qShti9aVfLU). The Hello World web app covers the following features: 1. [Scanning an Image](/_articles/hello-world/scanning.md) 2. [Uploading images to the server](/_articles/hello-world/uploading.md) 3. [Specifying Scan Settings](/_articles/hello-world/scan-settings.md) 4. [Editing Images](/_articles/hello-world/editing.md) Download the Hello World Code --- title: Dynamic Web TWAIN SDK HelloWorld - Specifying Scan Settings description: Dynamic Web TWAIN SDK HelloWorld - Specifying Scan Settings source_url: html: https://www.dynamsoft.com/web-twain/docs/hello-world/scan-settings.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/hello-world/scan-settings.md --- # Specifying Scan Settings Some applications may require images to be scanned with particular scan settings, e.g. a prescribed image size, resolution, color, etc. It may be undesirable to alter these settings, so we may wish to issue these settings to the scanner directly, without alteration by end users. We will demonstrate this method by passing scan settings through the DWT API in the HelloWorld application. > Prerequisites: Hello World - Uploading Images to the Server ## Specify Scan Parameters with JSON The `AcquireImagesAsync()` API accepts scan setting arguments in a JSON format (specified by [DeviceConfiguration](/_articles/info/api/interfaces.md#DeviceConfiguration){:target="\_blank" rel="noreferrer noopener"}). For this example, we will demonstrate specifying a grayscale image with a resolution of 150 ppi by passing a few of these defined properties: - `IfShowUI: false` - this disables the scanner UI. Scan settings issued through the UI would override scan settings passed by JSON, so this prevents end user misuse. - `PixelType: Dynamsoft.DWT.EnumDWT_PixelType.TWPT_GRAY` - this sets the image color mode to grayscale. - `Resolution:150` - this sets the image resolution to 150 ppi. Add all three properties in the JSON argument passed to `AcquireImageAsync()`: ```javascript function AcquireImage() { if (DWTObject) { DWTObject.SelectSourceAsync() .then(function () { return DWTObject.AcquireImageAsync({ IfCloseSourceAfterAcquire: true, IfShowUI: false, PixelType: Dynamsoft.DWT.EnumDWT_PixelType.TWPT_GRAY, Resolution: 150, }); }) .catch(function (exp) { alert(exp.message); }); } } ``` ## Review the Code ```html
``` Links to API Reference: - [`SelectSourceAsync()`](/_articles/info/api/WebTwain_Acquire.md#selectsourceasync){:target="\_blank" rel="noreferrer noopener"} - [`AcquireImageAsync()`](/_articles/info/api/WebTwain_Acquire.md#acquireimageasync){:target="\_blank" rel="noreferrer noopener"} - [`IfCloseSourceAfterAcquire`](/_articles/info/api/Device.md#deviceobjectacquireimage){:target="\_blank" rel="noreferrer noopener"} - [`IfShowUI`](/_articles/info/api/WebTwain_Acquire.md#ifshowui){:target="\_blank" rel="noreferrer noopener"} - [`PixelType`](/_articles/info/api/WebTwain_Acquire.md#pixeltype){:target="\_blank" rel="noreferrer noopener"} - [`Dynamsoft.DWT.EnumDWT_PixelType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_pixeltype){:target="\_blank" rel="noreferrer noopener"} - [`Resolution`](/_articles/info/api/WebTwain_Acquire.md#resolution){:target="\_blank" rel="noreferrer noopener"} ## Run the Application ### Open the Application in Your Browser ![HelloWorld-Scan-1](/assets/imgs/HelloWorldScanSetting1.png) ### Press the Scan button The scan should proceed directly after the button press, without displaying the scanner UI. ### View the scan You should receive a grayscale image at 150 ppi: ![HelloWorld-Scan-2](/assets/imgs/HelloWorldScanSetting2.png) # Previous Articles If you have yet to acquire the image from the scanner, please review [scanning an image](/_articles/hello-world/scanning.md). If this scan is all that you need, you can review [uploading images to the server](/_articles/hello-world/uploading.md). # Next Article The next and final step in our guide is [editing images](/_articles/hello-world/editing.md) after acquisition.
--- title: Dynamic Web TWAIN SDK HelloWorld - Scanning Images description: Dynamic Web TWAIN SDK HelloWorld - Scanning Images source_url: html: https://www.dynamsoft.com/web-twain/docs/hello-world/scanning.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/hello-world/scanning.md --- # Scanning Images The main use case for DWT is to acquire images from a document scanner (the image source). We will demonstrate its functions by building a web application using DWT. ## Initialize the Environment To start off, create the Hello World web application and load DWT into the environment. ### Create a Web Application Create a `HelloWorld.html` file anywhere and copy the `Resources` folder to the same location. You can typically find the `Resources` folder inside the following locations depending on your platform: - Windows: `C:\Program Files (x86)\Dynamsoft\Dynamic Web TWAIN SDK {Version Number}\` - Linux: Within the decompressed file `Dynamic Web TWAIN SDK {Version Number}/` - MacOS: `/Applications/Dynamsoft/Dynamic Web TWAIN SDK {Version Number}/` ### Include the DWT Scripts Include the library scripts in the `` element of `HelloWorld.html`: ```html ``` ### Initialize the DWT Environment Now that the web application includes the script libraries, we may begin implementing image scanning using DWT. Add this `
` in the `` element: ```html
``` > `dwtcontrolContainer` is the default `id` for the `div` in the default DWT resources, and any of the Dynamsoft-provided demos. If you would like to use a different `id` for this `div`, you will need to change `Dynamsoft.DWT.Containers` in the file `dynamsoft.webtwain.config.js` to match. DWT has an event registration API, `Dynamsoft.DWT.RegisterEvent`, that we can use here to retrieve the initialized `WebTwain` object only when DWT is fully initialized. This `WebTwain` object is the entrypoint to most APIs in DWT. Include the following in the `head` element of `HelloWorld.html`: ```html ``` The next step is to use the DWT API to acquire an image from a scanner. ## Add Simple Scanning Functionality ### Create an HTML Scan Button Add this element in the HTML body to create a scanning button: ```html ``` ### Initiate a Scan from an Image Source Define the following function to handle scans, and add it in the `script` element created during initialization: ```javascript function AcquireImage() { if (DWTObject) { DWTObject.SelectSourceAsync().then( function () { return DWTObject.AcquireImageAsync( { IfCloseSourceAfterAcquire: true } ); } ).catch(function (exp) { alert(exp.message); }); } } ``` ## Review the Code At this point, `HelloWorld.html` should look like this: ```html
``` APIs used: - [`RegisterEvent()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#registerevent) - [`OnWebTwainReady`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainready) - [`GetWebTwain()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain) - [`SelectSourceAsync()`](/_articles/info/api/WebTwain_Acquire.md#selectsourceasync) - [`AcquireImageAsync()`](/_articles/info/api/WebTwain_Acquire.md#acquireimageasync) - [`IfCloseSourceAfterAcquire`](/_articles/info/api/Device.md#deviceobjectacquireimage) ## Run the Application ### Open the Page in Your Browser Simply double click on `HelloWorld.html` in your file viewer, or right click on the HTML file and select a browser to open it with. In your browser, you should see a page with a scan button and an empty preview box. ![Build-the-Hello-World-Scan-Page-3](/assets/imgs/Build-the-Hello-World-Scan-Page-3.png) > Note: if you see a license notice, please make sure you have a valid license. Open `dynamsoft.webtwain.config.js` and ensure that you have a license defined at `Dynamsoft.DWT.ProductKey`. If you need further assistance, please contact [Dynamsoft Support](https://www.dynamsoft.com/web-twain/docs/about/getsupport.html). ### Press the Scan Button After pressing the Scan button, you will be presented with the Select Source dialog. Select your scanner and press the Select button. ![Build-the-Hello-World-Scan-Page-4](/assets/imgs/Build-the-Hello-World-Scan-Page-4.png) > Only TWAIN, WIA, ICA, or SANE compliant devices are listed in the Select Source dialog. If your connected scanner does not show up in the list, please confirm that the proper driver is installed. If you are using Windows and do not have a physical scanner on hand, you may install the TWAIN Virtual Scanner - a scanner simulator developed by the TWAIN Working Group for testing purposes. This guide uses the [TWAIN Virtual Scanner](/_articles/faq/download-virtual-scanner-for-testing.md) for reproducibility. ### Initiate a Scan from the Scanner UI You will be presented with your scanner's built-in interface after selecting the scanner. Initiate a scan from this dialog. Your scanner's interface may differ from the provided screenshot: ![Build-the-Hello-World-Scan-Page-UI](/assets/imgs/Build-the-Hello-World-Scan-Page-UI.png) ### View the Scanned Image After the scanner finishes scanning, the viewer will display the acquired images: ![Build-the-Hello-World-Scan-Page-5](/assets/imgs/Build-the-Hello-World-Scan-Page-5.png) You have just scanned an image using an image scanner controlled by a web application! ## Next Article The next article in this series will demonstrate [uploading images to the server](/_articles/hello-world/uploading.md). --- title: Dynamic Web TWAIN SDK Getting Started - Uploading Images to the Server description: Dynamic Web TWAIN SDK Documentation - Uploading Images to the Server source_url: html: https://www.dynamsoft.com/web-twain/docs/hello-world/uploading.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/hello-world/uploading.md --- # Uploading Images to the Server In the [previous guide]({{site.getstarted}}scanning.html), we incorporated DWT scanning functionality into the HelloWorld web application. Typically, we would like to upload scanned documents to the server. Here, we demonstrate how to use DWT to upload scanned documents as a PNG file by building on HelloWorld. > Prerequisites: Hello World - Scanning Images ## Add an Upload Button Insert this line in the `` element of `HelloWorld.html` to create a button: ```html ``` ## Define the Upload Function Here we define an upload function, as well as its helpers. Insert the following javascript in the existing `
``` ## Run the Application ### Open the Page in Your Browser Open `HelloWorld.html` in your browser, for example by selecting the `HelloWorld.html` file to open with your browser. On the web page, you should see a scan button, an upload button, and an empty preview box: ![Screenshot of web app with no scanned images](../../assets/imgs/HelloWorldUpload0.png) ### Scan a document Initiate a scan by clicking the Scan button in the same way that you did in the previous [scanning](scanning.md#press-the-scan-button) guide. This is a test image acquired from the TWAIN Virtual Scanner for reproducibility: ![Screenshot of web app with scanned sample image](../../assets/imgs/HelloWorldUpload1.png) ### Upload the image Once an image has been acquired, click the upload button.You should receive the successful upload message upon completion: ![Screenshot of web app after successful file upload alert](../../assets/imgs/HelloWorldUpload2.png) >Note: For the purposes of this guide, a Dynamsoft hosted end point is used, but for your own application you will need to create your own end point. **Sample Applications** - [Try the Scan Documents + Upload demo](https://demo.dynamsoft.com/Samples/dwt/Scan-Documents-and-Upload-Them/DWT_Scan_Upload_Demo.html){:target="_blank" rel="noreferrer noopener"} - [Get the Scan Documents + Upload demo source code](https://www.dynamsoft.com/web-twain/sample-downloads/?demoSampleId=4){:target="_blank" rel="noreferrer noopener"} # Previous Article You can review scanning an image with DWT [here](/_articles/hello-world/scanning.md). # Next Article Now that HelloWorld can both scan and upload images, the next step is [specifying scan parameters](/_articles/hello-world/scan-settings.md) to control image scanning methods directly through the API.
--- title: Dynamic Web TWAIN SDK Deployment - Index Page description: Dynamic Web TWAIN SDK Documentation Index Page source_url: html: https://www.dynamsoft.com/web-twain/docs/indepth/deployment/index.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/indepth/deployment/index.md --- # Deployment ## [Set up the server](/_articles/general-usage/server-deployment.md) ## [Set up the service](/_articles/extended-usage/dynamsoft-service-configuration.md) --- title: Dynamic Web TWAIN SDK Development - Professional Service description: Dynamic Web TWAIN SDK Documentation Professional Service Page source_url: html: https://www.dynamsoft.com/web-twain/docs/indepth/development/Pro-service.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/indepth/development/Pro-service.md --- # Professional Service Dynamsoft is devoted to making products as user-friendly as possible. In most cases, developers should be able to get started with the `Dynamic Web TWAIN` library in a very short time and integrate it into the workflow of their applications successfully within a matter of days. If any issues are met during the development process, the [Dynamsoft Support Team](/_articles/about/getsupport.md) is always ready to help. In some cases, we realize that some customers may require more advanced support from Dynamsoft and that's why we also provide a paid professional service. We offer two types of this paid professional service, applicable to different scenarios. ## Virtual Developer Service Although most of our customers have their own development teams (some are developers themselves) and can build their applications with the help of `Dynamic Web TWAIN` documentation and guides, there are still some customers who come to us for ready-made solutions. In other words, they would rather get a sample application that already has the required features than study the details of the SDK itself. In view of this, Dynamsoft provides a professional service called "Virtual Developer Service" (VDS). The idea is that Dynamsoft designates a team to help with the integration of `Dynamic Web TWAIN` into customers' applications, from requirements analysis to successful deployment. The following is how VDS works * Step 1: The customer sends over their requirements and other materials if required * Step 2: Dynamsoft analyzes the requirements and decide whether `Dynamic Web TWAIN` meets them > This step usually involves communicating back and forth until the requirements are clear enough and you can decide whether to proceed. * Step 3: Dynamsoft sends a quotation for the service as well as a quotation for the required licenses * Step 4: The customer makes the payment * Step 5: Dynamsoft designates a team to the project. The team usually consists of a case manager, a developer and a tester * Step 6: The designated team finishes the project before the agreed deadline and continues to maintain it during the agreed maintenance period ## Customization Service Dynamsoft provides many public samples and code snippets free of cost to all customers. The code in these materials can be customized at will. However, the resources files provided with each SDK **should not be changed** unless otherwise mentioned in this documentation. If you want to make unmentioned changes to any of these files in the documentation, you must first consult [Dynamsoft Support](/_articles/about/getsupport.md) to learn whether or not it can be done and if so, what that would entail from our end. If it involves a considerable amount of extra effort from the Dynamsoft team, the "Customization Service" (CS) may apply. The difference between VDS and CS is that the latter involves changes to the `Dynamic Web TWAIN` SDK itself and is considered much more complicated from a technical standpoint. However, in term of the customer's workflow to get a customization job done, the steps are the same as VDS. If you are interested in this type of professional service, please contact [Dynamsoft Support](/_articles/about/getsupport.md). --- title: Dynamic Web TWAIN SDK Development - About ActiveX description: Dynamic Web TWAIN SDK Documentation About ActiveX Page source_url: html: https://www.dynamsoft.com/web-twain/docs/indepth/development/activex.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/indepth/development/activex.md --- # About ActiveX April 21, 2022: Microsoft is retiring Internet Explorer 11 on June 15, 2022. To support Dynamic Web TWAIN ActiveX, please refer to [this article](/_articles/faq/activeX-in-Edge-IE-mode.md){:target="_blank"} to configure IE mode in Edge. **ActiveX** is a software framework created by Microsoft widely used in Internet Explorer (IE). However, Microsoft has announced plans to end support for older browsers completely and has now deprecated this technology. ## Dynamic Web TWAIN & ActiveX Although `Dynamic Web TWAIN` is built upon modern technologies like `WebSocket` , `HTML5` , `WebAssembly` , it was born as one of many ActiveX controls in 2003. The ActiveX edition of `Dynamic Web TWAIN` continued to dominate for 11 years. ActiveX is still part of `Dynamic Web TWAIN` though only used by a small number of customers who want to stick with IE 8 or 9. ## The Future of ActiveX Microsoft officially announced the end of support for IE 10 and older on `January 12th, 2016` . While IE 11 continues to be supported on Windows 7, 8.1, and 10, Microsoft is gradually deprecating it too. That said, since many enterprise applications still and will continue to rely on IE 11 for some time yet, the browser will continue receiving security updates and technical support for the lifecycle of the version of Windows on which it is installed. Windows 10 is among these versions of Windows on which IE 11 is installed, and there is no evidence that Microsoft will release a newer version of Windows soon. Therefore, it is safe to assume that IE 11 will continue to exist for quite some time. Read more [here](https://docs.microsoft.com/en-us/lifecycle/faq/internet-explorer-microsoft-edge). The fate of the ActiveX framework depends on the fate of IE 11. As long as IE 11 is still hanging around, ActiveX will continue to be supported. ## The Future of ActiveX Edition in Dynamic Web TWAIN Dynamsoft has a substantial customer base and their benefits are our biggest concern. While most of our customers have opted to use the modern browsers like Chrome, Firefox or Safari, a few of them must use IE 8 or 9 of which most cases are imitated by IE 11. In these cases, only the ActiveX edition of `Dynamic Web TWAIN` can be used. Dynamsoft has kept its support of the ActiveX edition as part of the Windows edition until now and will continue to do so as long as IE continues to be supported by Microsoft. Simultaneously, the ActiveX edition of `Dynamic Web TWAIN` will also be slowly phased out by Dynamsoft, just like IE by Microsoft. On the one hand, IE is reaching its end of life. On the other hand, outdated technologies are incompatible with updated Web standards, which hinders `Dynamic Web TWAIN` development. If you check our [release notes](/_articles/info/schedule/Stable.md), you can find that most of our development has been done to the HTML5-based editions of `Dynamic Web TWAIN` . For ActiveX, the strategy is as follows: * It'll continue to be a part of the Windows edition * No new features will be added * If a major bug is found, Dynamsoft will fix it * If there is a major feature conflict between two editions, the preference is to upgrade the ActiveX version or tag its behavior as deprecated We encourage customers who are still using the ActiveX edition of `Dynamic Web TWAIN` to consider moving to another edition as soon as possible. ## Move away from ActiveX If your organization or the end users of your application have decided to abandon the obsolete IE browser and switch to modern browsers like Chrome, Firefox, Edge, etc. You might need to consider moving away from the ActiveX. See below on how to proceed. ### You only have an ActiveX License In this case, you will need to purchase a new license to use the alternative edition which is the HTML5 edition. If you are using version 12.3.1 and above, you can get an HTML5 edition license for that same version, then just replacing the ActiveX license with the new license would work. Of course, we suggest that you also upgrade to use the latest edition of the SDK to keep up-to-date with the latest improvements. If you decide to upgrade, you may need to modify your code a bit. Contact [Dynamsoft Support](/_articles/about/getsupport.md) if you need help. If you are using a version older than 12.3.1, an upgrade will be inevitable. Contact [Dynamsoft Support](/_articles/about/getsupport.md) for more information. ### You already have a non-ActiveX license In this case, if your application already works on non-IE browsers, you can just let your users know that they can make the switch at any time. If your application only uses the ActiveX now, you can test the application in the modern browsers and see if it works (make sure you have the correct license in place). Contact [Dynamsoft Support](/_articles/about/getsupport.md) if you need help. --- title: Dynamic Web TWAIN SDK Development - Angular Integration description: Dynamic Web TWAIN SDK Documentation Angular Integration Page source_url: html: https://www.dynamsoft.com/web-twain/docs/indepth/development/angular.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/indepth/development/angular.md --- # Use Web TWAIN in Angular [Angular](https://angular.io/) is one of the most popular and mature JavaScript frameworks. Check out the following on how to implement `Dynamic Web TWAIN` into an Angular application. ![](https://www.dynamsoft.com/web-twain/docs/assets/imgs/download.png) [Sample of dwt-angular-advanced](https://github.com/dynamsoft-dwt/dwt-angular-advanced) ## Preparation Make sure you have [node](https://nodejs.org/) and [Angular CLI](https://cli.angular.io/) installed. `node 22.14.0` and `Angular CLI 19.1.7` are used in the example below. ## Create the sample project ### Create an out-of-the-box raw Angular application ``` cmd ng new dwt-angular ``` ### **cd** to the root directory of the application and install the dependencies ``` cmd npm install dwt@19.4.1 ``` ## Configure the project Open `angular.json` and add the following lines to `"build"/"options"/"assets"` . > These lines will copy the static files necessary to run `Dynamic Web TWAIN` to the resulting project. ``` json { "glob": "**/*", "input": "./node_modules/dwt/dist", "output": "assets/dwt-resources" } ``` We can get these resource files in a few different ways. See our [resource loading guide](/_articles/general-usage/resource-loading.md) to see how to load resource files from our official SDK, CDNs, or package managers. ## Start to implement ### Generate a component ``` cmd ng generate component dwt ``` ### Edit the component * In `dwt.component.html` add a button and a `HTMLDIVElement` . ``` html
``` * In `dwt.component.ts` add code to initialize `Dynamic Web TWAIN` . ``` typescript import Dynamsoft from 'dwt'; ``` ``` typescript containerId = "dwtcontrolContainer"; ngOnInit(): void { Dynamsoft.DWT.Containers = [{ WebTwainId: 'dwtObject', ContainerId: this.containerId, Width: '300px', Height: '400px' }]; Dynamsoft.DWT.RegisterEvent('OnWebTwainReady', () => { this.Dynamsoft_OnReady(); }); Dynamsoft.DWT.ProductKey = 'YOUR-PRODUCT-KEY'; Dynamsoft.DWT.ResourcesPath = 'assets/dwt-resources'; Dynamsoft.DWT.Load(); } ``` > Note: > * `containerId` specifies the `HTMLDIVElement` to create `Dynamic Web TWAIN` viewer in. > * `OnWebTwainReady` is the callback triggered when the initialization succeeds. > * `ProductKey` must be set to a valid trial or full key. > * `ResourcesPath` is set to the location of the static files mentioned in [Configure the project](#configure-the-project). * Get a handler of the `WebTwain` instance. Use the method [ `Dynamsoft.DWT.GetWebTwain()` ](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain) to get a handler of the created `WebTwain` instance. ``` typescript import { WebTwain } from 'dwt/dist/types/WebTwain'; ``` ``` typescript DWTObject: WebTwain | any = null; Dynamsoft_OnReady() { this.DWTObject = Dynamsoft.DWT.GetWebTwain(this.containerId); } ``` * Define the function `acquireImage()` . ``` typescript acquireImage() { if (this.DWTObject) { this.DWTObject.SelectSourceAsync() .then(() => { return this.DWTObject.AcquireImageAsync({ IfCloseSourceAfterAcquire: true, }); }) .catch((exp:any) => { console.error(exp.message); }); } } ``` * Add the component to `app.component.html` . Edit the file `app.component.html` to contain nothing but the following ``` html ``` * Add the component to `app.component.ts` . ``` typescript import { DwtComponent } from "./dwt/dwt.component"; ``` ``` typescript imports: [RouterOutlet, DwtComponent], ``` ### Review the Complete Code * `dwt.component.html` ``` html
``` * `dwt.component.ts` ``` typescript import { Component } from '@angular/core'; import Dynamsoft from 'dwt'; import { WebTwain } from 'dwt/dist/types/WebTwain'; @Component({ selector: 'app-dwt', imports: [], templateUrl: './dwt.component.html', styleUrl: './dwt.component.css' }) export class DwtComponent { containerId = "dwtcontrolContainer"; ngOnInit(): void { Dynamsoft.DWT.Containers = [{ WebTwainId: 'dwtObject', ContainerId: this.containerId, Width: '300px', Height: '400px' }]; Dynamsoft.DWT.RegisterEvent('OnWebTwainReady', () => { this.Dynamsoft_OnReady(); }); Dynamsoft.DWT.ProductKey = 'YOUR-PRODUCT-KEY'; Dynamsoft.DWT.ResourcesPath = 'assets/dwt-resources'; Dynamsoft.DWT.Load(); } DWTObject: WebTwain | any = null; Dynamsoft_OnReady() { this.DWTObject = Dynamsoft.DWT.GetWebTwain(this.containerId); } acquireImage() { if (this.DWTObject) { this.DWTObject.SelectSourceAsync() .then(() => { return this.DWTObject.AcquireImageAsync({ IfCloseSourceAfterAcquire: true, }); }) .catch((exp: any) => { console.error(exp.message); }); } } } ``` > Note: > * `ProductKey` must be set to a valid trial or full key. * `app.component.html` ``` html ``` * `app.component.ts` ``` typescript import { Component } from '@angular/core'; import { RouterOutlet } from '@angular/router'; import { DwtComponent } from "./dwt/dwt.component"; @Component({ selector: 'app-root', imports: [RouterOutlet, DwtComponent], templateUrl: './app.component.html', styleUrl: './app.component.css' }) export class AppComponent { title = 'dwt-angular'; } ``` ## Try running the project. ``` cmd ng serve -o ``` > If you have installed `Dynamic Web TWAIN` and have configured a valid `ProductKey` . You will have a working page to scan documents from your scanner now. Otherwise, you should see instructions on the page that guide you to install the library. [More info>>](/_articles/general-usage/initialization.md#installation-of-the-dynamsoft-service). ## Official Sample Check out the following sample project: * [dwt-angular-advanced](https://github.com/dynamsoft-dwt/dwt-angular-advanced)
--- title: Dynamic Web TWAIN SDK Development - ARM64 & MIPS64 support description: Dynamic Web TWAIN SDK Documentation ARM64 & MIPS64 Support Page source_url: html: https://www.dynamsoft.com/web-twain/docs/indepth/development/armmips.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/indepth/development/armmips.md --- # Support ARM64 or MIPS64 based computers In V17.0, we added support for 64-bit ARM & MIPS64 based computers. The corresponding service installer has been included in the V17.1+ official package. To get the V17.0 service installer package for ARM64 or MIPS64, please contact [Dynamsoft Support](/_articles/about/getsupport.md). --- title: Dynamic Web TWAIN SDK Development - Index description: Dynamic Web TWAIN SDK Documentation Development Index Page source_url: html: https://www.dynamsoft.com/web-twain/docs/indepth/development/index.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/indepth/development/index.md --- # Development Popular frameworks and frequently asked development questions are covered in these articles. * [Use Web TWAIN in Angular](/_articles/indepth/development/angular.md) * [Use Web TWAIN in React](/_articles/indepth/development/react.md) * [Use Web TWAIN in Vue](/_articles/indepth/development/vue.md) * [Upload or download images with Server-side scripts](/_articles/general-usage/server-side-scripting.md) * [Enable mobile web capture](/_articles/indepth/development/mobile-web-capture.md) * [How to perform upgrade](/_articles/indepth/development/upgrade.md) --- title: Dynamic Web TWAIN SDK Development - MRZ Scanner Integration description: Dynamic Web TWAIN SDK Documentation MRZ Scanner Integration Page source_url: html: https://www.dynamsoft.com/web-twain/docs/indepth/development/mrz.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/indepth/development/mrz.md --- # Integrating the MRZ Scanner into a Dynamic Web TWAIN Application One of the solutions that Dynamsoft offers is the [MRZ Scanner](https://www.dynamsoft.com/use-cases/mrz-scanner/), which is built on the foundational products [Dynamsoft Label Recognizer]({{ site.dcv }}core/introduction/?ver=latest&ver=latest#dynamsoft-label-recognizer) and the [Dynamsoft Code Parser]({{ site.dcv }}core/introduction/?ver=latest&ver=latest#dynamsoft-code-parser). This solution allows the user to scan MRZs in a web or native mobile application, either via a camera or static images from the local photo library. In this article, we will address how you can integrate the foundational products of the MRZ Scanner JavaScript Edition (Dynamsoft Label Recognizer, Dynamsoft Code Parser) with Dynamic Web TWAIN to implement the ability to read from static images without the need for a camera input. > [!NOTE] > You can download the [full sample code](https://github.com/Dynamsoft/mrz-scanner-javascript/tree/main/samples/dwt-mrz) from the Github repository of the MRZ Scanner Samples. Please use this sample as reference when building your own application. ## Initialization Dynamic Web TWAIN (DWT for short) allows users to acquire images from scanners in a web application, as well as load or download existing documents. One of the advantages of using Dynamic Web TWAIN is that it allows the user to load in PDFs as well as images. So whether you are loading in a local image or acquiring an image from a physical scanner, Dynamic Web TWAIN keeps things simple and implements these features with a few simple API. ### Setting up the Resources The first thing to do when creating a web application that utilizes DWT is to include the Resources folder of DWT. In this folder, the template for the MRZ Reader needs to also be included since it will be referenced by the MRZ Reader. To get a copy of the DWT Resources, please download the [30-day free trial](https://www.dynamsoft.com/web-twain/downloads) of Dynamic Web TWAIN. To get started with setting up the DWT resources and license key, please refer to the [General Usage]({{ site.general-usage }}index.html) page of the DWT docs. For the implementation that this guide will address, we will keep it to the basic functionalities of DWT, which is to [acquire images from a scanner]({{ site.general-usage }}scanner-image-acquisition.html) and [loading documents from local files]({{ site.extended-usage }}file-import.html). ### Initializing the Input Source and Capture Vision Instance The following is the full code needed to implement the basic functionalities of Dynamic Web TWAIN as well as the initialization of the MRZ reader using the [foundational API]({{ site.dcv }}web/programming/javascript/api-reference/index.html) of Dynamsoft Capture Vision. ```html Hello World

MRZ Result:

``` ## Implementing the MRZ Reader Now that we introduced the code to initialize DWT and the MRZ Reader, as well as defined the functions that implement the scanning and loading capabilities of Web TWAIN, it's time now to implement the MRZ reading portion of the code. Continuing the **script** from the previous section: ```js // Used by the Button on page, to trigger a MRZ read with the current select page async function readMRZ() { if (!checkIfImagesInBuffer()) { return; } if (!cvRouter) { console.log("cvRouter is not initialized."); return; } let imgURL = DWTObject.GetImageURL(DWTObject.CurrentImageIndexInBuffer); let capturedResults = await cvRouter.capture(imgURL, "ReadPassportAndId"); const recognizedResults = capturedResults.textLineResultItems; const parsedResults = capturedResults.parsedResultItems; if (!parsedResults || !parsedResults.length) { console.log("No Result"); return; } let extractedResults = JSON.stringify(extractDocumentFields(parsedResults[0])); extractedResults = extractedResults.split(",").join("\n"); extractedResults = extractedResults.replace(/{"text":|[{"}]/g, ""); document.getElementById("divNoteMessage").innerHTML = extractedResults; // print the result to the result div } /** * Extracts and returns document fields from the parsed MRZ result * * @param {Object} result - The parsed result object containing document fields. * @returns {Object} An object with key-value pairs of the extracted fields. */ function extractDocumentFields(result) { if (!result || result.exception) { return {}; } const fieldWithStatus = (fieldName, raw=false) => ({ text: raw ? result.getFieldRawValue(fieldName) : result.getFieldValue(fieldName), }); const parseDate = (yearField, monthField, dayField) => { const year = result.getFieldValue(yearField); const currentYear = new Date().getFullYear() % 100; const baseYear = yearField === "expiryYear" ? (parseInt(year) >= 60 ? "19" : "20") : parseInt(year) > currentYear ? "19" : "20"; return { text: `${baseYear}${year}-${result.getFieldValue(monthField)}-${result.getFieldValue(dayField)}`, }; }; // Add special case for Spanish IDs const getDocumentNumber = (codeType) => { const documentType = mapDocumentType(codeType); const documentNumberField = documentType === "passport" && codeType === "MRTD_TD3_PASSPORT" ? "passportNumber" : result.getFieldRawValue("nationality") === "ESP" ? "optionalData1" : "documentNumber"; const primaryNumber = fieldWithStatus(documentNumberField); const longNumber = fieldWithStatus("longDocumentNumber"); return primaryNumber?.text ? primaryNumber : longNumber; }; // Document Type and Name const codeType = result.codeType; return { Surname: fieldWithStatus("primaryIdentifier"), "Given Name": fieldWithStatus("secondaryIdentifier"), Nationality: fieldWithStatus("nationality", true), "Document Number": getDocumentNumber(codeType), "Document Type": documentTypeLabel(codeType), "Issuing State": fieldWithStatus("issuingState", true), Sex: fieldWithStatus("sex", true), "Date of Birth (YYYY-MM-DD)": parseDate("birthYear", "birthMonth", "birthDay"), "Date of Expiry (YYYY-MM-DD)": parseDate("expiryYear", "expiryMonth", "expiryDay"), "Document Type": JSON.parse(result.jsonString).CodeType, }; } function mapDocumentType(codeType) { switch (codeType) { case "MRTD_TD1_ID": return "td1"; case "MRTD_TD2_ID": case "MRTD_TD2_VISA": case "MRTD_TD2_FRENCH_ID": return "td2"; case "MRTD_TD3_PASSPORT": case "MRTD_TD3_VISA": return "passport"; default: throw new Error(`Unknown document type: ${codeType}`); } } function documentTypeLabel(codeType) { switch (codeType) { case "MRTD_TD1_ID": return "ID (TD1)"; case "MRTD_TD2_ID": return "ID (TD2)"; case "MRTD_TD2_VISA": return "ID (VISA)"; case "MRTD_TD2_FRENCH_ID": return "French ID (TD2)"; case "MRTD_TD3_PASSPORT": return "Passport (TD3)"; case "MRTD_TD3_VISA": return "Visa (TD3)"; default: throw new Error(`Unknown document type: ${codeType}`); } } ``` By completing the script with the code above, you can now go ahead and test the app that you just created. Please note that in order to properly function, the sample will need to be hosted on a server. If you are using VS Code, a quick and easy way to serve the project is using the [Live Server (Five Server) VSCode extension](https://marketplace.visualstudio.com/items?itemName=yandeu.five-server). Simply install the extension, open the `hello-world.html` file in the editor, and click "Go Live" in the bottom right corner of the editor. This will serve the application at `http://127.0.0.1:5500/hello-world.html`. Alternatively, you can also use IIS or Github Pages to quickly serve your application. ## Final Comments This sample was built based on the Hello World sample code of Web TWAIN as well as the Hello World code of the previous version of the MRZ Scanner that was dependent fully on the foundational API of Dynamsoft Capture Vision. Here are some references to check out: - [Dynamic Web TWAIN User Guide]({{ site.general-usage }}index.html) - [MRZ Scanner User Guide using Foundational DCV API](https://www.dynamsoft.com/mrz-scanner/docs/web/guides/mrz-scanner-v1.1.html?ver=1.1&matchVer=true&cVer=true) - [Dynamic Web TWAIN API Reference]({{ site.api }}) - [DCV Foundational API Reference]({{ site.dcv }}web/programming/javascript/api-reference/index.html) If there are any questions regarding this sample or your own implementation, please feel free to contact the [Dynamsoft Support Team](https://www.dynamsoft.com/company/contact/).
--- title: Dynamic Web TWAIN SDK Development - React Integration description: Dynamic Web TWAIN SDK Documentation React Integration Page source_url: html: https://www.dynamsoft.com/web-twain/docs/indepth/development/react.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/indepth/development/react.md --- # Use Web TWAIN in React [React](https://reactjs.org/) is a JavaScript library meant explicitly for creating interactive UIs. Follow this guide to learn how to implement `DWT` in a React application. ## Preparation Make sure you have [node](https://nodejs.org/) installed. `node 20.18.2` is used in the example below. ## Create the Sample Project ### Create a React project using Vite: ``` cmd npm create vite@latest dwt-react --template react ``` After running this, you will need to select the following options: - Select a framework: React - Select a variant: JavaScript ### Navigate to the project folder: ``` cmd cd dwt-react ``` ### Install dependencies and the required packages for DWT and NCP: ``` cmd npm install ``` ``` cmd npm install dwt@19.4.1 ncp ``` > `ncp` is used to copy static resources files. ## Configure the Project Open `package.json` and change `scripts` like this: ``` json "scripts": { "copy-resources": "ncp node_modules/dwt/dist public/dwt-resources", "dev": "npm run copy-resources && vite", "build": "npm run copy-resources && vite build", "lint": "eslint .", "preview": "vite preview" }, ``` > Note: The change ensures the static files required to run `DWT` are copied over to the built project. We can get these resource files in a few different ways. See our [resource loading guide](/_articles/general-usage/resource-loading.md) to see how to load resource files from our official SDK, CDNs, or package managers. ## Implementation ### Generate a Component Under `/src/`, create a new JavaScript file and name it `dwt.jsx`. ### Edit the Component * Copy the following to the newly created `dwt.jsx`. ``` typescript import React, { useEffect, useRef } from 'react'; import Dynamsoft from 'dwt'; function DWT() { const containerId = 'dwtcontrolContainer'; const dwtObject = useRef(null); useEffect(() => { Dynamsoft.DWT.RegisterEvent('OnWebTwainReady', () => { dwtObject.current = Dynamsoft.DWT.GetWebTwain(containerId); }); Dynamsoft.DWT.ProductKey = 'YOUR-PRODUCT-KEY'; Dynamsoft.DWT.ResourcesPath = "/dwt-resources"; Dynamsoft.DWT.Containers = [{ WebTwainId: 'dwtObject', ContainerId: containerId, Width: '300px', Height: '400px' }]; Dynamsoft.DWT.Load(); }, []); const acquireImage = () => { if (dwtObject.current) { dwtObject.current.SelectSourceAsync() .then(() => dwtObject.current.AcquireImageAsync({ IfCloseSourceAfterAcquire: true, })) .catch((error) => { console.error(error.message); }); } }; return ( <>
); }; export default DWT; ``` > Note: > * `containerId` specifies the DIV to create `DWT` viewer in which is defined in the `template`. > * `OnWebTwainReady` is the callback triggered when the initialization succeeds. > * `ProductKey` must be set to a valid trial or full key. > * `ResourcesPath` points to the location of the static files mentioned in [Configure the project](#configure-the-project). ### Add the Component to `App.jsx` ``` javascript import React from 'react'; import './App.css'; import DWT from './dwt'; function App() { return ; } export default App; ``` ### remove default styles Clear the contents of the src/App.css and src/index.css files. ### Run the Application ``` cmd npm run dev ``` > Note: If you have installed `DWT` and have configured a valid `ProductKey`, you will have a working page to scan documents from your scanner now. Otherwise, you should see instructions on the page that guide you to install the library. [More info>>](/_articles/general-usage/initialization.md#installation-of-the-dynamsoft-service) ## Official Samples Check out the following sample project: * [dwt-react-advanced](https://github.com/Dynamsoft/web-twain-react-advanced)
--- title: Dynamic Web TWAIN SDK Development - Upgrade Guide description: Dynamic Web TWAIN SDK Documentation Upgrade Guide Page source_url: html: https://www.dynamsoft.com/web-twain/docs/indepth/development/upgrade.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/indepth/development/upgrade.md --- # Upgrade This upgrade section talks about how to upgrade Dynamic Web TWAIN to a newer version. ## How to upgrade You can follow the steps below to upgrade Dynamic Web TWAIN: 1. Back up your current copy of `dynamsoft.webtwain.config.js`. 2. On your development machine, uninstall the old version of Dynamic Web TWAIN and install the new one. 3. Get the new **Resources** folder under the installation folder of Dynamic Web TWAIN and update the folder in your application. Use your original `dynamsoft.webtwain.config.js` if you want to keep the old settings. Typical paths of Dynamic Web TWAIN folder: * **Windows**: `C:\Program Files (x86)\Dynamsoft\Dynamic Web TWAIN SDK {Version Number}\` * **macOS**: `Applications > Dynamsoft > Dynamic Web TWAIN SDK {Version Number}` 4. Make necessary updates to the related code. If you get a new **license key** for the new version, you may follow the steps in [License](/_articles/general-usage/license.md) to update it. For changes in the new version, you can check the [Release Notes](/_articles/info/schedule/Stable.md) and [Deprecations](/_articles/info/schedule/deprecated.md). > Note: Please be aware of the following namespace changes introduced in v17.0: > | v17.0+ |v16.2- | > |:-|:-| > |`Dynamsoft.DWT` |`Dynamsoft.WebTwainEnv`| > |`Dynamsoft.DWT.EnumDWT_` |`Dynamsoft.EnumDWT_`| > |`Dynamsoft.DBR.EnumBarcodeFormat` |`Dynamsoft.EnumBarcodeFormat`| 5. Deploy the new version files to your server and test. Beginning with Dynamic Web TWAIN v16.0, the Dynamic Web TWAIN Service(formerly known as Dynamsoft Service) is backward compatible within _the same major version_. Once you upgrade Dynamic Web TWAIN for your application on the server side, for **end-users' side** - If the end-users have installed the same version or newer minor versions of Dynamic Web TWAIN Service, they don't need to do anything; - If the end-users have never installed Dynamic Web TWAIN Service, or have an older version or a different newer major version of it, they will be required to do a reinstallation of Dynamic Web TWAIN Service. The process is described here ## Update `dwt` package If your application uses a framework or library like Angular, React, Vue, etc. and uses the `dwt` package, you can just install the new version of Dynamic Web TWAIN to replace the old one. For example: > Note: the `@types/dwt` package is no longer used, and types are now included within the `dwt` package itself as of [version 17.0](/_articles/info/schedule/Stable.md#17004202021). For npm: ``` cmd npm install dwt ``` For Yarn: ``` cmd yarn add dwt ``` --- title: Dynamic Web TWAIN SDK Development - Vue Integration description: Dynamic Web TWAIN SDK Documentation Vue Integration Page source_url: html: https://www.dynamsoft.com/web-twain/docs/indepth/development/vue.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/indepth/development/vue.md --- # Use Web TWAIN in Vue [Vue](https://vuejs.org/) is a progressive framework for building user interfaces. Check out the following guide on how to integrate `DWT` into a Vue application.
- [Vue](#vue) - [Vue 3](#vue3)
## Preparation Make sure you have [node](https://nodejs.org/), [yarn](https://yarnpkg.com/cli/install), and [Vue CLI](https://cli.vuejs.org/) installed. `node 14.4.0` , `yarn 1.22.4`, and `@vue/cli 4.46` are used in the example below. ## Create the sample project ### Create a bootstrapped raw Vue application ``` cmd vue create dwt-vue ``` ### Navigate to the root directory of the application and install the `dwt` and `ncp` package ``` cmd yarn add dwt@19.4.1 ``` ``` cmd yarn add ncp ``` > `ncp` is used to copy static resources files. ## Configure the project Open `package.json` and change `scripts` as seen below: ``` json "scripts": { "serve": "ncp node_modules/dwt/dist public/dwt-resources && vue-cli-service serve", "build": "vue-cli-service build&& ncp node_modules/dwt/dist build/dwt-resources", "lint": "vue-cli-service lint" }, ``` > The change ensures the static files required to run `DWT` are copied over to the resulting built project. We can get these resource files in a few different ways. See our [resource loading guide](/_articles/general-usage/resource-loading.md) to see how to load resource files from our official SDK, CDNs, or package managers. ## Start to implement ### Edit the default component Change the file `/src/components/HelloWorld.vue` to match the following `template` and `script` (keep the `style` as is) ``` html ``` > Note: > * `containerId` specifies the DIV to create `DWT` viewer, which is defined in the `template`. > * `OnWebTwainReady` is the callback triggered when `DWT` initialization succeeds. > * `ProductKey` must be set to a valid trial or full key. > * `ResourcesPath` is set to the location of the static files mentioned in [Configure the project](#configure-the-project). ### Try running the project ``` cmd yarn serve ``` #### On desktop If you have installed `DWT` and have configured a valid `ProductKey` . You will have a working page to scan documents from your scanner now. Otherwise, you should see instructions on [this page](/_articles/general-usage/initialization.md#installation-of-the-dynamsoft-service) that guides you on installing the library. #### On mobile You should be able to open a file or capture an image.
## Preparation The recommended versions for Vue and Node are `v3.2.22` and `v16+` respectively. ## Create the sample project ### Create a bootstrapped raw Vue 3 application Assume the project name is "dwt-vue3" ``` cmd npm init vue@latest ``` ### Navigate to the root directory of the application and install the `dwt` and `ncp` package ``` cmd cd dwt-vue3 ``` ``` cmd npm install ``` ``` cmd npm install dwt@19.4.1 ``` ``` cmd npm install ncp ``` ## Configure the project Open `package.json` and change `scripts` as seen below: ``` json "scripts": { "dev": "ncp node_modules/dwt/dist public/dwt-resources && vite", "build": "ncp node_modules/dwt/dist public/dwt-resources && vite build", "preview": "vite preview" }, ``` > The change ensures the static files required to run `DWT` are copied over to the resulting built project. We can get these resource files in a few different ways. See our [resource loading guide](/_articles/general-usage/resource-loading.md) to see how to load resource files from our official SDK, CDNs, or package managers. ## Start to implement ### Edit the default component Create `localScan.vue` in the folder /src/components ```html ``` > Note: > * `containerId` specifies the DIV to create `DWT` viewer, which is defined in the `template`. > * `OnWebTwainReady` is the callback triggered when `DWT` initialization succeeds. > * `ProductKey` must be set to a valid trial or full key. > * `ResourcesPath` is set to the location of the static files mentioned in [Configure the project](#configure-the-project). Change the file /src/App.vue ```html ``` ### Try running the project ``` cmd npm run dev ``` #### On desktop If you have installed `DWT` and have configured a valid `ProductKey` . You will have a working page to scan documents from your scanner now. Otherwise, you should see instructions on [this page](/_articles/general-usage/initialization.md#installation-of-the-dynamsoft-service) that guides you on installing the library. ## Official Samples Check out the following sample project: * [dwt-vue](https://github.com/Dynamsoft/web-twain-vue-advanced)
--- title: Dynamic Web TWAIN SDK Documentation description: Dynamic Web TWAIN SDK Documentation Homepage source_url: html: https://www.dynamsoft.com/web-twain/docs/index.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/index.md --- # Dynamic Web TWAIN Documentation ## [Introduction]({{site.introduction}}index.html) - [System Requirements]({{site.introduction}}system-requirements.html) - [Imaging Hardware]({{site.introduction}}imaging-hardware.html) - [Supported File Formats]({{site.introduction}}supported-file-formats.html) - Core Concepts - [Scanner](/_articles/core-concepts/scanner.md) - [TWAIN](/_articles/core-concepts/TWAIN.md) - [Dynamic Web TWAIN Service](/_articles/core-concepts/Dynamic-Web-TWAIN-Service.md) - [Resource Files](/_articles/core-concepts/resource-files.md) ## Developer Guide ### [Hello World]({{site.hello-world}}index.html) - [Scanning an Image]({{site.hello-world}}scanning.html) - [Uploading images to the server]({{site.hello-world}}uploading.html) - [Specifying Scan Settings]({{site.hello-world}}scan-settings.html) - [Editing Images]({{site.hello-world}}editing.html) ### [General Usage Guide]({{site.genera-usage}}index.html) - [Loading Library Resources]({{site.general-usage}}resource-loading.html) - [Configuring License Keys]({{site.general-usage}}license.html) - [Initializing DWT]({{site.general-usage}}initialization.html) - [Acquiring Images from Scanners]({{site.general-usage}}scanner-image-acquisition.html) - [Configuring the Viewer]({{site.general-usage}}viewer-configuration.html) - [Processing Images]({{site.general-usage}}image-processing/index.html) - [Managing the Image Buffer]({{site.general-usage}}image-processing/buffer-management.html) - [Editing Images]({{site.general-usage}}image-processing/image-editing.html) - [Exporting Images]({{site.general-usage}}image-export/index.html) - [Uploading to the Web Server]({{site.general-usage}}image-export/server-upload.html) - [Exporting Locally]({{site.general-usage}}image-export/local-export.html) - [Server-Side Scripting]({{site.general-usage}}server-side-scripting.html) - [Deploying to the Server]({{site.general-usage}}server-deployment.html) ### [Extended Usage Guide]({{site.extended-usage}}index.html) - [Advanced DWT Initialization]({{site.extended-usage}}advanced-initialization.html) - [Loading Documents from Files]({{site.extended-usage}}file-import.html) - [Configuring System Messages]({{site.extended-usage}}system-message-configuration.html) - [Set Up the Dynamic Web TWAIN Service]({{site.extended-usage}}dynamsoft-service-configuration.html) - [UI Customization]({{site.extended-usage}}ui-customization.html) - [Using the DWT RESTful API]({{site.extended-usage}}restful-api.html) - [Barcode Recognition]({{site.extended-usage}}barcode-processing.html) - [PDF Handling]({{site.extended-usage}}pdf-processing.html) - [OCR](/_articles/extended-usage/ocr.md) - [Remote Scan](https://www.dynamsoft.com/remote-scan/docs/introduction/) - [Configuring System Messages]({{site.extended-usage}}system-message-configuration.html) ### Samples and Demos - [Use Web TWAIN in Angular]({{site.indepth}}development/angular.html) - [Use Web TWAIN in React]({{site.indepth}}development/react.html) - [Use Web TWAIN in Vue]({{site.indepth}}development/vue.html) - [Use Web TWAIN with the MRZ Scanner]({{site.indepth}}development/mrz.html) - [Code Gallery](https://www.dynamsoft.com/web-twain/resources/code-gallery/) ### [API Reference]({{site.api}}index.html) - [Global]({{site.api}}Dynamsoft_WebTwainEnv.html) - [Scan]({{site.api}}WebTwain_Acquire.html) - [Buffer]({{site.api}}WebTwain_Buffer.html) - [Viewer]({{site.api}}WebTwain_Viewer.html) - [Edit]({{site.api}}WebTwain_Edit.html) - [Input/Output]({{site.api}}WebTwain_IO.html) - [Utility]({{site.api}}WebTwain_Util.html) - [Dynamsoft FileUploader]({{site.api}}Dynamsoft_FileUploader.html) - Add-On Modules - [Barcode Reader]({{site.api}}Addon_BarcodeReader.html) - [OCR](/_articles/info/api/Addon_OCR.md) - [PDF Rasterizer]({{site.api}}Addon_PDF.html) - [Webcam]({{site.api}}Addon_Webcam.html) - [Enumerations]({{site.api}}Dynamsoft_Enum.html) - [Interfaces]({{site.api}}Interfaces.html) - [Error List]({{site.api}}appendix.html) ## Useful Resources ### [Release Notes]({{site.info}}schedule) - [Stable]({{site.info}}schedule/stable.html) - [Addon]({{site.info}}schedule/Addon.html) - [Deprecated]({{site.info}}schedule/deprecated.html) ### AI - [Overview](/_articles/ai/overview.md) - [Agent Skills](/_articles/ai/agent-skills.md) ### [Upgrade Instructions]({{site.indepth}}development/upgrade.html) ### [End-User Guide](/_articles/end-user/index.md) ### [Resources]({{site.about}}resources.html) ### [Support]({{site.about}}getsupport.html) ### [FAQ]({{site.faq}}index.html) ### [Annotation]({{site.faq}}#annotation) --- title: Dynamic Web TWAIN SDK API Reference - BarcodeReader Addon APIs description: Dynamic Web TWAIN SDK Documentation API Reference BarcodeReader Addon APIs Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/api/Addon_BarcodeReader.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/Addon_BarcodeReader.md --- # {WebTwainObject}.Addon.BarcodeReader > {WebTwainObject} denotes the `WebTwain` instance. **Methods** | [`decode()`](/_articles/info/api/Addon_BarcodeReader.md#decode) | [`getRuntimeSettings()`](/_articles/info/api/Addon_BarcodeReader.md#getruntimesettings) | [`updateRuntimeSettings()`](/_articles/info/api/Addon_BarcodeReader.md#updateruntimesettings) | | [`resetRuntimeSettings()`](/_articles/info/api/Addon_BarcodeReader.md#resetruntimesettings) | [`initRuntimeSettingsWithString()`](/_articles/info/api/Addon_BarcodeReader.md#initruntimesettingswithstring) | | --- ## decode() Read an image in the buffer and try to locate and decode barcode(s) on it. Please refer to [`TextResult`](/_articles/info/api/interfaces.md#textresult). **Syntax** ```typescript decode(index: number): Promise ; ``` **Parameters** `index`: Specify the image to decode. **Availability**
H5(Windows) H5(macOS) H5(Linux)
v14.1+ v19.0+ v19.0+
--- ## getRuntimeSettings() Return the current runtime settings or the settings of the specified built-in template. Please refer to [`RuntimeSettings`](/_articles/info/api/interfaces.md#runtimesettings). The template can only be "speed", "balance", or "coverage". **Syntax** ```typescript getRuntimeSettings(template?: string): Promise ; ``` **Availability**
H5(Windows) H5(macOS) H5(Linux)
v14.1+ v19.0+ v19.0+
--- ## updateRuntimeSettings() Update the runtime settings with a given object or use the string "speed", "balance", or "coverage" to use our preset settings. The default setting is "coverage". **Syntax** ```typescript updateRuntimeSettings(settings: RuntimeSettings): Promise ; ``` **Parameters** `settings`: Specify the runtime settings. Please refer to [`RuntimeSettings`](/_articles/info/api/interfaces.md#runtimesettings). **Availability**
H5(Windows) H5(macOS) H5(Linux)
v14.1+ v19.0+ v19.0+
**Example** ```javascript DWTObject.Addon.BarcodeReader.getRuntimeSettings("balance") .then(function (settings) { settings.barcodeFormatIds = Dynamsoft.DBR.EnumBarcodeFormat.BF_ONED; return DWTObject.Addon.BarcodeReader.updateRuntimeSettings(settings); }) .then(function () { DWTObject.Addon.BarcodeReader.decode(0).then( function (textResult) { console.log(textResult); }, function (ex) { console.log(ex.message || ex); } ); }); ``` --- ## resetRuntimeSettings() Reset all runtime settings to default values. Please refer to [`RuntimeSettings`](/_articles/info/api/interfaces.md#runtimesettings). **Syntax** ```typescript resetRuntimeSettings(): Promise ; ``` **Availability**
H5(Windows) H5(macOS) H5(Linux)
v14.1+ v19.0+ v19.0+
--- ## initRuntimeSettingsWithString() Set up the barcode reader with advanced settings. **Syntax** ```typescript initRuntimeSettingsWithString( settings: string ): Promise ; ``` **Parameters** `settings`: The runtime setting in the form of a string. **Return value** Please refer to [`RuntimeSettings`](/_articles/info/api/interfaces.md#runtimesettings). **Availability**
H5(Windows) H5(macOS) H5(Linux)
v16.0+ v19.0+ v19.0+
--- title: Dynamic Web TWAIN SDK API Reference - OCR Addon APIs description: Dynamic Web TWAIN SDK Documentation API Reference OCR Addon APIs Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/api/Addon_OCR.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/Addon_OCR.md --- # {WebTwainObject}.Addon.OCRKit > {WebTwainObject} denotes the `WebTwain` instance. **Methods** | [`GetInstalledOCRInfo()`](#getinstalledocrinfo) | [`DetectPageOrientation()`](#detectpageorientation) | [`Recognize()`](#recognize) | [`SaveToPath()`](#savetopath) | | [`SaveAsBase64()`](#saveasbase64) | [`SaveAsBlob()`](#saveasblob) | | | --- ## GetInstalledOCRInfo() Return the info of the installed OCR addon. It will throw an error if the OCR module is not installed. **Syntax** ```typescript GetInstalledOCRInfo(): Promise; ``` **Return Values** Promise of an [`OCRInfo`](/_articles/info/api/interfaces.md#ocrinfo) object. **Availability**
H5(Windows) H5(macOS) H5(Linux)
v19.3+ not supported not supported
--- ## DetectPageOrientation() **Syntax** ```ts DetectPageOrientation( index: number, settings?: { detectionMode?: EnumDWT_PageOrientationDetectionMode | number } ): Promise<{angle: EnumDWT_PageOrientation | number, confidence: number}>; ``` **Parameters** `index`: Index of the image to process. `settings`: Settings of the method. You can configure the accuracy mode. Please refer to [`EnumDWT_PageOrientationDetectionMode`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_pageorientationdetectionmode). **Return Values** Promise of an object of the orientation detection result. Please refer to [`EnumDWT_PageOrientation`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_pageorientation). **Availability**
H5(Windows) H5(macOS) H5(Linux)
v19.3+ not supported not supported
--- ## Recognize() Recognize the text in one page. **Syntax** ```ts Recognize( index: number, options?: { settings?: { language?: string, pageOrientation?: EnumDWT_PageOrientation| number, }, rects?: { left: number, top: number, right: number, bottom: number }[] } ): Promise; ``` **Parameters** `index`: Index of the image to process. `options`: * `settings`: Settings of the recognition. * `language`: Specify the code of language for recognition (`en`, `fr`, e.g.). See the table below listing supported languages. * `pageOrientation`: Specify the orientation of the page. The OCR will rotate the page before recognition. Please refer to [`EnumDWT_PageOrientation`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_pageorientation). * `rects`: An array of rectangles to limit the regions for recognition. **Return Values** Promise of the [`OCRResult`](/_articles/info/api/interfaces.md#ocrresult) object. **Supported Languages** | Language Name | Code | | :------------------------- | :---- | | English | en | | French | fr | | Spanish | es | | German | de | | Italian | it | | Portuguese | pt | **Availability**
H5(Windows) H5(macOS) H5(Linux)
v19.3+ not supported not supported
--- ## SaveToPath() Save the result to a local path. **Syntax** ```ts SaveToPath( indices: number[], outputFormat: Dynamsoft.DWT.EnumDWT_OCRKitOutputFormat | number, path: string ): Promise; ``` **Parameters** `indices`: Indices of the pages to save. `outputFormat`: Please refer to [`EnumDWT_OCRKitOutputFormat`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_ocrkitoutputformat). `path`: System's absolute path or filename for saving. A file saving dialog will appear for confirmation. **Return Values** Promise of a `boolean` result indicating the success of the operation. **Availability**
H5(Windows) H5(macOS) H5(Linux)
v19.3+ not supported not supported
--- ## SaveAsBase64() Save the result as base64. **Syntax** ```ts SaveAsBase64( indices: number[], outputFormat: Dynamsoft.DWT.EnumDWT_OCRKitOutputFormat | number ): Promise; ``` **Parameters** `indices`: Indices of the pages to save. `outputFormat`: Please refer to [`EnumDWT_OCRKitOutputFormat`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_ocrkitoutputformat). **Return Values** Promise of a base64 string result. **Availability**
H5(Windows) H5(macOS) H5(Linux)
v19.3+ not supported not supported
--- ## SaveAsBlob() Save the result as blob. **Syntax** ```ts SaveAsBlob( indices: number[], outputFormat: Dynamsoft.DWT.EnumDWT_OCRKitOutputFormat | number ): Promise; ``` **Parameters** `indices`: Indices of the pages to save. `outputFormat`: Please refer to [`EnumDWT_OCRKitOutputFormat`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_ocrkitoutputformat). **Return Values** Promise of a `Blob` object. **Availability**
H5(Windows) H5(macOS) H5(Linux)
v19.3+ not supported not supported
--- title: Dynamic Web TWAIN SDK API Reference - PDF Addon APIs description: Dynamic Web TWAIN SDK Documentation API Reference PDF Addon APIs Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/api/Addon_PDF.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/Addon_PDF.md --- # {WebTwainObject}.Addon.PDF > {WebTwainObject} denotes the `WebTwain` instance. **Methods** | [`GetConvertMode()`](#getconvertmode) | [`GetReaderOptions()`](#getreaderoptions) | [`IsModuleInstalled()`](#ismoduleinstalled) | [`IsRasterizationRequired()`](#israsterizationrequired) | | [`IsTextBasedPDF()`](#istextbasedpdf) | [`SetConvertMode()`](#setconvertmode) | [`SetPassword()`](#setpassword) | [`SetResolution()`](#setresolution) | | [`Write.Setup()`](#writesetup) | [`SetReaderOptions()`](#setreaderoptions) | | | --- ## GetConvertMode() > [!NOTE] > This API has been deprecated as of release 18.4. Please use the [`GetReaderOptions()`](/_articles/info/api/Addon_PDF.md#getreaderoptions) function. Return the convert mode. **Syntax** ```typescript GetConvertMode(): number; ``` Please refer to [`EnumDWT_ConvertMode`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_convertmode). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v17.2+ v17.2+ v17.2+ v17.2+
--- ## GetReaderOptions() Returns the current PDF reader options. Please refer to [`ReaderOptions`](/_articles/info/api/interfaces.md#readeroptions). **Syntax** ```typescript GetReaderOptions(): ReaderOptions; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.4+ v18.4+ v18.4+ v18.4+
--- ## IsModuleInstalled() Return whether the PDF module has been installed. **Syntax** ```typescript IsModuleInstalled(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.1+ v14.1+ v14.1+ v14.1+
--- ## IsRasterizationRequired() Return whether a local PDF file needs rasterization. If each PDF page contains only one image, return `false`. Otherwise, return `true`. **Syntax** ```typescript IsRasterizationRequired(path: string): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v19.0+ v19.0+ v19.0+ v19.0+
--- ## IsTextBasedPDF() Detect whether a local PDF file is text based or not. **Syntax** ```typescript IsTextBasedPDF(path: string): boolean; ``` **Parameters** `path`: Specify the path of the PDF file. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v11.2+ v11.2+ v11.2+ v11.2+
--- ## SetConvertMode() > [!NOTE] > This API has been deprecated as of release 18.4. Please use the [`SetReaderOptions()`](/_articles/info/api/Addon_PDF.md#setreaderoptions) function. Set the convert mode. **Syntax** ```typescript SetConvertMode(mode: Dynamsoft.DWT.EnumDWT_ConvertMode | number): boolean; ``` **Parameters** `mode`: Specify the mode. Please refer to [`EnumDWT_ConvertMode`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_convertmode). The default value is 3 (`Dynamsoft.DWT.EnumDWT_ConvertMode.CM_AUTO`) **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v11.2+ v11.2+ v11.2+ v11.2+
**Usage notes** There are three conversion modes - `CM_RENDERALL` (1): All the content in the target PDF file will be rasterized. - `CM_IMAGEONLY` (2): The PDF Rasterizer is turned off. - `CM_AUTO` (3): The library automatically detect whether a file needs to be rasterized or not and then process the file accordingly. Use this method before you import a PDF into the viewer with methods such as [`LoadImage()`](/_articles/info/api/WebTwain_IO.md#loadimage){:target="\_blank"}, [`HTTPDownload()`](/_articles/info/api/WebTwain_IO.md#httpdownload){:target="\_blank"}, and [`FTPDownload()`](/_articles/info/api/WebTwain_IO.md#ftpdownload){:target="\_blank"}. --- ## SetReaderOptions() Sets the current PDF reader options. **Syntax** ```typescript SetReaderOptions(options: ReaderOptions): boolean; ``` **Parameters** `options`: Please see the [`ReaderOptions`](/_articles/info/api/interfaces.md#readeroptions) interface. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.4+ v18.4+ v18.4+ v18.4+
**Usage Notes** Use this method before you import a PDF into the viewer with methods such as [`LoadImage()`](/_articles/info/api/WebTwain_IO.md#loadimage){:target="\_blank"}, [`HTTPDownload()`](/_articles/info/api/WebTwain_IO.md#httpdownload){:target="\_blank"}, and [`FTPDownload()`](/_articles/info/api/WebTwain_IO.md#ftpdownload){:target="\_blank"}. **Examples** 1. Render the PDF file to grayscale images without annotations. ```javascript DWTObject.Addon.PDF.SetReaderOptions({ convertMode: Dynamsoft.DWT.EnumDWT_ConvertMode.CM_RENDERALL, renderOptions: { renderAnnotations: false, renderGrayscale: true, }, }); ``` 2. Render the PDF file to images, but when saving, preserve the original data if the content of a page is not modified. ```javascript DWTObject.Addon.PDF.SetReaderOptions({ convertMode: Dynamsoft.DWT.EnumDWT_ConvertMode.CM_RENDERALL, preserveUnmodifiedOnSave: true, //only available for v19.0+ }); ``` --- ## SetPassword() > This API has been deprecated as of release 18.4. Please use the [`SetReaderOptions()`](/_articles/info/api/Addon_PDF.md#setreaderoptions) function. Set the password for reading encrypted PDF files. **Syntax** ```typescript SetPassword(password: string): boolean; ``` **Parameters** `password`: Specify the password. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v11.2+ v11.2+ v11.2+ v11.2+
**Usage notes** Use this method before you import a PDF into the viewer with methods such as [`LoadImage()`](/_articles/info/api/WebTwain_IO.md#loadimage){:target="\_blank"}, [`HTTPDownload()`](/_articles/info/api/WebTwain_IO.md#httpdownload){:target="\_blank"}, and [`FTPDownload()`](/_articles/info/api/WebTwain_IO.md#ftpdownload){:target="\_blank"}. --- ## SetResolution() > [!NOTE] > This API has been deprecated as of release 18.4. Please use the [`SetReaderOptions()`](/_articles/info/api/Addon_PDF.md#setreaderoptions) function. Set the resolution for rasterizing. **Syntax** ```typescript SetResolution(resolution: number): boolean; ``` **Parameters** `resolution`: Specify the resolution. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v11.2+ v11.2+ v11.2+ v11.2+
**Usage notes** The default resolution for the conversion is 200. We recommend that you set a value smaller than 300, otherwise it might slow down the program or cause the process to fail. Use this method before you import a PDF into the viewer with methods such as [`LoadImage()`](/_articles/info/api/WebTwain_IO.md#loadimage){:target="\_blank"}, [`HTTPDownload()`](/_articles/info/api/WebTwain_IO.md#httpdownload){:target="\_blank"}, and [`FTPDownload()`](/_articles/info/api/WebTwain_IO.md#ftpdownload){:target="\_blank"}. --- ## Write.Setup() Set up the PDF writing engine. **Syntax** ```typescript Write.Setup(settings: PDFWSettings): boolean; ``` **Parameters** `settings`: Configures how the PDF is generated. Please refer to [`PDFWSettings`](/_articles/info/api/interfaces.md#pdfwsettings). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v15.0+ v15.1+ v15.1+ v15.1+
**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** Use this method before you create a PDF with methods such as [`HTTPUpload()`](/_articles/info/api/WebTwain_IO.md#httpupload){:target="\_blank"}, [`SaveAsPDF()`](/_articles/info/api/WebTwain_IO.md#saveaspdf){:target="\_blank"}, and [`SaveAllAsPDF()`](/_articles/info/api/WebTwain_IO.md#saveallaspdf){:target="\_blank"}. Only the core module license is required to use this method.
--- title: Dynamic Web TWAIN SDK API Reference - Webcam Addon APIs description: Dynamic Web TWAIN SDK Documentation API Reference Webcam Addon APIs Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/api/Addon_Webcam.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/Addon_Webcam.md --- # {WebTwainObject}.Addon.Webcam > {WebTwainObject} denotes the `WebTwain` instance. The Webcam add-on works on Windows desktop. If you need to scan documents with camera on other platforms (macOS, Linux and mobile) or perform document boundary detection and cropping, you can use [Mobile Document Scanner](https://www.dynamsoft.com/use-cases/mobile-document-scanner/). **Methods** | [`CaptureImage()`](#captureimage) | [`CloseSource()`](#closesource) | [`GetCameraControlPropertySetting()`](#getcameracontrolpropertysetting) | [`GetCameraControlPropertyMoreSetting()`](#getcameracontrolpropertymoresetting) | | [`GetVideoPropertySetting()`](#getvideopropertysetting) | [`GetVideoPropertyMoreSetting()`](#getvideopropertymoresetting) | [`SetCameraControlPropertySetting()`](#setcameracontrolpropertysetting) | [`SetVideoPropertySetting()`](#setvideopropertysetting) | | [`GetFrameRate()`](#getframerate) | [`SetFrameRate()`](#setframerate) | [`GetMediaType()`](#getmediatype) | [`SetMediaType()`](#setmediatype) | | [`GetResolution()`](#getresolution) | [`SetResolution()`](#setresolution) | [`GetFramePartURL()`](#getframeparturl) | [`GetFrameURL()`](#getframeurl) | | [`GetSourceList()`](#getsourcelist) | [`SelectSource()`](#selectsource) | [`PauseVideo()`](#pausevideo) | [`PlayVideo()`](#playvideo) | | [`SetVideoRotateMode()`](#setvideorotatemode) | [`StopVideo()`](#stopvideo) | | | ## CaptureImage() Capture an image from the current camera. **Syntax** ```typescript CaptureImage( successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error String **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.2+ not supported not supported not supported
--- ## GetSourceList() Return a list of all available cameras. **Syntax** ```typescript GetSourceList(): string[]; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.2+ not supported not supported not supported
--- ## SelectSource() Select a camera to use. **Syntax** ```typescript SelectSource(name: string): boolean; ``` **Parameters** `name`: Specify the camera. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.2+ not supported not supported not supported
--- ## CloseSource() Close the current camera. **Syntax** ```typescript CloseSource(): boolean; ``` **Usage notes** When you close the camera, the video stream will stop at the last frame. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.2+ not supported not supported not supported
--- ## PlayVideo() Start to play the video stream from the current camera. **Syntax** ```typescript PlayVideo( DWTObject: WebTwain, quality: number, frameDidShow?: function () {} ): boolean; ``` **Parameters** `DWTObject`: Specify a WebTwain instance to show the video. `quality`: Specify the quality of the video. `frameDidShow`: A callback function that is triggered after each video frame is shown. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.3+ not supported not supported not supported
--- ## PauseVideo() Pause the video. **Syntax** ```typescript PauseVideo(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.3+ not supported not supported not supported
--- ## StopVideo() Stop the video. **Syntax** ```typescript StopVideo(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.3+ not supported not supported not supported
**Usage notes** When you capture a frame, it's always the actual latest frame from the camera even if you have paused the video. When you close the camera, the video stream will stop at the last frame. --- ## GetCameraControlPropertySetting() Return information about the specified camera property. Please refer to [`CameraControlProperty`](/_articles/info/api/interfaces.md#cameracontrolproperty). **Syntax** ```typescript GetCameraControlPropertySetting( property: Dynamsoft.DWT.EnumDWT_CameraControlProperty | number ): CameraControlProperty; ``` **Parameters** `property`: Specify the property. Please refer to [EnumDWT_CameraControlProperty](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_cameracontrolproperty). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.3+ not supported not supported not supported
--- ## GetCameraControlPropertyMoreSetting() Return detailed information about the specified camera property. Please refer to [`CameraControlPropertyExtra`](/_articles/info/api/interfaces.md#cameracontrolpropertyextra). **Syntax** ```typescript GetCameraControlPropertyMoreSetting( property: Dynamsoft.DWT.EnumDWT_CameraControlProperty | number ): CameraControlPropertyExtra; ``` **Parameters** `property`: Specify the property. Please refer to [EnumDWT_CameraControlProperty](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_cameracontrolproperty). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.3+ not supported not supported not supported
--- ## SetCameraControlPropertySetting() Set the specified camera property. **Syntax** ```typescript SetCameraControlPropertySetting( property: Dynamsoft.DWT.EnumDWT_CameraControlProperty | number, value: number, auto: boolean ): boolean; ``` **Parameters** `property`: Specify the property. Please refer to [EnumDWT_CameraControlProperty](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_cameracontrolproperty). `value`: Specify the value. `auto`: Specify whether the property should change automatically. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.3+ not supported not supported not supported
--- ## GetVideoPropertySetting() Return information about the specified video property. Please refer to [`VideoControlProperty`](/_articles/info/api/interfaces.md#videocontrolproperty). **Syntax** ```typescript GetVideoPropertySetting( property: Dynamsoft.DWT.EnumDWT_VideoProperty | number ): VideoControlProperty; ``` **Parameters** `property`: Specify the property. Please refer to [EnumDWT_VideoProperty](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_videoproperty). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.3+ not supported not supported not supported
--- ## GetVideoPropertyMoreSetting() Return detailed information about the specified video property. Please refer to [`VideoControlPropertyExtra`](/_articles/info/api/interfaces.md#videocontrolpropertyextra). **Syntax** ```typescript GetVideoPropertyMoreSetting( property: Dynamsoft.DWT.EnumDWT_VideoProperty | number ): VideoControlPropertyExtra; ``` **Parameters** `property`: Specify the property. Please refer to [EnumDWT_VideoProperty](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_videoproperty). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.3+ not supported not supported not supported
--- ## SetVideoPropertySetting() Set the specified video property. **Syntax** ```typescript SetVideoPropertySetting( property: Dynamsoft.DWT.EnumDWT_VideoProperty | number, value: number, auto: boolean ): boolean; ``` **Parameters** `property`: Specify the property. Please refer to [EnumDWT_VideoProperty](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_videoproperty). `value`: Specify the value. `auto`: Specify whether the property should change automatically. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.3+ not supported not supported not supported
--- ## GetFrameRate() Return the frame rates supported by the current camera. Please refer to [`FrameRate`](/_articles/info/api/interfaces.md#framerate). **Syntax** ```typescript GetFrameRate(): FrameRate; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.3.1+ not supported not supported not supported
--- ## GetMediaType() Return the media types supported by the current camera. Please refer to [`MediaType`](/_articles/info/api/interfaces.md#mediatype). **Syntax** ```typescript GetMediaType(): MediaType; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.3+ not supported not supported not supported
--- ## GetResolution() Return the resolutions supported by the current camera. Please refer to [`Resolution`](/_articles/info/api/interfaces.md#resolution). **Syntax** ```typescript GetResolution(): Resolution; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.3+ not supported not supported not supported
--- ## SetFrameRate() Set the frame rate. **Syntax** ```typescript SetFrameRate(rate: number): boolean; ``` **Parameters** `rate`: Specify the frame rate. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.3+ not supported not supported not supported
--- ## SetMediaType() Set the media type. **Syntax** ```typescript SetMediaType(type: string): boolean; ``` **Parameters** `type`: Specify the media type. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.3+ not supported not supported not supported
--- ## SetResolution() Set the resolution. **Syntax** ```typescript SetResolution(resolution: string): boolean; ``` **Parameters** `resolution`: Specify the resolution. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.3+ not supported not supported not supported
**Example** ```javascript DWTObject.Addon.Webcam.SetResolution("640 x 480"); ``` --- ## SetVideoRotateMode() Rotate the video. **Syntax** ```typescript SetVideoRotateMode( mode: Dynamsoft.DWT.EnumDWT_VideoRotateMode | number ): boolean; ``` **Parameters** `mode`: Specify the rotate mode. Please refer to [EnumDWT_VideoRotateMode](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_videorotatemode). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.3+ not supported not supported not supported
--- ## GetFrameURL() Return the URL (http(s)://) for the latest frame. **Syntax** ```typescript GetFrameURL(): string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.3.1+ not supported not supported not supported
--- ## GetFramePartURL() Return the internal URL (dwt://) for the latest frame. **Syntax** ```typescript GetFramePartURL(): string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.3.1+ not supported not supported not supported
**Usage notes** `GetFrameURL()` returns a public URL that can be used to access the frame directly by any application capable of HTTP requests that runs on the same machine. For example: `https://127.0.0.1:18623/dwt/dwt_16000428/img?id=853407158&index=-1&width=-1&height=-1&webcam=80&t=1590481406860`. `GetFramePartURL()` returns an internal URL that only Dynamsoft libraries such as the Barcode Reader add-on can read. For example: `dwt://dwt_16000428/img?id=853407158&index=-1&width=-1&height=-1&webcam=80&t=1590481403659`.
--- title: Dynamic Web TWAIN API Reference - Device APIs description: Dynamic Web TWAIN SDK Documentation API Reference Device APIs Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/api/Device.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/Device.md --- # {DeviceObject} Scan > The properties and methods on this page live in the namespace {DeviceObject}. ```typescript interface Device { /** * The real name of the device. */ readonly name: string; /** * The displayed name of the device. */ readonly displayName: string; readonly deviceType: Dynamsoft.EnumDWT_DeviceType; readonly serviceInfo?: ServiceInfo; readonly deviceInfo?: any; acquireImage( deviceConfiguration: DeviceConfiguration | null, sendTo: WebTwain, ): Promise; } ``` **Methods** | [`DeviceObject.acquireImage()`](#deviceobject.acquireimage) | --- ## DeviceObject.acquireImage() Scan documents into another DWTObject control. Supports eSCL scanners and all other scanners with limited capabilities. **Syntax** ```typescript acquireImage(deviceConfiguration: DeviceConfiguration | null, sendTo: WebTwain): Promise< boolean>; interface DeviceConfiguration { IfShowUI?: boolean; //Whether to show the built-in User Interface from the device vendor PixelType?: Dynamsoft.DWT.EnumDWT_PixelType | number | string; //Whether to scan in color, grey or black & white Resolution?: number; //Measured by dots per pixel (DPI) IfFeederEnabled?: boolean; //Whether to use the document feeder or the flatbed of the device IfDuplexEnabled?: boolean; //Whether to scan one side or both sides IfDisableSourceAfterAcquire?: boolean; //Whether to close the built-in User Interface after acquisition. Only valid when {IfShowUI} is true. IfGetImageInfo?: boolean; //Whether to retrieve information about the image after it's transferred. IfGetExtImageInfo?: boolean; //Whether to retrieve extended information about the image after it's transferred. extendedImageInfoQueryLevel?: Dynamsoft.DWT.EnumDWT_ExtImageInfo | number; //How much extended information is retrieved. Only valid when {IfGetExtImageInfo} is true. SelectSourceByIndex?: number; //Specify a source by its index. IfCloseSourceAfterAcquire?: boolean; //Whether to close the data source after acquisition. Default: false. } ``` **Parameters** `deviceConfiguration`: The device configuration `sendTo`: The DWTObject control to scan into **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.0+ v18.0+ v18.0+ v18.0+
**Example** ```javascript DWTObject.GetDevicesAsync() .then((deviceList) => { return deviceList[0].acquireImage({}, DWTObject); }) .then((result) => { console.log(result); }) .catch((e) => { console.error(e); }); ```
--- title: Dynamic Web TWAIN SDK API Reference - Enumerations description: Dynamic Web TWAIN SDK Documentation API Reference Enumerations Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/api/Dynamsoft_Enum.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/Dynamsoft_Enum.md --- # Enumerations ## Dynamsoft.DWT.EnumDWT_PixelType | Label | Value | | :------------ | :---- | | TWPT_BW | 0 | | TWPT_GRAY | 1 | | TWPT_RGB | 2 | | TWPT_PALLETE | 3 | | TWPT_CMY | 4 | | TWPT_CMYK | 5 | | TWPT_YUV | 6 | | TWPT_YUVK | 7 | | TWPT_CIEXYZ | 8 | | TWPT_LAB | 9 | | TWPT_SRGB | 10 | | TWPT_SCRGB | 11 | | TWPT_INFRARED | 16 | ## Dynamsoft.DWT.EnumDWT_BorderStyle | Label | Value | | :-------------- | :---- | | TWBS_NONE | 0 | | TWBS_SINGLEFLAT | 1 | | TWBS_SINGLE3D | 2 | ## Dynamsoft.DWT.EnumDWT_MessageType | Label | Value | | :-------------- | :---- | | TWQC_GET | 1 | | TWQC_SET | 2 | | TWQC_GETDEFAULT | 4 | | TWQC_GETCURRENT | 8 | | TWQC_RESET | 16 | ## Dynamsoft.DWT.EnumDWT_Cap | Label | Value | | :----------------------------------- | :---- | | CAP_NONE | 0 | | CAP_XFERCOUNT | 1 | | ICAP_COMPRESSION | 256 | | ICAP_PIXELTYPE | 257 | | ICAP_UNITS | 258 | | ICAP_XFERMECH | 259 | | CAP_AUTHOR | 4096 | | CAP_CAPTION | 4097 | | CAP_FEEDERENABLED | 4098 | | CAP_FEEDERLOADED | 4099 | | CAP_TIMEDATE | 4100 | | CAP_SUPPORTEDCAPS | 4101 | | CAP_EXTENDEDCAPS | 4102 | | CAP_AUTOFEED | 4103 | | CAP_CLEARPAGE | 4104 | | CAP_FEEDPAGE | 4105 | | CAP_REWINDPAGE | 4106 | | CAP_INDICATORS | 4107 | | CAP_SUPPORTEDCAPSEXT | 4108 | | CAP_PAPERDETECTABLE | 4109 | | CAP_UICONTROLLABLE | 4110 | | CAP_DEVICEONLINE | 4111 | | CAP_AUTOSCAN | 4112 | | CAP_THUMBNAILSENABLED | 4113 | | CAP_DUPLEX | 4114 | | CAP_DUPLEXENABLED | 4115 | | CAP_ENABLEDSUIONLY | 4116 | | CAP_CUSTOMDSDATA | 4117 | | CAP_ENDORSER | 4118 | | CAP_ALARMS | 4120 | | CAP_ALARMVOLUME | 4121 | | CAP_AUTOMATICCAPTURE | 4122 | | CAP_TIMEBEFOREFIRSTCAPTURE | 4123 | | CAP_TIMEBETWEENCAPTURES | 4124 | | CAP_CLEARBUFFERS | 4125 | | CAP_MAXBATCHBUFFERS | 4126 | | CAP_DEVICETIMEDATE | 4127 | | CAP_POWERSUPPLY | 4128 | | CAP_CAMERAPREVIEWUI | 4129 | | CAP_SERIALNUMBER | 4132 | | CAP_PRINTER | 4134 | | CAP_PRINTERENABLED | 4135 | | CAP_PRINTERINDEX | 4136 | | CAP_PRINTERMODE | 4137 | | CAP_PRINTERSTRING | 4138 | | CAP_PRINTERSUFFIX | 4139 | | CAP_LANGUAGE | 4140 | | CAP_FEEDERALIGNMENT | 4141 | | CAP_FEEDERORDER | 4142 | | CAP_REACQUIREALLOWED | 4144 | | CAP_BATTERYMINUTES | 4146 | | CAP_BATTERYPERCENTAGE | 4147 | | CAP_CAMERASIDE | 4148 | | CAP_SEGMENTED | 4149 | | CAP_CAMERAENABLED | 4150 | | CAP_CAMERAORDER | 4151 | | CAP_MICRENABLED | 4152 | | CAP_FEEDERPREP | 4153 | | CAP_FEEDERPOCKET | 4154 | | CAP_AUTOMATICSENSEMEDIUM | 4155 | | CAP_CUSTOMINTERFACEGUID | 4156 | | ICAP_AUTOBRIGHT | 4352 | | ICAP_BRIGHTNESS | 4353 | | ICAP_CONTRAST | 4355 | | ICAP_CUSTHALFTONE | 4356 | | ICAP_EXPOSURETIME | 4357 | | ICAP_FILTER | 4358 | | ICAP_FLASHUSED | 4359 | | ICAP_GAMMA | 4360 | | ICAP_HALFTONES | 4361 | | ICAP_HIGHLIGHT | 4362 | | ICAP_IMAGEFILEFORMAT | 4364 | | ICAP_LAMPSTATE | 4365 | | ICAP_LIGHTSOURCE | 4366 | | ICAP_ORIENTATION | 4368 | | ICAP_PHYSICALWIDTH | 4369 | | ICAP_PHYSICALHEIGHT | 4370 | | ICAP_SHADOW | 4371 | | ICAP_FRAMES | 4372 | | ICAP_XNATIVERESOLUTION | 4374 | | ICAP_YNATIVERESOLUTION | 4375 | | ICAP_XRESOLUTION | 4376 | | ICAP_YRESOLUTION | 4377 | | ICAP_MAXFRAMES | 4378 | | ICAP_TILES | 4379 | | ICAP_BITORDER | 4380 | | ICAP_CCITTKFACTOR | 4381 | | ICAP_LIGHTPATH | 4382 | | ICAP_PIXELFLAVOR | 4383 | | ICAP_PLANARCHUNKY | 4384 | | ICAP_ROTATION | 4385 | | ICAP_SUPPORTEDSIZES | 4386 | | ICAP_THRESHOLD | 4387 | | ICAP_XSCALING | 4388 | | ICAP_YSCALING | 4389 | | ICAP_BITORDERCODES | 4390 | | ICAP_PIXELFLAVORCODES | 4391 | | ICAP_JPEGPIXELTYPE | 4392 | | ICAP_TIMEFILL | 4394 | | ICAP_BITDEPTH | 4395 | | ICAP_BITDEPTHREDUCTION | 4396 | | ICAP_UNDEFINEDIMAGESIZE | 4397 | | ICAP_EXTIMAGEINFO | 4399 | | ICAP_MINIMUMHEIGHT | 4400 | | ICAP_MINIMUMWIDTH | 4401 | | ICAP_AUTODISCARDBLANKPAGES | 4404 | | ICAP_FLIPROTATION | 4406 | | ICAP_BARCODEDETECTIONENABLED | 4407 | | ICAP_SUPPORTEDBARCODETYPES | 4408 | | ICAP_BARCODEMAXSEARCHPRIORITIES | 4409 | | ICAP_BARCODESEARCHPRIORITIES | 4410 | | ICAP_BARCODESEARCHMODE | 4411 | | ICAP_BARCODEMAXRETRIES | 4412 | | ICAP_BARCODETIMEOUT | 4413 | | ICAP_ZOOMFACTOR | 4414 | | ICAP_PATCHCODEDETECTIONENABLED | 4415 | | ICAP_SUPPORTEDPATCHCODETYPES | 4416 | | ICAP_PATCHCODEMAXSEARCHPRIORITIES | 4417 | | ICAP_PATCHCODESEARCHPRIORITIES | 4418 | | ICAP_PATCHCODESEARCHMODE | 4419 | | ICAP_PATCHCODEMAXRETRIES | 4420 | | ICAP_PATCHCODETIMEOUT | 4421 | | ICAP_FLASHUSED2 | 4422 | | ICAP_IMAGEFILTER | 4423 | | ICAP_NOISEFILTER | 4424 | | ICAP_OVERSCAN | 4425 | | ICAP_AUTOMATICBORDERDETECTION | 4432 | | ICAP_AUTOMATICDESKEW | 4433 | | ICAP_AUTOMATICROTATE | 4434 | | ICAP_JPEGQUALITY | 4435 | | ICAP_FEEDERTYPE | 4436 | | ICAP_ICCPROFILE | 4437 | | ICAP_AUTOSIZE | 4438 | | ICAP_AUTOMATICCROPUSESFRAME | 4439 | | ICAP_AUTOMATICLENGTHDETECTION | 4440 | | ICAP_AUTOMATICCOLORENABLED | 4441 | | ICAP_AUTOMATICCOLORNONCOLORPIXELTYPE | 4442 | | ICAP_COLORMANAGEMENTENABLED | 4443 | | ICAP_IMAGEMERGE | 4444 | | ICAP_IMAGEMERGEHEIGHTTHRESHOLD | 4445 | | ICAP_SUPPORTEDEXTIMAGEINFO | 4446 | ## Dynamsoft.DWT.EnumDWT_CapType | Label | Value | | :--------------- | :---- | | TWON_NONE | 0 | | TWON_ARRAY | 3 | | TWON_ENUMERATION | 4 | | TWON_ONEVALUE | 5 | | TWON_RANGE | 6 | ## Dynamsoft.DWT.EnumDWT_TransferMode | Label | Value | | :---------- | :---- | | TWSX_NATIVE | 0 | | TWSX_FILE | 1 | | TWSX_MEMORY | 2 | ## Dynamsoft.DWT.EnumDWT_FileFormat | Label | Value | Description | | :------------- | :---- | :---------------------------------------------------------------------------------------- | | TWFF_TIFF | 0 | Tagged Image File Format. Used for document imaging. Native Linux format | | TWFF_PICT | 1 | Native Macintosh format | | TWFF_BMP | 2 | Native Microsoft format | | TWFF_XBM | 3 | X-Windows Bitmap used for document imaging | | TWFF_JFIF | 4 | JPEG File Interchange Format. Wrapper for JPEG images | | TWFF_FPX | 5 | FlashPix, used with digital cameras | | TWFF_TIFFMULTI | 6 | Multi-page TIFF files | | TWFF_PNG | 7 | An image format standard intended for use on the web, replaces GIF | | TWFF_SPIFF | 8 | A standard from JPEG, intended to replace JFIF, also supports JBIG | | TWFF_EXIF | 9 | File format for use with digital cameras | | TWFF_PDF | 10 | A file format from Adobe (TWAIN Spec 1.91) | | TWFF_JP2 | 11 | A file format from the Joint Photographic Experts Group ISO/IEC 15444-1 (TWAIN Spec 1.91) | | TWFF_JPX | 13 | A file format from the Joint Photographic Experts Group ISO/IEC 15444-2 (TWAIN Spec 1.91) | | TWFF_DEJAVU | 14 | A file format from LizardTech (TWAIN Spec 1.91) | | TWFF_PDFA | 15 | A file format from Adobe PDF/A, Version 1 (TWAIN Spec 2.0) | | TWFF_PDFA2 | 16 | A file format from Adobe PDF/A, Version 2 (TWAIN Spec 2.1) | ## Dynamsoft.DWT.EnumDWT_TIFFCompressionType | Label | Value | | :------------ | :---- | | TIFF_AUTO | 0 | | TIFF_NONE | 1 | | TIFF_RLE | 2 | | TIFF_FAX3 | 3 | | TIFF_T4 | 3 | | TIFF_FAX4 | 4 | | TIFF_T6 | 4 | | TIFF_LZW | 5 | | TIFF_JPEG | 7 | | TIFF_PACKBITS | 32773 | ## Dynamsoft.DWT.EnumDWT_InterpolationMethod | Label | Value | | :------------------ | :---- | | IM_NEARESTNEIGHBOUR | 1 | | IM_BILINEAR | 2 | | IM_BICUBIC | 3 | | IM_BESTQUALITY | 5 | ## Dynamsoft.DWT.EnumDWT_ImageType | Label | Value | | :--------------- | :---- | | IT_BMP | 0 | | IT_JPG | 1 | | IT_TIF | 2 | | IT_PNG | 3 | | IT_PDF | 4 | | IT_ALL | 5 | | IT_MULTIPAGE_PDF | 7 | | IT_MULTIPAGE_TIF | 8 | Note: - IT_MULTIPAGE_PDF & IT_MULTIPAGE_TIF are only applicable to the ImageType of [`startScan()`](/_articles/info/api/WebTwain_Acquire.md#startscan). - IT_ALL is only applicable to the ImageType of [`LoadImageEx()`](/_articles/info/api/WebTwain_IO.md#loadimageex){% comment %}, [`LoadImageFromBase64Binary()`](/_articles/info/api/WebTwain_IO.md#loadimagefrombase64binary), [`HTTPDownloadEx()`](/_articles/info/api/WebTwain_IO.md#httpdownloadex), [`HTTPDownloadThroughPost()`](/_articles/info/api/WebTwain_IO.md#httpdownloadthroughpost){% endcomment %}. ## Dynamsoft.DWT.EnumDWT_ImageFormatType | Label | Value | | :----- | :---- | | URL | 0 | | Blob | 1 | | Base64 | 2 | ## Dynamsoft.DWT.EnumPDF_Page | Label | Value | | :------------------ | :---- | | Page_Default | 0 | | Page_Custom | 1 | | Page_A4 | 2 | | Page_A4_Reverse | 3 | | Page_A3 | 4 | | Page_A3_Reverse | 5 | | Page_Letter | 6 | | Page_Letter_Reverse | 7 | | Page_Legal | 8 | | Page_Legal_Reverse | 9 | ## Dynamsoft.DWT.EnumDWT_PDFCompressionType | Label | Value | | :--------- | :---- | | PDF_AUTO | 0 | | PDF_FAX4 | 2 | | PDF_LZW | 3 | | PDF_JPEG | 5 | | PDF_JP2000 | 6 | | PDF_JBIG2 | 7 | ## Dynamsoft.DWT.EnumDWT_ShowMode | Label | Value | | :-------- | :---- | | SW_ACTIVE | 0 | | SW_MAX | 1 | | SW_MIN | 2 | | SW_CLOSE | 3 | | SW_IFLIVE | 4 | ## Dynamsoft.DWT.EnumDWT_CapValueType | Label | Value | | :---------- | :---- | | TWTY_INT8 | 0 | | TWTY_INT16 | 1 | | TWTY_INT32 | 2 | | TWTY_UINT8 | 3 | | TWTY_UINT16 | 4 | | TWTY_int | 5 | | TWTY_BOOL | 6 | | TWTY_FIX32 | 7 | | TWTY_FRAME | 8 | | TWTY_STR32 | 9 | | TWTY_STR64 | 10 | | TWTY_STR128 | 11 | | TWTY_STR255 | 12 | ## Dynamsoft.DWT.EnumDWT_UnitType | Label | Value | | :--------------- | :---- | | TWUN_INCHES | 0 | | TWUN_CENTIMETERS | 1 | | TWUN_PICAS | 2 | | TWUN_POINTS | 3 | | TWUN_TWIPS | 4 | | TWUN_PIXELS | 5 | | TWUN_MILLIMETERS | 6 | ## Dynamsoft.DWT.EnumDWT_ConvertMode | Label | Value | | :----------- | :---- | | CM_RENDERALL | 1 | | CM_IMAGEONLY | 2 | | CM_AUTO | 3 | Note: The below enumeration value has been deprecated as of 18.4. | Label | Value | | :------------------------- | :---- | | CM_RENDERALLWITHANNOTATION | 4 | ## Dynamsoft.DWT.EnumDWT_DUPLEX | Label | Value | | :--------------- | :---- | | TWDX_NONE | 0 | | TWDX_1PASSDUPLEX | 1 | | TWDX_2PASSDUPLEX | 2 | ## Dynamsoft.DWT.EnumDWT_CapLanguage | Label | Value | | :------------------------ | :---- | | TWLG_DAN | 0 | | TWLG_DUT | 1 | | TWLG_ENG | 2 | | TWLG_FCF | 3 | | TWLG_FIN | 4 | | TWLG_FRN | 5 | | TWLG_GER | 6 | | TWLG_ICE | 7 | | TWLG_ITN | 8 | | TWLG_NOR | 9 | | TWLG_POR | 10 | | TWLG_SPA | 11 | | TWLG_SWE | 12 | | TWLG_USA | 13 | | TWLG_USERLOCALE | -1 | | TWLG_AFRIKAANS | 14 | | TWLG_ALBANIA | 15 | | TWLG_ARABIC | 16 | | TWLG_ARABIC_ALGERIA | 17 | | TWLG_ARABIC_BAHRAIN | 18 | | TWLG_ARABIC_EGYPT | 19 | | TWLG_ARABIC_IRAQ | 20 | | TWLG_ARABIC_JORDAN | 21 | | TWLG_ARABIC_KUWAIT | 22 | | TWLG_ARABIC_LEBANON | 23 | | TWLG_ARABIC_LIBYA | 24 | | TWLG_ARABIC_MOROCCO | 25 | | TWLG_ARABIC_OMAN | 26 | | TWLG_ARABIC_QATAR | 27 | | TWLG_ARABIC_SAUDIARABIA | 28 | | TWLG_ARABIC_SYRIA | 29 | | TWLG_ARABIC_TUNISIA | 30 | | TWLG_ARABIC_UAE | 31 | | TWLG_ARABIC_YEMEN | 32 | | TWLG_BASQUE | 33 | | TWLG_BYELORUSSIAN | 34 | | TWLG_BULGARIAN | 35 | | TWLG_CATALAN | 36 | | TWLG_CHINESE | 37 | | TWLG_CHINESE_HONGKONG | 38 | | TWLG_CHINESE_PRC | 39 | | TWLG_CHINESE_SINGAPORE | 40 | | TWLG_CHINESE_SIMPLIFIED | 41 | | TWLG_CHINESE_TAIWAN | 42 | | TWLG_CHINESE_TRADITIONAL | 43 | | TWLG_CROATIA | 44 | | TWLG_CZECH | 45 | | TWLG_DANISH | 0 | | TWLG_DUTCH | 1 | | TWLG_DUTCH_BELGIAN | 46 | | TWLG_ENGLISH | 2 | | TWLG_ENGLISH_AUSTRALIAN | 47 | | TWLG_ENGLISH_CANADIAN | 48 | | TWLG_ENGLISH_IRELAND | 49 | | TWLG_ENGLISH_NEWZEALAND | 50 | | TWLG_ENGLISH_SOUTHAFRICA | 51 | | TWLG_ENGLISH_UK | 52 | | TWLG_ENGLISH_USA | 13 | | TWLG_ESTONIAN | 53 | | TWLG_FAEROESE | 54 | | TWLG_FARSI | 55 | | TWLG_FINNISH | 4 | | TWLG_FRENCH | 5 | | TWLG_FRENCH_BELGIAN | 56 | | TWLG_FRENCH_CANADIAN | 3 | | TWLG_FRENCH_LUXEMBOURG | 57 | | TWLG_FRENCH_SWISS | 58 | | TWLG_GERMAN | 6 | | TWLG_GERMAN_AUSTRIAN | 59 | | TWLG_GERMAN_LUXEMBOURG | 60 | | TWLG_GERMAN_LIECHTENSTEIN | 61 | | TWLG_GERMAN_SWISS | 62 | | TWLG_GREEK | 63 | | TWLG_HEBREW | 64 | | TWLG_HUNGARIAN | 65 | | TWLG_ICELANDIC | 7 | | TWLG_INDONESIAN | 66 | | TWLG_ITALIAN | 8 | | TWLG_ITALIAN_SWISS | 67 | | TWLG_JAPANESE | 68 | | TWLG_KOREAN | 69 | | TWLG_KOREAN_JOHAB | 70 | | TWLG_LATVIAN | 71 | | TWLG_LITHUANIAN | 72 | | TWLG_NORWEGIAN | 9 | | TWLG_NORWEGIAN_BOKMAL | 73 | | TWLG_NORWEGIAN_NYNORSK | 74 | | TWLG_POLISH | 75 | | TWLG_PORTUGUESE | 10 | | TWLG_PORTUGUESE_BRAZIL | 76 | | TWLG_ROMANIAN | 77 | | TWLG_RUSSIAN | 78 | | TWLG_SERBIAN_LATIN | 79 | | TWLG_SLOVAK | 80 | | TWLG_SLOVENIAN | 81 | | TWLG_SPANISH | 11 | | TWLG_SPANISH_MEXICAN | 82 | | TWLG_SPANISH_MODERN | 83 | | TWLG_SWEDISH | 12 | | TWLG_THAI | 84 | | TWLG_TURKISH | 85 | | TWLG_UKRANIAN | 86 | | TWLG_ASSAMESE | 87 | | TWLG_BENGALI | 88 | | TWLG_BIHARI | 89 | | TWLG_BODO | 90 | | TWLG_DOGRI | 91 | | TWLG_GUJARATI | 92 | | TWLG_HARYANVI | 93 | | TWLG_HINDI | 94 | | TWLG_KANNADA | 95 | | TWLG_KASHMIRI | 96 | | TWLG_MALAYALAM | 97 | | TWLG_MARATHI | 98 | | TWLG_MARWARI | 99 | | TWLG_MEGHALAYAN | 100 | | TWLG_MIZO | 101 | | TWLG_NAGA | 102 | | TWLG_ORISSI | 103 | | TWLG_PUNJABI | 104 | | TWLG_PUSHTU | 105 | | TWLG_SERBIAN_CYRILLIC | 106 | | TWLG_SIKKIMI | 107 | | TWLG_SWEDISH_FINLAND | 108 | | TWLG_TAMIL | 109 | | TWLG_TELUGU | 110 | | TWLG_TRIPURI | 111 | | TWLG_URDU | 112 | | TWLG_VIETNAMESE | 113 | ## Dynamsoft.DWT.EnumDWT_CapSupportedSizes | Label | Value | | :---------------- | :---- | | TWSS_NONE | 0 | | TWSS_A4LETTER | 1 | | TWSS_B5LETTER | 2 | | TWSS_USLETTER | 3 | | TWSS_USLEGAL | 4 | | TWSS_A5 | 5 | | TWSS_B4 | 6 | | TWSS_B6 | 7 | | TWSS_USLEDGER | 9 | | TWSS_USEXECUTIVE | 10 | | TWSS_A3 | 11 | | TWSS_B3 | 12 | | TWSS_A6 | 13 | | TWSS_C4 | 14 | | TWSS_C5 | 15 | | TWSS_C6 | 16 | | TWSS_4A0 | 17 | | TWSS_2A0 | 18 | | TWSS_A0 | 19 | | TWSS_A1 | 20 | | TWSS_A2 | 21 | | TWSS_A4 | 1 | | TWSS_A7 | 22 | | TWSS_A8 | 23 | | TWSS_A9 | 24 | | TWSS_A10 | 25 | | TWSS_ISOB0 | 26 | | TWSS_ISOB1 | 27 | | TWSS_ISOB2 | 28 | | TWSS_ISOB3 | 12 | | TWSS_ISOB4 | 6 | | TWSS_ISOB5 | 29 | | TWSS_ISOB6 | 7 | | TWSS_ISOB7 | 30 | | TWSS_ISOB8 | 31 | | TWSS_ISOB9 | 32 | | TWSS_ISOB10 | 33 | | TWSS_JISB0 | 34 | | TWSS_JISB1 | 35 | | TWSS_JISB2 | 36 | | TWSS_JISB3 | 37 | | TWSS_JISB4 | 38 | | TWSS_JISB5 | 2 | | TWSS_JISB6 | 39 | | TWSS_JISB7 | 40 | | TWSS_JISB8 | 41 | | TWSS_JISB9 | 42 | | TWSS_JISB10 | 43 | | TWSS_C0 | 44 | | TWSS_C1 | 45 | | TWSS_C2 | 46 | | TWSS_C3 | 47 | | TWSS_C7 | 48 | | TWSS_C8 | 49 | | TWSS_C9 | 50 | | TWSS_C10 | 51 | | TWSS_USSTATEMENT | 52 | | TWSS_BUSINESSCARD | 53 | | TWSS_MAXSIZE | 54 | ## Dynamsoft.DWT.EnumDWT_CapFeederAlignment | Label | Value | | :---------- | :---- | | TWFA_NONE | 0 | | TWFA_LEFT | 1 | | TWFA_CENTER | 2 | | TWFA_RIGHT | 3 | ## Dynamsoft.DWT.EnumDWT_CapFeederOrder | Label | Value | | :------------------ | :---- | | TWFO_FIRSTPAGEFIRST | 0 | | TWFO_LASTPAGEFIRST | 1 | ## Dynamsoft.DWT.EnumDWT_CapPrinter | Label | Value | | :------------------------- | :---- | | TWPR_IMPRINTERTOPBEFORE | 0 | | TWPR_IMPRINTERTOPAFTER | 1 | | TWPR_IMPRINTERBOTTOMBEFORE | 2 | | TWPR_IMPRINTERBOTTOMAFTER | 3 | | TWPR_ENDORSERTOPBEFORE | 4 | | TWPR_ENDORSERTOPAFTER | 5 | | TWPR_ENDORSERBOTTOMBEFORE | 6 | | TWPR_ENDORSERBOTTOMAFTER | 7 | ## Dynamsoft.DWT.EnumDWT_CapPrinterMode | Label | Value | | :------------------ | :---- | | TWPM_SINGLESTRING | 0 | | TWPM_MULTISTRING | 1 | | TWPM_COMPOUNDSTRING | 2 | ## Dynamsoft.DWT.EnumDWT_CapBitdepthReduction | Label | Value | | :---------------- | :---- | | TWBR_THRESHOLD | 0 | | TWBR_HALFTONE | 1 | | TWBR_CUSTHALFTONE | 2 | | TWBR_DIFFUSION | 3 | ## Dynamsoft.DWT.EnumDWT_CapBitOrder | Label | Value | | :------------ | :---- | | TWBO_LSBFIRST | 0 | | TWBO_MSBFIRST | 1 | ## Dynamsoft.DWT.EnumDWT_CapFilterType | Label | Value | | :----------- | :---- | | TWFT_RED | 0 | | TWFT_GREEN | 1 | | TWFT_BLUE | 2 | | TWFT_NONE | 3 | | TWFT_WHITE | 4 | | TWFT_CYAN | 5 | | TWFT_MAGENTA | 6 | | TWFT_YELLOW | 7 | | TWFT_BLACK | 8 | ## Dynamsoft.DWT.EnumDWT_CapFlash | Label | Value | | :---------- | :---- | | TWFL_NONE | 0 | | TWFL_OFF | 1 | | TWFL_ON | 2 | | TWFL_AUTO | 3 | | TWFL_REDEYE | 4 | ## Dynamsoft.DWT.EnumDWT_CapFlipRotation | Label | Value | | :----------- | :---- | | TWFR_BOOK | 0 | | TWFR_FANFOLD | 1 | ## Dynamsoft.DWT.EnumDWT_CapImageFilter | Label | Value | | :------------ | :---- | | TWIF_NONE | 0 | | TWIF_AUTO | 1 | | TWIF_LOWPASS | 2 | | TWIF_BANDPASS | 3 | | TWIF_HIGHPASS | 4 | | TWIF_TEXT | 3 | | TWIF_FINELINE | 4 | ## Dynamsoft.DWT.EnumDWT_CapLightPath | Label | Value | | :---------------- | :---- | | TWLP_REFLECTIVE | 0 | | TWLP_TRANSMISSIVE | 1 | ## Dynamsoft.DWT.EnumDWT_CapLightSource | Label | Value | | :--------- | :---- | | TWLS_RED | 0 | | TWLS_GREEN | 1 | | TWLS_BLUE | 2 | | TWLS_NONE | 3 | | TWLS_WHITE | 4 | | TWLS_UV | 5 | | TWLS_IR | 6 | ## Dynamsoft.DWT.EnumDWT_MagType | Label | Value | | :----------- | :---- | | TWMD_MICR | 0 | | TWMD_RAW | 1 | | TWMD_INVALID | 2 | ## Dynamsoft.DWT.EnumDWT_CapNoiseFilter | Label | Value | | :---------------- | :---- | | TWNF_NONE | 0 | | TWNF_AUTO | 1 | | TWNF_LONEPIXEL | 2 | | TWNF_MAJORITYRULE | 3 | ## Dynamsoft.DWT.EnumDWT_CapORientation | Label | Value | | :--------------- | :---- | | TWOR_ROT0 | 0 | | TWOR_ROT90 | 1 | | TWOR_ROT180 | 2 | | TWOR_ROT270 | 3 | | TWOR_PORTRAIT | 0 | | TWOR_LANDSCAPE | 3 | | TWOR_AUTO | 4 | | TWOR_AUTOTEXT | 5 | | TWOR_AUTOPICTURE | 6 | ## Dynamsoft.DWT.EnumDWT_CapOverscan | Label | Value | | :------------- | :---- | | TWOV_NONE | 0 | | TWOV_AUTO | 1 | | TWOV_TOPBOTTOM | 2 | | TWOV_LEFTRIGHT | 3 | | TWOV_ALL | 4 | ## Dynamsoft.DWT.EnumDWT_CapPixelFlavor | Label | Value | | :------------- | :---- | | TWPF_CHOCOLATE | 0 | | TWPF_VANILLA | 1 | ## Dynamsoft.DWT.EnumDWT_CapPlanarChunky | Label | Value | | :---------- | :---- | | TWPC_CHUNKY | 0 | | TWPC_PLANAR | 1 | ## Dynamsoft.DWT.EnumDWT_DataSourceStatus | Label | Value | | :-------------- | :---- | | TWDSS_CLOSED | 0 | | TWDSS_OPENED | 1 | | TWDSS_ENABLED | 2 | | TWDSS_ACQUIRING | 3 | ## Dynamsoft.DWT.EnumDWT_FitWindowType | Label | Value | | :------------------ | :---- | | enumFitWindow | 0 | | enumFitWindowHeight | 1 | | enumFitWindowWidth | 2 | ## Dynamsoft.DWT.EnumDWT_PlatformType | Label | Value | | :--------- | :---- | | enumWindow | 0 | | enumMac | 1 | | enumLinux | 2 | ## Dynamsoft.DWT.EnumDWT_UploadDataFormat | Label | Value | | :----- | :---- | | Binary | 0 | | Base64 | 1 | ## Dynamsoft.DWT.EnumDWT_MouseShape | Label | Value | | :-------- | :---- | | Default | 0 | | Hand | 1 | | Crosshair | 2 | | Zoom | 3 | | NWResize | 4 | | EResize | 5 | | NResize | 6 | | Resize | 7 | | Move | 8 | {% comment %} ## Dynamsoft.DWT.EnumDWT_InitMsg | Label | Value | | :---------------------- | :---- | | Info | 1 | | Error | 2 | | NotInstalledError | 3 | | DownloadError | 4 | | DownloadNotRestartError | 5 | {% endcomment %} ## Dynamsoft.DWT.EnumDWT_Driver | Label | Value | | :---------------- | :---- | | TWAIN | 0 | | ICA | 3 | | SANE | 3 | | TWAIN_AND_ICA | 4 | | TWAIN_AND_TWAIN64 | 4 | | TWAIN64 | 5 | ## Dynamsoft.DWT.EnumDWT_CameraControlProperty | Label | Value | Description | | :----------- | :---- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | CCP_PAN | 0 | Specify the pan in degrees. Values range from –180 to +180. By default, it's 0. Positive values are clockwise from the origin (the camera rotates clockwise when viewed from above), and negative values are counterclockwise from the origin. | | CCP_TILT | 1 | Specify the tilt in degrees. Values range from –180 to +180. By default, it's 0. Positive values point the imaging plane up, and negative values point the imaging plane down. | | CCP_ROLL | 2 | Specify the roll in degrees. Values range from –180 to +180. By default, it's 0. Positive values cause a clockwise rotation of the camera along the image-viewing axis, and negative values cause a counterclockwise rotation of the camera. | | CCP_ZOOM | 3 | Specify the zoom in millimeters. Values range from 10 to 600, and the default is specific to the device. | | CCP_EXPOSURE | 4 | Specify the exposure in log base 2 seconds. In other words, for values less than zero, the exposure time is 1/2^n seconds, and for values zero or above, the exposure time is 2^n seconds. For example: -3 means 1/8 second, -2 means 1/4 second, 0 means 1 second, 2 means 4 seconds, etc. | | CCP_IRIS | 5 | Specify the iris in units of fstop\* 10. | | CCP_FOCUS | 6 | Specify the focus in millimeters which is the distance to the optimally focused target. The range and default value are specific to the device. | ## Dynamsoft.DWT.EnumDWT_VideoProperty | Label | Value | Description | | :----------------------- | :---- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | VP_BRIGHTNESS | 0 | Specify the brightness. For NTSC, the value is expressed in IRE units \* 100. For non-NTSC sources, the units are arbitrary, with zero representing blanking and 10, 000 representing pure white. Values range from –10, 000 to 10, 000. | | VP_CONTRAST | 1 | Specify the contrast which is expressed as the gain factor \* 100. Values range from zero to 10, 000. | | VP_HUE | 2 | Specify the hue which is expressed in degrees \* 100. Values range from -180, 000 to 180, 000 (-180 to +180 degrees). | | VP_SATURATION | 3 | Specify the saturation. Values range from 0 to 10, 000. | | VP_SHARPNESS | 4 | Specify the sharpness. Values range from 0 to 100. | | VP_GAMMA | 5 | Specify the gamma which is expressed as gamma \* 100. Values range from 1 to 500. | | VP_COLORENABLE | 6 | Specify the color-enable setting. It's either 0 (off) or 1 (on). | | VP_WHITEBALANCE | 7 | Specify the white balance, as a color temperature in degrees Kelvin. The range of values depends on the device. | | VP_BACKLIGHTCOMPENSATION | 8 | Specify the backlight compensation setting. It's either 0 (off) or 1 (on). | | VP_GAIN | 9 | Specify the gain adjustment. Zero is normal. Positive values are brighter and negative values are darker. The range of values depends on the device. | ## Dynamsoft.DWT.EnumDWT_VideoRotateMode | Label | Value | Description | | :------------------------ | :---- | :-------------------- | | VRM_NONE | 0 | No rotation | | VRM_90_DEGREES_CLOCKWISE | 1 | 90 degrees Clockwise | | VRM_180_DEGREES_CLOCKWISE | 2 | 180 degrees Clockwise | | VRM_270_DEGREES_CLOCKWISE | 3 | 270 degrees Clockwise | | VRM_FLIP_VERTICAL | 4 | Flip | | VRM_FLIP_HORIZONTAL | 5 | Mirror | ## Dynamsoft.DWT.EnumDWT_SelectionMode | Label | Value | | :------- | :---- | | Single | 0 | | Multiple | 1 | ## Dynamsoft.DWT.EnumDWT_ConfirmExitType | Label | Value | | :---------- | :---- | | Cancel | 0 | | Exit | 1 | | SaveAndExit | 2 | ## Dynamsoft.DWT.EnumDWT_DeviceType | Label | Value | Description | | :---------------- | :---- | :--------------------------------------------------------------------------------------------------------------- | | TWAINSCANNER | 0x10 | | | WIASCANNER | 0x20 | | | TWAINX64SCANNER | 0x40 | | | ICASCANNER | 0x80 | | | SANESCANNER | 0x100 | | | ESCLSCANNER | 0x200 | | | WIFIDIRECTSCANNER | 0x400 | | | WIATWAINSCANNER | 0x800 | Deprecated since version 18.2 and will be removed in future versions, please use the value `WIASCANNER` instead. | ## Dynamsoft.DWT.EnumDWT_ExtImageInfo | Label | Value | | :-------- | :---- | | default | 0 | | standard | 1 | | supported | 2 | ## Dynamsoft.DWT.EnumDWT_WorkMode | Label | Value | Description | | :------ | :---- | :------------------------------------------------------- | | normal | 0 | Original mode, the image data is processed in the buffer | | balance | 1 | The image data is processed in the browser canvas | ## Dynamsoft.DWT.EnumDWT_CompressionType | Label | Value | | :--------------- | :---- | | TWCP_NONE | 0 | | TWCP_PACKBITS | 1 | | TWCP_GROUP31D | 2 | | TWCP_GROUP31DEOL | 3 | | TWCP_GROUP32D | 4 | | TWCP_GROUP4 | 5 | | TWCP_JPEG | 6 | | TWCP_LZW | 7 | | TWCP_JBIG | 8 | | TWCP_PNG | 9 | | TWCP_RLE4 | 10 | | TWCP_RLE8 | 11 | | TWCP_BITFIELDS | 12 | | TWCP_ZIP | 13 | | TWCP_JPEG2000 | 14 | ## Dynamsoft.DWT.EnumDWT_ResponseType | Label | Value | | :---------- | :---- | | Text | 0 | | Blob | 1 | | ArrayBuffer | 2 | | XML | 3 | | JSON | 4 | ## Dynamsoft.DWT.EnumDWT_OCRKitOutputFormat | Label | Value | | :------------------------- | :---- | | TEXT | 0 | | PDF_PLAIN_TEXT | 1 | | PDF_WITH_EXTRA_TEXTLAYER | 2 | Note: `PDF_PLAIN_TEXT` will only keep a text layer of the OCRed text for each page. `PDF_WITH_EXTRA_TEXTLAYER` will add an extra invisible text layer of the OCRed text above each page. ## Dynamsoft.DWT.EnumDWT_PageOrientation | Label | Value | | :------------------------- | :---- | | AUTO | -1 | | ANGLE_0 | 0 | | ANGLE_90 | 90 | | ANGLE_180 | 180 | | ANGLE_270 | 270 | ## Dynamsoft.DWT.EnumDWT_PageOrientationDetectionMode | Label | Value | | :------------------------- | :---- | | FAST | 0 | | BALANCE | 1 | | PRECISION | 2 | --- title: Dynamic Web TWAIN SDK API Reference - Uploader APIs description: Dynamic Web TWAIN SDK Documentation API Reference Uploader APIs Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/api/Dynamsoft_FileUploader.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/Dynamsoft_FileUploader.md --- # FileUploader Module The File Uploader is an independent component that is dedicated to file uploading. ## Dynamsoft.FileUploader ### Init() Initialize and create a FileUploader instance. **Syntax** ```typescript Init( URL: string, successCallback: (uploadManager: UploadManager) => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `URL`: Specify a path to retrieve the FileUploader library. `successCallback`: A callback function that is executed if the request succeeds. - `uploadManager`: A FileUploader instance. Please refer to [`UploadManager`](#uploadmanager). `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.0+ v14.0+ v14.0+ v14.0+
**Example** ```javascript var dsUploadManager; Dynamsoft.FileUploader.Init( "", function (obj) { dsUploadManager = obj; }, function () {}, ); ``` **Usage notes** The FileUploader library is installed with Dynamic Web TWAIN Service by default, therefore, `URL` can be left empty "". ## UploadManager **Methods** | [`CreateJob()`](#createjob) | [`Run()`](#run) | [`Cancel()`](#cancel) | [`CancelAllUpload()`](#cancelallupload) | ### CreateJob() Create an upload job. **Syntax** ```typescript CreateJob(): Job; ``` Please refer to [`Job`](#job). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.0+ v14.0+ v14.0+ v14.0+
### Run() Start uploading (processing the specified job). **Syntax** ```typescript Run(job: Job): boolean; ``` **Parameters** `job`: Specify the job. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.0+ v14.0+ v14.0+ v14.0+
### Cancel() Cancel a job. **Syntax** ```typescript Cancel(job: Job): boolean; ``` **Parameters** `job`: Specify the job. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.0+ v14.0+ v14.0+ v14.0+
### CancelAllupload() Cancel all jobs. **Syntax** ```typescript CancelAllUpload(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.0+ v14.0+ v14.0+ v14.0+
**Usage notes** [`Cancel()`](#cancel) or [`CancelAllUpload()`](#cancelallupload) should be called in the event [`OnUploadTransferPercentage`](#onuploadtransferpercentage). **Example** ```javascript var dsUploadManager; Dynamsoft.FileUploader.Init( "", function (obj) { dsUploadManager = obj; var job = dsUploadManager.CreateJob(); job.OnUploadTransferPercentage = FileUpload_OnUploadTransferPercentage; dsUploadManager.Run(job); function FileUpload_OnUploadTransferPercentage(job, iPercentage) { console.log("job cancelled!"); dsUploadManager.Cancel(job); } }, function () {}, ); ``` ## Job **Properties** | [`BlockSize`](#blocksize) | [`FileName`](#filename) | [`FormField`](#formfield) | | [`HttpHeader`](#httpheader) | [`HttpVersion`](#httpversion) | [`ServerUrl`](#serverurl) | | [`SourceValue`](#sourcevalue) | [`ThreadNum`](#threadnum) | [`Version`](#version) | **Events** | | | :---------------------------------------------------------- | :------------------------------ | ------------------------------- | | [`OnUploadTransferPercentage`](#onuploadtransferpercentage) | [`OnRunSuccess`](#onrunsuccess) | [`OnRunFailure`](#onrunfailure) | ### BlockSize Specify the block size (in bytes). By default, it's 10240. **Syntax** ```typescript BlockSize: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.0+ v14.0+ v14.0+ v14.0+
### FileName Specify the file name. **Syntax** ```typescript FileName: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.0+ v14.0+ v14.0+ v14.0+
### FormField Specifies extra fields to be uploaded in the same HTTP post. **Syntax** ```typescript FormField: FormField; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.0+ v14.0+ v14.0+ v14.0+
**Usage notes** Use the `Add()` method of the Object to add fields for uploading. Please refer to [`FormField`](/_articles/info/api/interfaces.md#formfield). **Example** ```javascript job.FormField.Add("customField", "FormFieldValue"); ``` ### HttpHeader Specifies headers in the the HTTP Post Request of the upload job. For example: `job.HttpHeader["Content-Type"] = "text/plain";` **Syntax** ```typescript HttpHeader: object; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.0+ v14.0+ v14.0+ v14.0+
**Usage notes** By default, HttpHeader is an empty object. If left as it is, default headers are used. Otherwise, the headers set by this property will be added to the HTTP Post Request or replace existing ones with the same names. ### HttpVersion Return the Http version. **Syntax** ```typescript readonly HttpVersion: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.0+ v14.0+ v14.0+ v14.0+
### ServerUrl Specifies the target of the HTTP Post Request of the upload job. This typically is a file on the server. For example: `job.ServerUrl = 'http://www.dynamsoft.com/ScanAndUpload/Actions/SaveToFile.aspx';` **Syntax** ```typescript ServerUrl: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.0+ v14.0+ v14.0+ v14.0+
### SourceValue Specifies the files to be uploaded and the name for it. The files are specified by URLs which can be created with the method [`GenerateURLForUploadData()`](/_articles/info/api/WebTwain_Util.md#generateurlforuploaddata). **Syntax** ```typescript SourceValue: SourceValue; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.0+ v14.0+ v14.0+ v14.0+
**Usage notes** Use the `Add()` method of the Object to add data for uploading. Please refer to [`SourceValue`](/_articles/info/api/interfaces.md#sourcevalue). **Example** ```javascript job.SourceValue.Add(url, fileName); ``` ### ThreadNum Specify the number of threads (<=4) for the upload. **Syntax** ```typescript ThreadNum: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.0+ v14.0+ v14.0+ v14.0+
### Version Return the version of the job. **Syntax** ```typescript readonly Version: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.0+ v14.0+ v14.0+ v14.0+
### OnUploadTransferPercentage The event is triggered during the execution of an upload job. It has a parameter which specifies the percentage of the completion of the job. **Syntax** ```typescript OnUploadTransferPercentage: ( job: Job, percentage: number ) => void; ``` **Parameters** `job`: A job object. `sPercentage`: The percentage of the completion of the job. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.0+ v14.0+ v14.0+ v14.0+
**Example** ```javascript job.OnUploadTransferPercentage = FileUpload_OnUploadTransferPercentage; function FileUpload_ OnUploadTransferPercentage (job, sPercentage){ console.log(sPercentage); } ``` ### OnRunSuccess The event is triggered when an upload job completes successfully. **Syntax** ```typescript OnRunSuccess: (job: Job) => void; ``` **Parameters** `job`: A job object. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.0+ v14.0+ v14.0+ v14.0+
**Example** ```javascript job.OnRunSuccess = FileUpload_OnRunSuccess; function FileUpload_OnRunSuccess(job) { alert(" upload completed "); } ``` ### OnRunFailure The event is triggered when an upload job completes successfully. **Syntax** ```typescript OnRunFailure: ( job: Job, errorCode: number, errorString: string ) => void; ``` **Parameters** `job`: A job object. `errorCode`: The error code. `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.0+ v14.0+ v14.0+ v14.0+
**Example** ```javascript job.OnRunFailure = FileUpload_OnRunFailure; function FileUpload_OnRunFailure(job, errorCode, errorString) { alert(errorString); } ```
--- title: Dynamic Web TWAIN SDK API Reference - Global APIs description: Dynamic Web TWAIN SDK Documentation API Reference Global APIs Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/api/Dynamsoft_WebTwainEnv.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/Dynamsoft_WebTwainEnv.md --- # Global > The Global Web TWAIN properties and methods on this page live in the namespace `{Dynamsoft.DWT}`, **Methods** | [`CreateDWTObject()`](#createdwtobject) | [`CreateDWTobjectEx()`](#createdwtobjectex) | [`DeleteDWTObject()`](#deletedwtobject) | [`GetWebTwain()`](#getwebtwain) | | [`Load()`](#load) | [`RegisterEvent()`](#registerevent) | [`Unload()`](#unload) | | **Properties** | [`AutoLoad`](#autoload) | [`Containers`](#containers) | [`CustomizableDisplayInfo`](#customizabledisplayinfo) | [`DeviceFriendlyName`](#devicefriendlyname) | | [`EnableLocalNetworkMixedContent`](#enablelocalnetworkmixedcontent) | [`Host`](#host) | [`IfAddMD5InUploadHeader`](#ifaddmd5inuploadheader) | [`IfConfineMaskWithinTheViewer`](#ifconfinemaskwithintheviewer) | | [`JSVersion`](#jsversion) | [`ProductKey`](#productkey) | [`ResourcesPath`](#resourcespath) | [`ServiceInstallerLocation`](#serviceinstallerlocation) | | [`UseDefaultViewer`](#usedefaultviewer) | [`IfCheckCORS`](#ifcheckcors) | [`IfAlwaysFocusOnPopupWindow`](#ifalwaysfocusonpopupwindow) | | **Events** | [`OnWebTwainReady`](#onwebtwainready) | [`OnWebTwainError`](#onwebtwainerror) | [`OnWebTwainPostExecute`](#onwebtwainpostexecute) | [`OnWebTwainPreExecute`](#onwebtwainpreexecute) | ## CreateDWTObject() Creates a new `WebTwain` instance that listens to the specified host and ports. This instance requires a UI element specified by the `ContainerId` attribute, typically a `
`. The DWT library will generate UI and bind it to this element. > [!CAUTION] > Disable auto-loading a `WebTwain` instance when creating a `WebTwain` instance with `CreateDWTObject` by setting `Dynamsoft.DWT.AutoLoad = false` and `Dynamsoft.DWT.Containers = []` in the `dynamsoft.webtwain.config.js` file. **Syntax** ```typescript CreateDWTObject( ContainerId: string, successCallBack: (DWTObject: WebTwain) => void, failureCallBack: ({code: number, message: string}) => void ): void; CreateDWTObject( ContainerId: string, host: string, port: string | number, portSSL: string | number, successCallBack: (DWTObject: WebTwain) => void, failureCallBack: ({code: number, message: string}) => void ): void; ``` **Parameters** `ContainerId`: Specify the id of HTML element (typically of the type HTMLDivElement) to hold the UI. `host`: Specify the host. Default value: `"127.0.0.1"` `port`: Specify the port. Default value: `18622` `portSSL`: Specify the SSL port. Default value: `18623` `successCallback`: A callback function that is executed if the request succeeds. - `DWTObject`: The `WebTwain` instance. `failureCallback`: A callback function that is executed if the request fails. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v12.0+ v12.0+ v12.0+ v12.1+
**Example** ```typescript var DWTObject; Dynamsoft.DWT.CreateDWTObject( "dwtcontrolContainer", "127.0.0.1", 18622, 18623, function (DWTObject) { DWTObject = DWTObject; DWTObject.SelectSourceAsync() .then(function () { DWTObject.AcquireImageAsync({ IfCloseSourceAfterAcquire: true, }); }) .catch(function (exp) { alert(exp.message); }); }, function (error) { console.log(error); }, ); ``` OR ```typescript var DWTObject; Dynamsoft.DWT.CreateDWTObject( "dwtcontrolContainer", function (DWTObject) { DWTObject = DWTObject; DWTObject.SelectSourceAsync() .then(function () { DWTObject.AcquireImageAsync({ IfCloseSourceAfterAcquire: true, }); }) .catch(function (exp) { alert(exp.message); }); }, function (error) { console.log(error); }, ); ``` --- ## CreateDWTObjectEx() Creates a new UI-less `WebTwain` instance. This instance will be uniquely identified by the parameter `WebTwainId`. > [!CAUTION] > Disable auto-loading a `WebTwain` instance when creating a `WebTwain` instance with `CreateDWTObject` by setting `Dynamsoft.DWT.AutoLoad = false` and `Dynamsoft.DWT.Containers = []` in the `dynamsoft.webtwain.config.js` file. **Syntax** ```typescript CreateDWTObjectEx( dwtInitialConfig: DWTInitialConfig, successCallBack: (DWTObject: WebTwain) => void, failureCallBack: ({code: number, message: string}) => void ): void; ``` **Parameters** `dwtInitialConfig`: Specify the initial configuration of the instance. Please refer to [`DWTInitialConfig`](/_articles/info/api/interfaces.md#DWTInitialConfig). `successCallback`: A callback function that is executed if the request succeeds. - `DWTObject`: The `WebTwain` instance. `failureCallback`: A callback function that is executed if the request fails. - `code`: The error code. - `message`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.0+ v16.0+ v16.0+ v16.0+
**Example** ```typescript var DWTObject; Dynamsoft.DWT.CreateDWTObjectEx( { WebTwainId: "dwtId", }, function (DWTObject) { DWTObject = DWTObject; DWTObject.Viewer.bind("dwtcontrolContainer"); DWTObject.Viewer.show(); DWTObject.SelectSourceAsync() .then(function () { DWTObject.AcquireImageAsync({ IfCloseSourceAfterAcquire: true, }); }) .catch(function (exp) { alert(exp.message); }); }, function (error) { console.log(error); }, ); ``` --- ## DeleteDWTObject() Delete and destroy the specified `WebTwain` instance. **Syntax** ```typescript DeleteDWTObject(Id: string): boolean; ``` **Parameters** `Id`: Specify the instance with its `ContainerId` or `WebTwainId`. **Return Value** `true`: Successfully. `false`: Failed. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v12.0+ v12.0+ v12.0+ v12.1+
--- ## GetWebTwain() Return the `WebTwain` instance by its `ContainerId` or `WebTwainId`. **Syntax** ```typescript GetWebTwain(ContainerIdOrWebTwainId?: string): WebTwain; ``` **Parameters** `ContainerIdOrWebTwainId`: Specify the instance with its `ContainerId` or `WebTwainId`. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.1+ v11.0+ v11.0+ v12.1+
**Example** ```javascript var DWTObject; function Dynamsoft_OnReady() { DWTObject = Dynamsoft.DWT.GetWebTwain("dwtcontrolContainer"); // Get the Dynamic Web TWAIN object that is embedded in the div with id 'dwtcontrolContainer' } ``` **Usage Note** - If no parameter is provided, the first valid `WebTwain` instance is returned. --- ## 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`. --- ## RegisterEvent() Registers an environmental event. **Syntax** ```typescript Dynamsoft.DWT.RegisterEvent(eventName: string, listener: (...arguments: any[])=>any): boolean; ``` **Parameters** `eventName`: Specify the event. Supported events: [`OnWebTwainReady`](#onwebtwainready), [`OnWebTwainError`](#onwebtwainerror), [`OnWebTwainPostExecute`](#onwebtwainpostexecute), [`OnWebTwainPreExecute`](#onwebtwainpreexecute) `listener`: Specify the callback. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Example** ```javascript Dynamsoft.DWT.RegisterEvent( "OnWebTwainReady", Dynamsoft_OnReady, //The typical function for initializing the environment once the resources have loaded ); function Dynamsoft_OnReady() { DWTObject = Dynamsoft.DWT.GetWebTwain("dwtcontrolContainer"); // Get the Dynamic Web TWAIN object that is embedded in the div with id 'dwtcontrolContainer' } Dynamsoft.DWT.RegisterEvent("OnWebTwainError", function (error) {}); Dynamsoft.DWT.RegisterEvent("OnWebTwainPostExecute", function () {}); Dynamsoft.DWT.RegisterEvent("OnWebTwainPreExecute", function () {}); ``` --- ## Unload() Destroys all `WebTwain` instances and cuts off the connection to the Dynamic Web TWAIN Service. **Syntax** ```typescript Unload(): void; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.2+ v11.0+ v11.0+ v12.1+
--- ## AutoLoad Specifies whether or not to load the Web TWAIN environment when the Dynamic Web TWAIN scripts are loaded into memory. **Syntax** ```typescript AutoLoad: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.2+ v11.0+ v11.0+ v12.1+
**Usage Notes** Default value: `true`. --- ## Containers Defines the Id and UI of the WebTwain instances. **Syntax** ```typescript Containers: Container[]; ``` Please refer to [`Container`](/_articles/info/api/interfaces.md#Container). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.1+ v11.0+ v11.0+ v12.1+
--- ## CustomizableDisplayInfo Define the display info. **Syntax** ```typescript CustomizableDisplayInfo: DisplayInfo; ``` Please refer to [`DisplayInfo`](/_articles/info/api/interfaces.md#DisplayInfo). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
--- ## DeviceFriendlyName This property allows you to specify a specified name to the client machine that will be used to identify the client machine when using Dynamsoft License Server. If this is not set, a randomly generated non-traceable UID will be generated. **Syntax** ```typescript DeviceFriendlyName: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.0+ v18.0+ v18.0+ v18.0+
--- ## EnableLocalNetworkMixedContent If enabled, the library will use HTTP to communicate with the service. The host must be `localhost` or `127.0.0.1`. The default value is `false`. It works on FireFox and Chromium-based browsers. Internet Explorer and Safari are not supported. **Syntax** ```typescript EnableLocalNetworkMixedContent: boolean; ``` **Availability**
H5(Windows) H5(macOS) H5(Linux)
v19.3+ v19.3+ v19.3+
---- ## Host Specify the target address for the local Dynamic Web TWAIN Service. **Syntax** ```typescript Host: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Usage Notes** Default value: `127.0.0.1`. --- ## IfAddMD5InUploadHeader Whether or not an md5 header `dwt-md5` should be included in HTTP upload requests. Note that this header is not a standard header and may be deemed invalid on some web servers. **Syntax** ```typescript IfAddMD5InUploadHeader: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.0+ v14.0+ v14.0+ v14.0+
**Usage Notes** Default value: `false`. --- ## IfConfineMaskWithinTheViewer This property defines whether any Dynamic Web TWAIN generated masks will apply to the entire window or just the `Viewer` object. Setting this property to `true` will confine the mask to the `Viewer` object. **Syntax** ```typescript IfConfineMaskWithinTheViewer: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.0+ v14.0+ v14.0+ v14.0+
**Usage Notes** Default Value: `false`. --- ## JSVersion This is a readonly property that specifies what version the server side Dynamic Web TWAIN resources are being used with the web application. **Syntax** ```typescript readonly JSVersion: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v13.1+ v13.1+ v13.1+ v13.1+
--- ## ProductKey Sets or returns the product key for the library. A valid product key is required for each module of Dynamic Web TWAIN. **Syntax** ```typescript ProductKey: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.1+ v11.0+ v11.0+ v12.1+
**Example** ```typescript Dynamsoft.DWT.ProductKey = "t0076lQAAAGNcO61He******"; ``` If you have multiple license keys, separate them with semicolons like below: ```typescript Dynamsoft.DWT.ProductKey = "t0076lQAAAGNcO61He******;t0076lQAAAGNcO61He******"; ``` --- ## ResourcesPath Sets or returns the path to the directory containing Dynamic Web TWAIN resource files are hosted. **Syntax** ```typescript ResourcesPath: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.1+ v11.0+ v11.0+ v12.1+
--- ## ServiceInstallerLocation Sets or returns where the path to the Dynamic Web TWAIN Service installers are hosted. **Syntax** ```typescript ServiceInstallerLocation: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.4+ v18.4+ v18.4+ v18.4+
--- ## UseDefaultViewer Whether to use the built-in viewer. **Syntax** ```typescript UseDefaultViewer: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Usage Notes** - If it is set to `false`, the file `dynamsoft.webtwain.viewer.js` is not loaded at all and there is no way to add it back later. Therefore, only set it to `false` when you absolutely won't need the viewer or will be building your own viewer. --- ## IfCheckCORS Whether to check CORS issue in detail. **Syntax** ```typescript IfCheckCORS: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.5+ v18.5+ v18.5+ v18.5+
**Usage Notes** - Default value: `false`. - When set to `true`, if encountering a CORS issue, it will detect the issue more specifically and return the corresponding CORS error. - When set to `false`, if encountering a CORS issue, it will solely detect that the Dynamic Web TWAIN Service is not connected and prompt a service installation window. --- ## IfAlwaysFocusOnPopupWindow Control whether the scanner-related UI and load/save UI are always displayed in the foreground. **Syntax** ```typescript IfAlwaysFocusOnPopupWindow: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Usage Notes** - Default value: `true`. - When set to `true`, the scanner-related UI and load/save UI will always be displayed in the foreground. - When set to `false`, the scanner-related UI and load/save UI will initially be displayed in the foreground, but by switching focus, they can be moved to the background behind the browser page. --- ## OnWebTwainReady A built-in callback triggered when the Web TWAIN resources have completed loading **Syntax** ```typescript RegisterEvent("OnWebTwainReady", function () {}); ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.1+ v11.0+ v11.0+ v12.1+
**Example** ```javascript Dynamsoft.DWT.RegisterEvent( "OnWebTwainReady", Dynamsoft_OnReady, //The typical function for initializing the environment once the resources have loaded ); var DWTObject; function Dynamsoft_OnReady() { DWTObject = Dynamsoft.DWT.GetWebTwain("dwtcontrolContainer"); // Get the Dynamic Web TWAIN object that is embedded in the div with id 'dwtcontrolContainer' } ``` --- ## OnWebTwainError A built-in callback triggered when an error is detected when loading the Web TWAIN environment. **Syntax** ```typescript RegisterEvent("OnWebTwainError", function () {}); ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.2+ v18.2+ v18.2+ v18.2+
**Example** ```javascript Dynamsoft.DWT.RegisterEvent("OnWebTwainError", Dynamsoft_OnError); function Dynamsoft_OnError(error) { // error handling console.error(error.message); } ``` --- ## OnWebTwainPostExecute This event triggers at the resolution of an asynchronous API. The default behavior is to hide the mask and loading spinner triggered by `OnWebTwainPreExecute`. You may override this function to implement your own post-execute scenario. Please refer to this [article](/_articles/extended-usage/ui-customization.md#loading-bar-and-backdrop). **Syntax** ```typescript RegisterEvent("OnWebTwainPostExecute", function () {}); ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.3+ v11.0+ v11.0+ v12.1+
--- ## OnWebTwainPreExecute This event triggers at the beginning of an asynchronous API. The default behavior is to display a mask and a loading spinner. You may override this function to either hide the default loading spinner, or define your own. Please refer to this [article](/_articles/extended-usage/ui-customization.md#loading-bar-and-backdrop). **Syntax** ```typescript RegisterEvent("OnWebTwainPreExecute", function () {}); ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.3+ v11.0+ v11.0+ v12.1+
--- title: Dynamic Web TWAIN SDK API Reference - Acquire APIs description: Dynamic Web TWAIN SDK Documentation API Reference Acquire APIs Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Acquire.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/WebTwain_Acquire.md --- # {WebTwainObject} Scan > The properties and methods on this page live in the namespace {WebTwainObject}. {WebTwainObject} denotes the `WebTwain` instance. Learn more about creating `WebTwain` instances [here](/_articles/general-usage/initialization.md). **1. The following APIs are compatible with TWAIN, ICA, and SANE (Windows, macOS and Linux)** **Methods** | [`GetSourceNameItems()`](#getsourcenameitems) | [`GetSourceNames()`](#getsourcenames) | [`GetSourceNamesAsync()`](#getsourcenamesasync) | [`SelectSource()`](#selectsource) | | [`SelectSourceAsync()`](#selectsourceasync) | [`SelectSourceByIndex()`](#selectsourcebyindex) | [`SelectSourceByIndexAsync()`](#selectsourcebyindexasync) | [`OpenSource()`](#opensource) | | [`OpenSourceAsync()`](#opensourceasync) | [`EnableSourceUI()`](#enablesourceui) | [`EnableSource()`](#enablesource) | [`AcquireImage()`](#acquireimage) | | [`AcquireImageAsync()`](#acquireimageasync) | [`startScan()`](#startscan) | [`DisableSource()`](#disablesource) | [`CloseSource()`](#closesource) | | [`CloseSourceAsync()`](#closesourceasync) | [`CloseWorkingProcess()`](#closeworkingprocess) | [`GetDevicesAsync()`](#getdevicesasync) | [`SelectDeviceAsync()`](#selectdeviceasync) | | [`SetOpenSourceTimeout()`](#setopensourcetimeout) | **Properties** | [`CurrentSourceName`](#currentsourcename) | [`IfDisableSourceAfterAcquire`](#ifdisablesourceafteracquire) | [`IfDuplexEnabled`](#ifduplexenabled) | [`IfFeederEnabled`](#iffeederenabled) | | [`PageSize`](#pagesize) | [`PixelType`](#pixeltype) | [`Resolution`](#resolution) | [`SourceCount`](#sourcecount) | **Events** | [`OnPostAllTransfers`](#onpostalltransfers) | [`OnPostTransfer`](#onposttransfer) | [`OnPostTransferAsync`](#onposttransferasync) | [`OnPreAllTransfers`](#onprealltransfers) | | [`OnPreTransfer`](#onpretransfer) | | | | **2. The following APIs are compatible with TWAIN and ICA** **Methods** | [`getCapabilities()`](#getcapabilities) | [`setCapabilities()`](#setcapabilities) | **3. The following APIs are compatible with TWAIN (mostly Windows, but also possibly macOS)** **Methods** | [`OpenSourceManager()`](#opensourcemanager) | [`OpenSourceManagerAsync()`](#opensourcemanagerasync) | [`CloseSourceManager()`](#closesourcemanager) | [`CloseSourceManagerAsync()`](#closesourcemanagerasync) | | [`GetCustomDSData()`](#getcustomdsdata) | [`GetCustomDSDataEx()`](#getcustomdsdataex) | [`CancelAllPendingTransfers()`](#cancelallpendingtransfers) | [`FeedPage()`](#feedpage) | | [`ResetImageLayout()`](#resetimagelayout) | [`RewindPage()`](#rewindpage) | [`SetCustomDSData()`](#setcustomdsdata) | [`SetCustomDSDataEx()`](#setcustomdsdataex) | | [`SetFileXferInfo()`](#setfilexferinfo) | [`SetImageLayout()`](#setimagelayout) | | | **Properties** | [`BitDepth`](#bitdepth) | [`Brightness`](#brightness) | [`Contrast`](#contrast) | [`DataSourceStatus`](#datasourcestatus) | | [`DefaultSourceName`](#defaultsourcename) | [`Duplex`](#duplex) | [`IfAutoBright`](#ifautobright) | [`IfAutoDiscardBlankpages`](#ifautodiscardblankpages) | | [`IfAutoFeed`](#ifautofeed) | [`IfAutomaticBorderDetection`](#ifautomaticborderdetection) | [`IfAutomaticDeskew`](#ifautomaticdeskew) | [`IfAutoScan`](#ifautoscan) | | [`IfFeederLoaded`](#iffeederloaded) | [`IfPaperDetectable`](#ifpaperdetectable) | [`IfShowIndicator`](#ifshowindicator) | [`IfShowUI`](#ifshowui) | | [`IfUIControllable`](#ifuicontrollable) | [`IfUseTwainDSM`](#ifusetwaindsm) | [`ImageCaptureDriverType`](#imagecapturedrivertype) | [`ImageLayoutDocumentNumber`](#imagelayoutdocumentnumber) | | [`ImageLayoutFrameBottom`](#imagelayoutframebottom) | [`ImageLayoutFrameLeft`](#imagelayoutframeleft) | [`ImageLayoutFrameNumber`](#imagelayoutframenumber) | [`ImageLayoutFrameRight`](#imagelayoutframeright) | | [`ImageLayoutFrameTop`](#imagelayoutframetop) | [`ImageLayoutPageNumber`](#imagelayoutpagenumber) | [`ImagePixelType`](#imagepixeltype) | [`MagData`](#magdata) | | [`MagType`](#magtype) | [`PendingXfers`](#pendingxfers) | [`PixelFlavor`](#pixelflavor) | [`TransferMode`](#transfermode) | | [`Unit`](#unit) | [`XferCount`](#xfercount) | [`IfAppendImage`](#ifappendimage) | | **Events** | [`OnSourceUIClose`](#onsourceuiclose) | --- ## AcquireImage() Request a scan, then store to the image buffer of the WebTwain instance upon completion of the scan. By default, the scans are displayed from the `dwtcontrolContainer` container. **Syntax** ```typescript AcquireImage(): void; AcquireImage( deviceConfiguration: DeviceConfiguration ): void; AcquireImage( successCallBack: () => void, failureCallBack: ( errorCode: number, errorString: string) => void ): void; AcquireImage( deviceConfiguration: DeviceConfiguration, successCallBack: () => void, failureCallBack: ( deviceConfiguration: DeviceConfiguration, errorCode: number, errorString: string) => void ): void; ``` **Parameters** `deviceConfiguration`: Configuration for the acquisition. Please refer to [`DeviceConfiguration`](/_articles/info/api/interfaces.md#DeviceConfiguration). `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Example** > The example code shows 4 ways to use the API `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); } ``` --- ## CloseSource() Close the data source (a TWAIN/ICA/SANE device, which in most cases is a scanner) to free it to be used by other applications. **Syntax** ```typescript CloseSource(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Example** ```javascript // Close the scanner source in the success/failure callback after all images are acquired. In this case, the source can be freed and used by others. DWTObject.OpenSource(); DWTObject.AcquireImage(successCallback,failureCallback); function successCallback() { console.log("successful"); DWTObject.CloseSource(); } function failureCallback(errorCode, errorString) { alert(errorString); DWTObject.CloseSource(); } ``` --- ## CloseSourceAsync() Close the data source (a TWAIN/ICA/SANE device, which in most cases is a scanner) to free it to be used by other applications. **Syntax** ```typescript CloseSourceAsync(): Promise; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.1+ v16.1+ v16.1+ v16.1+
--- ## DisableSource() Disable the data source (a TWAIN/ICA/SANE device, which in most cases is a scanner) to stop the acquisition process. This also closes the data source's user interface, if it is displayed. **Syntax** ```typescript DisableSource(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** After calling `DisableSource()`, the data source remains open, and you can continue to acquire images by calling [`AcquireImage()`](/_articles/info/api/WebTwain_Acquire.md#acquireimage) or [`EnableSource()`](/_articles/info/api/WebTwain_Acquire.md#enablesource). --- ## EnableSource() Enable the data source to start the acquisition process. **Syntax** ```typescript EnableSource(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** The method is equivalent to `AcquireImage()` without parameters. --- ## EnableSourceUI() Display the TWAIN source's built-in user interface. **Syntax** ```typescript EnableSourceUI( successCallBack: () => void, failureCallBack: (errorCode: number, errorString: string) => void ): boolean; ``` **Parameters** `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.0+ v16.0+ v16.0+ v16.0+
**Usage notes** This method enables the user to manipulate the scan settings without actually starting a scan. It only works if the source supports the capability `CAP_ENABLEDSUIONLY`. You can call [`GetCustomDSDataEx()`](#getcustomdsdataex) to save the settings in the callback `successCallBack`. You can then call [`SetCustomDSDataEx()`](#setcustomdsdataex) at a later time to apply these settings before starting a scan. --- ## OpenSource() Load a data source to prepare it for image acquisition. **Syntax** ```typescript OpenSource(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Example** ```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); } ``` --- ## OpenSourceAsync() Load a data source to prepare it for image acquisition. **Syntax** ```typescript OpenSourceAsync(): Promise; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.1+ v16.1+ v16.1+ v16.1+
--- ## GetSourceNames() Return all available data sources (scanners, etc.), and optionally all detailed information about them. **Syntax** ```typescript GetSourceNames(bIncludeDetails?: boolean): string[] | SourceDetails[]; ``` **Parameters** `bIncludeDetails`: Whether to return more details about the data sources or just their names. **Arguments** `SourceDetails`: Please refer to [`SourceDetails`](/_articles/info/api/interfaces.md#sourcedetails). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v15.3+ v15.3+ v15.3+ v15.3+
**Example** ```javascript DWTObject.GetSourceNames(); // return a list of scanner sources such as ['PaperStream IP fi-7300NX Net', 'TWAIN2 FreeImage Software Scanner'] ``` --- ## GetSourceNamesAsync() Return all available data sources (scanners, etc.) and optionally all detailed information about them. **Syntax** ```typescript GetSourceNamesAsync(bIncludeDetails: boolean): Promise; ``` **Parameters** `bIncludeDetails`: Whether to return more details about the data sources or just their names. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.1+ v16.1+ v16.1+ v16.1+
--- ## SelectSource() Bring up the Source Selection User Interface (UI) for the user to choose a data source. **Syntax** ```typescript SelectSource(): boolean | string; // Call this API asynchronously to avoid blocking the browser's main thread SelectSource( successCallBack: () => void, failureCallBack: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v14.0+
**Usage notes** - We recommend calling this API asynchronously by passing arguments to `successCallback` and `failureCallback`. - **Windows only**: you can call this API without arguments, in which case it runs synchronously and returns a boolean value. **Example** ```javascript DWTObject.SelectSource( function () { DWTObject.OpenSource(); DWTObject.AcquireImage(successCallback, failureCallback); }, function (errorCode, errorString) { console.log(errorString); } ); function successCallback() { DWTObject.CloseSource(); console.log("successful"); } function failureCallback(errorCode, errorString) { DWTObject.CloseSource(); console.log(errorString); } ``` --- ## SelectSourceAsync() Bring up the Source Selection User Interface (UI) for the user to choose a data source. **Syntax** ```typescript SelectSourceAsync(deviceType?: Dynamsoft.DWT.EnumDWT_DeviceType | number): Promise; ``` **Parameters** `deviceType`: Specify the device type of scanners. Please refer to [`EnumDWT_DeviceType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_devicetype). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.1+ v16.1+ v16.1+ v16.1+
**Example** ```javascript DWTObject.SelectSourceAsync() .then(function (sourceIndex) { console.log(sourceIndex); return DWTObject.AcquireImageAsync({ IfCloseSourceAfterAcquire: true, }); }) .catch(function (e) { console.log(e); }); ``` --- ## SelectSourceByIndex() Select a data source by its index. **Syntax** ```typescript SelectSourceByIndex(index: number): boolean; ``` **Parameters** `index`: The index of the data source. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Example** ```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(); console.log(errorString); } ``` --- ## SelectSourceByIndexAsync() Select a data source by its index. **Syntax** ```typescript SelectSourceByIndexAsync(index: number): Promise; ``` **Parameters** `index`: The index of the data source. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.1+ v16.1+ v16.1+ v16.1+
**Example** ```javascript DWTObject.SelectSourceByIndexAsync(0) .then(() => { return DWTObject.OpenSourceAsync(); }) .then(() => { return DWTObject.AcquireImageAsync({ IfCloseSourceAfterAcquire: true, }); }); ``` --- ## SetOpenSourceTimeout() Set a timer which stops the data source opening process once it expires. **Syntax** ```typescript SetOpenSourceTimeout(duration: number): boolean; ``` **Parameters** `duration`: Set the duration of the timer (in milliseconds). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v11.0+ v11.0+ v11.0+ v12.1+
**Example** ```javascript DWTObject.SelectSource(function () { DWTObject.SetOpenSourceTimeout(3000); // stop the opening process if the source cannot be opened within 3000 ms. DWTObject.OpenSource(); DWTObject.AcquireImage(); }); ``` --- ## startScan() Start the acquisition by passing all settings at once. **Syntax** ```typescript startScan(scanSetup: ScanSetup): Promise; ``` **Parameters** `scanSetup`: Configuration for the acquisition. Please refer to [`ScanSetup`](/_articles/info/api/interfaces.md#scansetup). **Availability**
H5(Windows/TWAIN) H5(Windows/WIA) H5(macOS/TWAIN) H5(macOS/ICA) H5(macOS/eSCL) H5(Linux/SANE)
v15.0+ v18.5+ v15.1+ v15.1+ v18.5+ v15.1+
**Usage notes** [`OnPostTransfer`](#onposttransfer), [`OnPostAllTransfers`](#onpostalltransfers) and [`OnPreAllTransfers`](#onprealltransfers) events are not triggered using `startScan()`. You can use the `funcScanStatus` callback instead. **Sample** Make use of the API startScan --- ## CancelAllPendingTransfers() Cancel all pending transfers. **Syntax** ```typescript CancelAllPendingTransfers(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** This method is only valid in the events [`OnPreAllTransfers`](#onprealltransfers), [`OnPreTransfer`](#onpretransfer) and [`OnPostTransfer`](#onposttransfer). --- ## CloseSourceManager() Close and unload the Data Source Manager. **Syntax** ```typescript CloseSourceManager(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Example** ```javascript DWTObject.CloseSourceManager(); ``` --- ## CloseSourceManagerAsync() Close and unload the Data Source Manager. **Syntax** ```typescript CloseSourceManagerAsync(): Promise; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.1+ v16.1+ v16.1+ v16.1+
--- ## CloseWorkingProcess() Close the scanning process to release resources on the machine. **Syntax** ```typescript CloseWorkingProcess(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v11.2+ v11.2+ v11.2+ v12.1+
**Usage notes** In the HTML5 edition, Dynamic Web TWAIN uses a separate process to communicate with the scanners. When not scanning, you can choose to close this process to free up resources on the end user's machine. (CPU, memory, etc.) --- ## FeedPage() Eject the current page and begin scanning the next page in the document feeder. **Syntax** ```typescript FeedPage(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** Use this method after calling [`OpenSource()`](#opensource), and make sure [`IfFeederEnabled`](#iffeederenabled) is `true` . --- ## GetCustomDSData() Get the custom data source data and save the data to a specified file. **Syntax** ```typescript GetCustomDSData(fileName: string): boolean; ``` **Parameters** `fileName`: The path of the file to save the data source data to. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** Typically, the data source data file is set by the method [`SetCustomDSData()`](#setcustomdsdata). **Example** ```javascript // Please note, the API only works for TWAIN driver. DWTObject.GetCustomDSData("C:\\Users\\UserName\\Desktop\\ProfileName"); ``` --- ## GetCustomDSDataEx() Get custom DS data and return it in a base64 string. **Syntax** ```typescript GetCustomDSDataEx(): string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** Typically, the data source data file is set by the method [`SetCustomDSDataEx()`](#setcustomdsdataex). **Example** ```javascript // Please note, the API only works for TWAIN driver. DWTObject.GetCustomDSDataEx(); // Return a base64 string ``` --- ## GetSourceNameItems() Get the name of a data source by its index in the data source manager source list. **Syntax** ```typescript GetSourceNameItems(index: number): string; ``` **Parameters** `index`: The index of the data source. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Example** ```javascript DWTObject.GetSourceNames(); // [scanner 1, scanner 2, scanner 3...] DWTObject.GetSourceNameItems(0); // return the name of scanner 1 ``` --- ## OpenSourceManager() Load and open the data source manager. **Syntax** ```typescript OpenSourceManager(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** If application identification needs to be set, it should be set before calling this API. **Example** ```javascript DWTObject.OpenSourceManager(); ``` --- ## OpenSourceManagerAsync() Load and open the data source manager. **Syntax** ```typescript OpenSourceManagerAsync(): Promise; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.1+ v16.1+ v16.1+ v16.1+
**Usage notes** If application identification needs to be set, it should be set before calling this API. --- ## ResetImageLayout() Reset the image layout in the data source. **Syntax** ```typescript ResetImageLayout(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** You can use [`SetImageLayout()`](#setimagelayout) to set the image layout manually. --- ## RewindPage() If called while the `{IfFeederEnabled}` property is true, the data source will return the current page to the input area, and return the last page from the output area into the acquisition area. **Syntax** ```typescript RewindPage(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** Use this API after calling [`OpenSource()`](#opensource), and make sure [`IfFeederEnabled`](#iffeederenabled) is `true` . --- ## SetCustomDSData() Set custom data source data to be used for scanning. The data is stored in a file which may be regarded as a scanning profile. **Syntax** ```typescript SetCustomDSData(fileName: string): boolean; ``` **Parameters** `fileName`: The path of the file. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** Typically, the data source data file is created by the method [`GetCustomDSData()`](#getcustomdsdata). **Example** ```javascript // Please note, the API only works for TWAIN driver. DWTObject.SetCustomDSData("C:\\Users\\UserName\\Desktop\\ProfileName"); ``` --- ## SetCustomDSDataEx() Set custom data source data to be used for scanning. The input format is a base64 string. **Syntax** ```typescript SetCustomDSDataEx(dsDataString: string): boolean; ``` **Parameters** `dsDataString`: The string that contains custom data source data. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** Typically the data source data string is created by the method [`GetCustomDSDataEx()`](#getcustomdsdataex) ```javascript // Please note, the API only works for TWAIN driver. DWTObject.SetCustomDSData("the base64 string of your profile"); ``` --- ## SetFileXferInfo() Set the file transfer information to be used in File Transfer mode. **Syntax** ```typescript SetFileXferInfo( fileName: string, fileFormat: Dynamsoft.DWT.EnumDWT_FileFormat | number ): boolean; ``` **Parameters** `fileName`: The path to transfer the file to. `fileFormat`: The format of the file. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v17.0+ not supported
**Usage notes** Make sure the format you set is supported by the data source. Example argument for the parameter `fileName` - "C:\\webtwain.jpg": The next scanned image will be compressed as a JPEG file named `webtwain` and transferred to "C:\\". - "C:\\webtwain" + <> + ".jpg": The scanned images will result in "C:\\webtwain1.jpg", "C:\\webtwain2.jpg", "C:\\webtwain3.jpg", etc. - "C:\\webtwain" + <%06d> + ".jpg": The scanned images will result in "C:\\webtwain000001.jpg", "C:\\webtwain000002.jpg", "C:\\webtwain000003.jpg", etc. Available file formats are defined in [`Dynamsoft.DWT.EnumDWT_FileFormat`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_fileformat). **Example** ```javascript DWTObject.OpenSource(); DWTObject.TransferMode = Dynamsoft.DWT.EnumDWT_TransferMode.TWSX_FILE; if (DWTObject.TransferMode === Dynamsoft.DWT.EnumDWT_TransferMode.TWSX_FILE) { if ( DWTObject.SetFileXferInfo( "C:\\Temp\\WebTWAIN<%06d>.bmp", Dynamsoft.DWT.EnumDWT_FileFormat.TWFF_BMP ) ) { DWTObject.IfShowUI = true; DWTObject.AcquireImage(successCallback, failureCallback); } } function successCallback() { DWTObject.CloseSource(); console.log("successful"); } function failureCallback(errorCode, errorString) { DWTObject.CloseSource(); console.log(errorString); } ``` --- ## SetImageLayout() Set the image layout rectangle for the current data source by specifying the rectangle's left, top, right, and bottom sides, respectively. The image layout rectangle defines a frame of the data source's scanning area to be acquired. **Syntax** ```typescript SetImageLayout( left: number, top: number, right: number, bottom: number ): boolean; ``` **Parameters** `left`: Specify the rectangle (leftmost coordinate). `top`: Specify the rectangle (topmost coordinate). `right`: Specify the rectangle (rightmost coordinate). `bottom`: Specify the rectangle (bottommost coordinate). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** The arguments set to the parameters `left` , `top` , `right` , `bottom` are expressed in the measurement unit defined by the [`Unit`](#unit) property, which is `inches` by default. This API is device-dependent. If a data source does not support customizing the scan area, this method might not work correctly. Since there are several ways to negotiate the scan area, it becomes confusing when deciding what should take precedence. The TWAIN Working Group has suggested the following behavior: - Setting the frame with `SetImageLayout()` shall be equivalent to setting the frame with [`CapGetFrameBottom()`](https://www.dynamsoft.com/docs/dwt15.3.1/API/Capability-Negotiation.html#CapGetFrameBottom), [`CapGetFrameLeft()`](https://www.dynamsoft.com/docs/dwt15.3.1/API/Capability-Negotiation.html#CapGetFrameLeft), [`CapGetFrameRight()`](https://www.dynamsoft.com/docs/dwt15.3.1/API/Capability-Negotiation.html#CapGetFrameRight), [`CapGetFrameTop()`](https://www.dynamsoft.com/docs/dwt15.3.1/API/Capability-Negotiation.html#CapGetFrameTop) and the property [PageSize](#pagesize) shall return `TWSS_NONE` (0). - If the current frame is set from negotiating the capability `ICAP_FRAMES` with the method [CapSetFrame()](https://www.dynamsoft.com/docs/dwt15.3.1/API/Capability-Negotiation.html#CapSetFrame), the property [PageSize](#pagesize) shall return `TWSS_NONE` (0) and the image layout shall reflect the same frame with the properties [ImageLayoutFrameBottom](#imagelayoutframebottom), [ImageLayoutFrameLeft](#imagelayoutframeleft), [ImageLayoutFrameRight](#imagelayoutframeright) and [ImageLayoutFrameTop](#imagelayoutframetop). - If the current fixed frame is set by the property [PageSize](#pagesize), the same dimensions shall be reflected in the APIs [CapGetFrameBottom()](https://www.dynamsoft.com/docs/dwt15.3.1/API/Capability-Negotiation.html#CapGetFrameBottom), [CapGetFrameLeft()](https://www.dynamsoft.com/docs/dwt15.3.1/API/Capability-Negotiation.html#CapGetFrameLeft), [CapGetFrameRight()](https://www.dynamsoft.com/docs/dwt15.3.1/API/Capability-Negotiation.html#CapGetFrameRight), [CapGetFrameTop()](https://www.dynamsoft.com/docs/dwt15.3.1/API/Capability-Negotiation.html#CapGetFrameTop) as well as [ImageLayoutFrameBottom](#imagelayoutframebottom), [ImageLayoutFrameLeft](#imagelayoutframeleft), [ImageLayoutFrameRight](#imagelayoutframeright) and [ImageLayoutFrameTop](#imagelayoutframetop). Note, however, the orientation (in other words, whether it's in the portrait mode or landscape mode) also plays a role in the order of the values. **Example** ```javascript DWTObject.SelectSource(); DWTObject.OpenSource(); DWTObject.IfShowUI = false; DWTObject.Unit = Dynamsoft.DWT.EnumDWT_UnitType.TWUN_PIXELS; DWTObject.SetImageLayout(50, 50, 100, 100); DWTObject.AcquireImage(successCallback, failureCallback); function successCallback() { DWTObject.CloseSource(); console.log("successful"); } function failureCallback(errorCode, errorString) { DWTObject.CloseSource(); console.log(errorString); } ``` --- ## BitDepth Return or set the pixel bit depth for the current color mode (defined by [`PixelType`](/_articles/info/api/WebTwain_Acquire.md#pixeltype)). **Syntax** ```typescript BitDepth: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** Set this property after [`OpenSource()`](/_articles/info/api/WebTwain_Acquire.md#opensource) and before [`AcquireImage()`](/_articles/info/api/WebTwain_Acquire.md#acquireimage) for the desired bit depth to take effect upon calling [`AcquireImage()`](/_articles/info/api/WebTwain_Acquire.md#acquireimage). The default bit depth is 1 for `TWPT_BW` , 8 for `TWPT_GRAY` and 24 for `TWPT_RGB` . --- ## IfAppendImage Return or set whether newly acquired images are inserted or appended to the image buffer. **Syntax** ```typescript IfAppendImage: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** The value of this property defaults to `true`, meaning that the newly acquired image will be appended to the last image in the buffer. If it's set to `false` , the images will be inserted before the current image. Note that by design, the current image is always the previously acquired image. This means that the images acquired after setting `IfAppendImage` to `false` will be displayed/retained in reverse order. Read this [article](/_articles/faq/insert-new-pages-to-existing-document.md#can-i-insert-newly-scanned-pages-to-an-existing-document) learn how to insert new images to a specified index in the image buffer. --- ## IfDisableSourceAfterAcquire Return or set whether or not to disable the scanner (i.e., the image source) after acquiring all images. When this property is set to `true` and the scanning UI is open, this setting simultaneously closes the scanning UI when disabling the image source. **Syntax** ```javascript IfDisableSourceAfterAcquire: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Example** ```javascript DWTObject.OpenSource(); DWTObject.IfDisableSourceAfterAcquire = true; // Close the scanner UI after images acquired. DWTObject.IfShowUI = true; DWTObject.AcquireImage(successCallback,failureCallback); function successCallback() { DWTObject.CloseSource(); } function failureCallback(errorCode, errorString) { DWTObject.CloseSource(); } ``` --- ## IfDuplexEnabled Return or set whether or not to enable duplex scanning (scanning both sides of the paper). **Syntax** ```typescript IfDuplexEnabled: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** Set this property after calling [`OpenSource()`](/_articles/info/api/WebTwain_Acquire.md#opensource) and before calling [`AcquireImage()`](/_articles/info/api/WebTwain_Acquire.md#acquireimage) for the setting to take effect upon calling [`AcquireImage()`](/_articles/info/api/WebTwain_Acquire.md#acquireimage). Not all scanners support duplex scanning. To confirm, check the user manual of the device or check the value of [`Duplex`](/_articles/info/api/WebTwain_Acquire.md#duplex) after calling [`OpenSource()`](/_articles/info/api/WebTwain_Acquire.md#opensource). **Example** ```javascript DWTObject.OpenSource(); if (DWTObject.Duplex != 0) { // Note: DWTObject.Duplex doesn't support Linux. DWTObject.IfDuplexEnabled = true; } DWTObject.AcquireImage(successCallback, failureCallback); function successCallback() { DWTObject.CloseSource(); console.log("successful"); } function failureCallback(errorCode, errorString) { DWTObject.CloseSource(); console.log(errorString); } ``` --- ## IfFeederEnabled Return or set whether or not a data source's Automatic Document Feeder (ADF) is enabled for scanning. **Syntax** ```typescript IfFeederEnabled: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** Set this property after [`OpenSource()`](/_articles/info/api/WebTwain_Acquire.md#opensource) and before [`AcquireImage()`](/_articles/info/api/WebTwain_Acquire.md#acquireimage) for the setting to take effect upon calling [`AcquireImage()`](/_articles/info/api/WebTwain_Acquire.md#acquireimage). If the property is set to `true`, the data source attempt to acquire images from the document feeder first. Otherwise, if the data source does not have a document feeder, the data source will use the flatbed. **Example** ```javascript DWTObject.OpenSource(); DWTObject.IfFeederEnabled = true; DWTObject.AcquireImage(successCallback, failureCallback); function successCallback() { DWTObject.CloseSource(); console.log("successful"); } function failureCallback(errorCode, errorString) { DWTObject.CloseSource(); console.log(errorString); } ``` --- ## IfShowUI Return or set whether or not the data source displays the user interface when scanning. **Syntax** ```typescript IfShowUI: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** when the property is set to `true`, the data source displays its user interface when [`AcquireImage()`](/_articles/info/api/WebTwain_Acquire.md#acquireimage) is called. Otherwise, the scan starts immediately without displaying the UI. It is recommended to use this API after [`OpenSource()`](/_articles/info/api/WebTwain_Acquire.md#opensource) is called. Setting `IfShowUI` is also effective for the new [`AcquireImageAsync`](#acquireimageasync) method. But it is recommended to use the [`DeviceConfiguration`](/_articles/info/api/interfaces.md#deviceconfiguration) parameter of the method. **Example** ```javascript DWTObject.OpenSource(); DWTObject.IfShowUI = true; // display the scanner UI before acquiring image DWTObject.AcquireImage(successCallback, failureCallback); function successCallback() { DWTObject.CloseSource(); console.log("successful"); } function failureCallback(errorCode, errorString) { DWTObject.CloseSource(); console.log(errorString); } ``` --- ## ImageCaptureDriverType Return or set the driver type, which determines the type of sources to use. **Syntax** ```typescript ImageCaptureDriverType: Dynamsoft.DWT.EnumDWT_Driver | number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v11.0+ v11.0+ v11.0+ not supported
**Usage notes** Set this property immediately after initializing the SDK, or after calling [`CloseSourceManager()`](/_articles/info/api/WebTwain_Acquire.md#closesourcemanager) and [`OpenSourceManager()`](/_articles/info/api/WebTwain_Acquire.md#opensourcemanager). The allowed values for `EnumDWT_Driver` are | Label | Value | Description | | :---------------- | :---- | :---------------------------------------------------------------------------------- | | TWAIN | 0 | Use data sources that conforms to the TWAIN protocol **(Default value on Windows)** | | ICA | 3 | Use data sources that conforms to the Image Capture Architecture | | SANE | 3 | Use data sources that conforms to the SANE API **(Default value on Linux)** | | TWAIN_AND_ICA | 4 | Use both TWAIN and ICA data sources **(Default value on MacOS)** | | TWAIN_AND_TWAIN64 | 4 | Use both 32bit and 64bit TWAIN drivers | | TWAIN64 | 5 | Use 64bit TWAIN sources | --- ## PageSize Return or set the page size that the data source uses to acquire images. **Syntax** ```typescript PageSize: Dynamsoft.DWT.EnumDWT_CapSupportedSizes | number; ``` **Parameters** `PageSize`: Please refer to [`EnumDWT_CapSupportedSizes`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_capsupportedsizes) **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ not supported
**Usage notes** Set this property after [`OpenSource()`](/_articles/info/api/WebTwain_Acquire.md#opensource) and before [`AcquireImage()`](/_articles/info/api/WebTwain_Acquire.md#acquireimage) for the setting to take effect upon calling [`AcquireImage()`](/_articles/info/api/WebTwain_Acquire.md#acquireimage). --- ## PixelType Return or set the pixel type used when acquiring images. **Syntax** ```typescript PixelType: Dynamsoft.DWT.EnumDWT_PixelType | number; ``` Please refer to [`EnumDWT_PixelType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_pixeltype). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** Set this property after [`OpenSource()`](/_articles/info/api/WebTwain_Acquire.md#opensource) and before [`AcquireImage()`](/_articles/info/api/WebTwain_Acquire.md#acquireimage) for the setting to take effect upon calling [`AcquireImage()`](/_articles/info/api/WebTwain_Acquire.md#acquireimage). --- ## Resolution Return or set the resolution used when acquiring images. **Syntax** ```typescript Resolution: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** Set this property after [`OpenSource()`](/_articles/info/api/WebTwain_Acquire.md#opensource) and before [`AcquireImage()`](/_articles/info/api/WebTwain_Acquire.md#acquireimage) for the setting to take effect upon calling [`AcquireImage()`](/_articles/info/api/WebTwain_Acquire.md#acquireimage). --- ## SourceCount Return the number of data sources available on the local system. **Syntax** ```typescript readonly SourceCount: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## BlankImageThreshold Return or set the blank image detection threshold. Higher values are lenient (higher likelihood of detecting blank pages), and lower values are stringent (lower likelihood of detecting blank pages). **Syntax** ```typescript BlankImageThreshold: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.2+ v5.2+ v5.2+ v5.2+
**Usage notes** `BlankImageThreshold` ranges from 0 to 255, and is 128 by default. This property only takes effect when [`PixelType`](/_articles/info/api/WebTwain_Acquire.md#pixeltype) is set to `TWPT_BW` . The bigger the value is, the more likely it is for an image to be classified as blank. --- ## Brightness Return or set the brightness value used for scanning by the data source. **Syntax** ```typescript Brightness: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported v12.1+
**Usage notes** Set this property after [`OpenSource()`](/_articles/info/api/WebTwain_Acquire.md#opensource) and before [`AcquireImage()`](/_articles/info/api/WebTwain_Acquire.md#acquireimage) for the setting to take effect upon calling [`AcquireImage()`](/_articles/info/api/WebTwain_Acquire.md#acquireimage). Typically, the value range is -1000 ~ 1000 where -1000 indicates the darkest and 1000 the brightest. --- ## Contrast Return or set the contrast value used for scanning by the data source. **Syntax** ```typescript Contrast: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported v12.1+
**Usage notes** Set this property after [`OpenSource()`](/_articles/info/api/WebTwain_Acquire.md#opensource) and before [`AcquireImage()`](/_articles/info/api/WebTwain_Acquire.md#acquireimage) for the setting to take effect upon calling [`AcquireImage()`](/_articles/info/api/WebTwain_Acquire.md#acquireimage). Typically, the value range is -1000 ~ 1000, where -1000 indicates the lowest contrast and 1000 the highest contrast. --- ## CurrentSourceName Return the device name of the current data source. **Syntax** ```typescript readonly CurrentSourceName: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** If no source is currently selected, this property returns "". --- ## DataSourceStatus Return the data source status code. **Syntax** ```typescript DataSourceStatus: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** | Value | Description | | :---- | :----------------------------------- | | 0 | The data source is closed. | | 1 | The data source is opened. | | 2 | The data source is enabled. | | 3 | The data source is acquiring images. | --- ## DefaultSourceName Return the name of the last used source. **Syntax** ```typescript DefaultSourceName: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported v17.0+
--- ## Duplex Indicate if the data source supports 1-pass duplex scanning, 2-pass duplex scanning, or does not support duplex scanning at all. **Syntax** ```typescript readonly Duplex: Dynamsoft.DWT.EnumDWT_DUPLEX | number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** | Label | Value | Description | | :--------------- | :---- | :---------------------- | | TWDX_NONE | 0 | duplex is not supported | | TWDX_1PASSDUPLEX | 1 | 1-pass duplex | | TWDX_2PASSDUPLEX | 2 | 2-pass duplex | 1-pass means the paper gets scanned on both sides at the same time. 2-pass means the paper passes the light bar twice to get both sides scanned separately. This property is not supported on Linux. --- ## IfAutoBright Return or set whether or not to enable the data source's auto-brightness feature. **Syntax** ```typescript IfAutoBright: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
--- ## IfAutoDiscardBlankpages Return or set whether or not the data source automatically discards blank images during scanning. **Syntax** ```typescript IfAutoDiscardBlankpages: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** This property works only if the device and its driver support discarding blank pages. You can find whether your device supports this capability from the device's user manual. Alternatively, the Dynamic Web TWAIN library can also detect blank images after they are transferred. --- ## IfAutoFeed Return or set whether or not to enable the data source's automatic document feeding feature. **Syntax** ```typescript IfAutoFeed: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** If set to `true` , the data source will automatically feed the next page from the document feeder as soon as the previous page is scanned. --- ## IfAutomaticBorderDetection Return or set whether or not to enable the data source's automatic border detection feature. **Syntax** ```typescript IfAutomaticBorderDetection: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** The property works only if the device and its driver support automatic border detection. You can check for device capability support in the device's user manual. Once enabled, the data source (scanner) automatically detects the borders of the document so as to not scan extra margins. --- ## IfAutomaticDeskew Return or set whether or not to enable the data source's automatic skew correction feature. **Syntax** ```typescript IfAutomaticDeskew: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** The property works only if the device and its driver supports automatic de-skewing. You can check for device capability support in the device's user manual. --- ## IfAutoScan Return or set whether or not to enable the data source's automatic document scanning feature. **Syntax** ```typescript IfAutoScan: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** This property is only valid when [`IfFeederEnabled`](/_articles/info/api/WebTwain_Acquire.md#iffeederenabled) is set to `true` . The fundamental assumption behind this property is that the device can capture the number of images indicated by the property [`XferCount`](/_articles/info/api/WebTwain_Acquire.md#xfercount) without waiting for the Application to request the image transfers. This is only possible if the device has internal buffers capable of caching the images it captures. --- ## IfFeederLoaded Return whether or not there are documents loaded in the data source's feeder. **Syntax** ```typescript readonly IfFeederLoaded: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** This property is only valid when [`IfFeederEnabled`](/_articles/info/api/WebTwain_Acquire.md#iffeederenabled) and [`IfPaperDetectable`](/_articles/info/api/WebTwain_Acquire.md#ifpaperdetectable) are `true`. --- ## IfPaperDetectable Return whether or not the Source has a paper sensor that can detect pages on the ADF or flatbed. **Syntax** ```typescript readonly IfPaperDetectable: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** Check this property after calling [`OpenSource()`](#opensource). --- ## IfShowIndicator Return or set whether or not the data source displays a progress indicator during acquisition and transfer. **Syntax** ```typescript IfShowIndicator: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** This property works only when `IfShowUI` is set to `false`. The indicator will only be hidden when **both** [`IfShowUI`](#ifshowui) and [`IfShowIndicator`](#ifshowindicator) are `false` . --- ## IfUIControllable Return whether or not the data source supports acquisitions with the UI (User Interface) disabled. **Syntax** ```typescript readonly IfUIControllable: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** Check this property after calling [`OpenSource()`](#opensource). --- ## IfUseTwainDSM Return or set whether or not to use the new TWAIN DSM (Data Source Manager) for acquisitions. The new TWAIN DSM is a DLL called `TWAINDSM.dll` while the default/old DSM is called `twain_32.dll`. **Syntax** ```typescript IfUseTwainDSM: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** This property should be set before calling or setting any TWAIN-related methods or properties. --- ## ImageLayoutFrameBottom Return the value of the bottom edge of the current image frame, with distance measured in `Unit` (defaults to inches). **Syntax** ```typescript readonly ImageLayoutFrameBottom: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
all versions all versions all versions all versions
--- ## ImageLayoutFrameLeft Return the value of the left edge of the current image frame, with distance measured in `Unit` (defaults to inches). **Syntax** ```typescript readonly ImageLayoutFrameLeft: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
all versions all versions all versions all versions
--- ## ImageLayoutFrameNumber Return the frame number of the current image. **Syntax** ```typescript readonly ImageLayoutFrameNumber: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
all versions all versions all versions all versions
**Usage Notes** Usually a chronological index of the acquired frames, these frames are related to one another in some way. Usually, they were acquired from the same page. The source assigns these values. The initial value is 1. The value resets upon acquiring a new image. `ImageLayoutFrameNumber` property, along with other properties about the current image information, is valid only in the [`OnPreTransfer`](/_articles/info/api/WebTwain_Acquire.md#onpretransfer) and [`OnPostTransfer`](/_articles/info/api/WebTwain_Acquire.md#onposttransfer) events. The frame information here only applies to the current frame. To get information about all frames to be transferred in an acquire session, please use capability negotiation. In this case, the capability is `ICAP_FRAMES` (4372). --- ## ImageLayoutFrameRight Return the value of the right edge of the current image frame, with distance measured in `Unit` (defaults to inches). **Syntax** ```typescript readonly ImageLayoutFrameRight: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
all versions all versions all versions all versions
--- ## ImageLayoutFrameTop Return the value of the top edge of the current image frame, with distance measured in `Unit` (defaults to inches). **Syntax** ```typescript readonly ImageLayoutFrameTop: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
all versions all versions all versions all versions
--- ## ImageLayoutDocumentNumber Return the document number of the current image. **Syntax** ```typescript readonly ImageLayoutDocumentNumber: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
all versions all versions all versions all versions
--- ## ImageLayoutPageNumber Return the page number of the current image. **Syntax** ```typescript readonly ImageLayoutPageNumber: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
all versions all versions all versions all versions
--- ## ImageBitsPerPixel Return the bit depth of the current image. **Syntax** ```typescript readonly ImageBitsPerPixel: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
all versions all versions all versions all versions
--- ## ImageLength Return the length of the current image. **Syntax** ```typescript readonly ImageLength: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
all versions all versions all versions all versions
--- ## ImageWidth Return the width of the current image. **Syntax** ```typescript readonly ImageWidth: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
all versions all versions all versions all versions
--- ## ImageXResolution Return the horizontal resolution of the current image. **Syntax** ```typescript readonly ImageXResolution: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
all versions all versions all versions all versions
--- ## ImageYResolution Return the vertical resolution of the current image. **Syntax** ```typescript readonly ImageYResolution: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
all versions all versions all versions all versions
--- ## ImagePixelType Return the pixel type of the current image. **Syntax** ```typescript readonly ImagePixelType: Dynamsoft.DWT.EnumDWT_PixelType | number; ``` Please refer to [`EnumDWT_PixelType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_pixeltype). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
all versions all versions all versions all versions
--- ## MagData Return magnetic data if the data source supports magnetic data recognition. **Syntax** ```typescript readonly MagData: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v8.0+ v8.0+ v8.0+ v8.0+
--- ## MagType Return the type of the magnetic data if the data source supports magnetic data recognition. **Syntax** ```typescript readonly MagType: Dynamsoft.DWT.EnumDWT_MagType | number; ``` Please refer to [`EnumDWT_MagType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_magtype). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v8.0+ v8.0+ v8.0+ v8.0+
**Usage notes** The values returned by these APIs are expressed in the measurement unit defined by the [`Unit`](#unit) property, which is `inches` by default. These APIs are only valid in the callbacks for the events [`OnPreTransfer`](#onpretransfer) and [`OnPostTransfer`](#onposttransfer). [`MagData`](#magdata) and [`MagType`](#magtype) are device-dependent. Check the user manual of the device to see if magnetic data recognition is supported. --- ## PendingXfers Return the number of transfers the data source is ready to supply upon demand. **Syntax** ```typescript readonly PendingXfers: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** This property is only valid in the event [`OnPostTransfer`](#onposttransfer). The data source returns -1 if it is not sure how many transfers are pending. This normally occurs when the ADF (Automatic Document Feeder) is used. --- ## PixelFlavor Return or set the pixel flavor used for acquiring images. **Syntax** ```typescript PixelFlavor: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
**Usage notes** Available values: - 0: Chocolate. Zero pixel represents darkest shade - 1: Vanilla. Zero pixel represents lightest shade. --- ## TransferMode Return or set the data source's transfer mode. **Syntax** ```typescript TransferMode: Dynamsoft.DWT.EnumDWT_TransferMode | number; ``` Please refer to [`EnumDWT_TransferMode`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_transfermode). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ not supported v11.0+ not supported
**Usage notes** Allowed values are - `TWSX_NATIVE | 0`: The default mode - this mode transfers the whole image in a single memory block. - `TWSX_FILE | 1`: Transfer the image to a specified file on the disk directly. This mode is ideal when transferring large images that may encounter memory limits with Native mode. Check out [`SetFileXferInfo`](#setfilexferinfo) for more information. - `TWSX_MEMORY | 2`: Transfer the image in multiple memory blocks. This mode is ideal for transferring very large images or a large number of images quickly. `TWSX_NATIVE` and `TWSX_MEMORY` are required by all TWAIN data sources while `TWSX_FILE` is not. Therefore, make sure the data source supports `TWSX_FILE` before you use it. | Supported values | Windows(TWAIN) | Windows(WIA) | macOS(TWAIN) | macOS(ICA) | Linux(SANE) | | ------------------ | -------------- | ------------ | ------------ | ---------- | ----------- | | `TWSX_NATIVE` | ✔ | ✖ | ✖ | ✔ | ✔ | | `TWSX_MEMORY` | ✔ | ✔ | ✔ | ✖ | ✖ | | `TWSX_FILE` | ✔ | ✔ | ✖ | ✔ | ✖ | --- ## Unit Return or set the unit of measurement for all quantities. This setting only applies to TWAIN/ICA (hardware) -related operations. **Syntax** ```typescript Unit: Dynamsoft.DWT.EnumDWT_UnitType | number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ not supported
**Usage notes** Allowed values are | Label | Value | Description | | :--------------- | :---- | :-------------- | | TWUN_INCHES | 0 | inches(Default) | | TWUN_CENTIMETERS | 1 | centimeters | | TWUN_PICAS | 2 | picas | | TWUN_POINTS | 3 | points | | TWUN_TWIPS | 4 | twips | | TWUN_PIXELS | 5 | pixels | | TWUN_MILLIMETERS | 6 | millimeters | --- ## XferCount Return or set the number of images the web application is willing to accept for each scan. **Syntax** ```typescript XferCount: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported v12.1+
**Usage notes** Allowed values are between -1 and 215, where -1 indicate multiple images. --- ## OnPostAllTransfers This event triggers when all page(s) have been scanned and transferred. **Syntax** ```typescript RegisterEvent("OnPostAllTransfers", function () {}); ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** This event triggers after all pages in the document feeder have been scanned and transferred. This event is convenient for uploading the images, detecting barcodes, discarding blank pages, etc. **Example** ```javascript DWTObject.RegisterEvent("OnPostAllTransfers", function () { console.log("All images are transferred."); }); ``` --- ## OnPostTransfer This event triggers after each page has been scanned and transferred. **Syntax** ```typescript RegisterEvent("OnPostTransfer", function () {}); ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Example** ```javascript DWTObject.RegisterEvent("OnPostTransfer", function () { console.log("An image has been scanned"); }); ``` --- ## OnPostTransferAsync This event triggers after each page has been scanned and transferred. This is the asynchronous counterpart to the synchronous event [`OnPostTransfer`](#onposttransfer). **Syntax** ```typescript RegisterEvent("OnPostTransferAsync", function (outputInfo: OutputInfo) {}); ``` **Parameters** `outputInfo`: Detailed information about the image that just got transferred. Please refer to [`OutputInfo`](/_articles/info/api/interfaces.md#outputinfo). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v15.0+ v15.1+ v15.1+ v15.1+
**Example** ```javascript DWTObject.RegisterEvent("OnPostTransferAsync", function (outputInfo) { console.log("The image ID is " + outputInfo.imageId); }); ``` --- ## OnPreAllTransfers This event triggers when all images are scanned and ready to be transferred. **Syntax** ```typescript RegisterEvent("OnPreAllTransfers", function () {}); ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** Multiple transfers may occur in two cases: - Multiple images are scanned through the ADF(Auto Document Feeder) - Multiple frames are scanned on one single page Multiple transfers trigger the [`OnPreTransfer`](#onpretransfer) event multiple times but only triggers `OnPreAllTransfers` once. In the callback function of this event, you can call [`CancelAllPendingTransfers()`](#cancelallpendingtransfers) to cancel all transfers. --- ## OnPreTransfer This event triggers when a page has been scanned and is ready to be transferred. **Syntax** ```typescript RegisterEvent('OnPreTransfer',function(){...}); ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** In the callback function of this event, you can: - Check [`PendingXFERs`](#pendingxfers) for the number of pending transfers. - Get information about the transferred image, such as [`ImageLayoutDocumentNumber`](#imagelayoutdocumentnumber), [`ImageLayoutFrameLeft`](#imagelayoutframeleft), [`ImageLayoutFrameTop`](#imagelayoutframetop), [`ImageLayoutFrameRight`](#imagelayoutframeright), [`ImageLayoutFrameBottom`](#imagelayoutframebottom), [`ImageLayoutPageNumber`](#imagelayoutpagenumber), [`ImageLayoutFrameNumber`](#imagelayoutframenumber), etc. - Call [`CancelAllPendingTransfers()`](#cancelallpendingtransfers) to cancel the rest of the transfers. --- ## OnSourceUIClose This event triggers when the user interface of the data source is closed manually by the user. **Syntax** ```typescript RegisterEvent("OnSourceUIClose", function () {}); ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ not supported not supported
--- ## getCapabilities() Get detailed information about specified or all capabilities of the current data source. **Syntax** ```typescript getCapabilities( capabilities: Dynamsoft.DWT.EnumDWT_Cap[] | number[], successCallback: (capabilityDetails: CapabilityDetails[]) => void, failureCallback: (errorCode: number, errorString: string) => void ): void; getCapabilities( successCallback: (capabilityDetails: CapabilityDetails[]) => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `capabilities`: Specifies the capabilities to query. Please refer to [`Dynamsoft.DWT.EnumDWT_Cap`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_cap). `successCallback`: A callback function that is executed if the request succeeds. - `capabilityDetails`: Detailed information about the specified capabilities. Please refer to [`CapabilityDetails`](/_articles/info/api/interfaces.md#capabilitydetails). `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows/TWAIN) H5(Windows/WIA) H5(macOS/TWAIN) H5(macOS/ICA) H5(macOS/eSCL) H5(Linux/SANE)
v16.0+ v18.2+ v16.0+ v16.0+ v18.2+ not supported
--- ## setCapabilities() Set the value of one or more capabilities. **Syntax** ```typescript setCapabilities( capabilities: Capabilities, successCallback: (capabilities: Capabilities) => void, failureCallback: (capabilities: Capabilities) => void ): boolean; ``` **Parameters** `capabilities`: An object that contains capability values to be set. `successCallback`: A callback function that is executed if the request succeeds. - `capabilities`: The capabilities to set. `failureCallback`: A callback function that is executed if the request fails. - `capabilities`: The capabilities to set. Please refer to [`Capabilities`](/_articles/info/api/interfaces.md#capabilities). **Availability**
H5(Windows/TWAIN) H5(Windows/WIA) H5(macOS/TWAIN) H5(macOS/ICA) H5(macOS/eSCL) H5(Linux/SANE)
v16.0+ v18.2+ v16.0+ v16.0+ v18.2+ not supported
**Usage notes** For simplicity, Dynamsoft designed the API with a simplified parameter `Capabilities` which only requires the minimum information to set a capability: a number to specify the capability and a value to set the capability to. DWT takes care of container type setting, value type setting as well as data validation, all behind the scene. Take note of the **overall** `exception` parameter and the **individual** `exception` parameter for each capability. If the overall parameter is set to `fail`, the setting aborts upon encountering the first exception raised while setting any of the capabilities. If the overall parameter is set to `fail`, the API carries on setting the next capability upon encountering a exception setting a previous capability. The individual `exception` argument is optional but takes precedence if set. In other words, you can set the overall `exception` to `ignore` and then set the individual one to `fail` for critical capabilities. This way, you get notified if these critical capabilities fail to be set, and ignore failing to set less important capabilities. **Example** ```javascript DWTObject.SelectSourceByIndex(0); DWTObject.IfShowUI = false; DWTObject.OpenSource(); DWTObject.setCapabilities( { exception: "ignore", capabilities: [ { capability: Dynamsoft.DWT.EnumDWT_Cap.ICAP_CONTRAST, // your own capability curValue: 500, // your own curValue }, { capability: Dynamsoft.DWT.EnumDWT_Cap.CAP_PRINTERSTRING, // your own capability curValue: "abc", // your own curValue exception: "fail", }, { capability: Dynamsoft.DWT.EnumDWT_Cap.ICAP_PIXELTYPE, // your own capability curValue: 0, // your own curValue }, ], }, function (successData) { DWTObject.AcquireImage( function () { DWTObject.CloseSource(); }, function () { DWTObject.CloseSource(); console.log(DWTObject.ErrorString); } ); }, function (errorData) { console.error(errorData); DWTObject.AcquireImage( function () { DWTObject.CloseSource(); }, function () { DWTObject.CloseSource(); console.log(DWTObject.ErrorString); } ); } ); ``` --- ## GetDevicesAsync() Return all available devices (scanners, eSCL scanners, etc.). Optionally, only return devices of a specified type. **Syntax** ```typescript GetDevicesAsync(deviceType?: Dynamsoft.DWT.EnumDWT_DeviceType | number, refresh?:boolean): Promise; ``` **Parameters** `deviceType`: The device type. Please refer to [`EnumDWT_DeviceType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_devicetype). `refresh`: Default value is `false`. **Arguments** `Device`: Please refer to [`Device`](/_articles/info/api/interfaces.md#device). **Example** ```javascript DWTObject.GetDevicesAsync().then((deviceList)=>{ return DWTObject.SelectDeviceAsync(deviceList[0]) //Select the first device }).then(()=>{ return DWTObject.AcquireImageAsync({ IfCloseSourceAfterAcquire: true, }) }).catch((e)=>{ console.error(e) }) ``` **Availability**
H5(Windows/TWAIN) H5(Windows/WIA) H5(macOS/TWAIN) H5(macOS/ICA) H5(macOS/eSCL) H5(Linux/SANE)
v18.0+ v18.2+ v18.0+ v18.0+ v18.2+ v18.0+
--- ## SelectDeviceAsync() Select the device to be used for scanning. **Syntax** ```typescript SelectDeviceAsync(device: Device): Promise< boolean>; ``` **Example** ```javascript DWTObject.GetDevicesAsync().then((deviceList)=>{ return DWTObject.SelectDeviceAsync(deviceList[0]) //Select the first device }).then(()=>{ return DWTObject.AcquireImageAsync({ IfCloseSourceAfterAcquire: true, }) }).catch((e)=>{ console.error(e) }) ``` **Parameters** `device`: the device object. Please refer to [`Device`](/_articles/info/api/interfaces.md#device). **Availability**
H5(Windows/TWAIN) H5(Windows/WIA) H5(macOS/TWAIN) H5(macOS/ICA) H5(macOS/eSCL) H5(Linux/SANE)
v18.0+ v18.2+ v18.0+ v18.0+ v18.2+ v18.0+
--- ## AcquireImageAsync() Request a scan, then store to the image buffer of the WebTwain instance upon completion of the scan. By default, the scans are displayed from the `dwtcontrolContainer` container. **Syntax** ```typescript AcquireImageAsync(deviceConfiguration?: DeviceConfiguration): Promise< boolean>; ``` **Parameters** `deviceConfiguration`: The device configuration. Please refer to [`DeviceConfiguration`](/_articles/info/api/interfaces.md#deviceconfiguration). **Availability**
H5(Windows/TWAIN) H5(Windows/WIA) H5(macOS/TWAIN) H5(macOS/ICA) H5(macOS/eSCL) H5(Linux/SANE)
v18.0+ v18.2+ v18.0+ v18.0+ v18.2+ v18.0+
**Example** ```javascript DWTObject.GetDevicesAsync().then((deviceList)=>{ return DWTObject.SelectDeviceAsync(deviceList[0]) //Select the first device }).then(()=>{ return DWTObject.AcquireImageAsync({ IfCloseSourceAfterAcquire: true, }) }).catch((e)=>{ console.error(e) }) ```
--- title: Dynamic Web TWAIN SDK API Reference - Buffer APIs description: Dynamic Web TWAIN SDK Documentation API Reference Buffer APIs Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Buffer.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/WebTwain_Buffer.md --- # {WebTwainObject} Buffer Manage The properties and methods on this page live in the namespace {WebTwainObject}. {WebTwainObject} denotes the `WebTwain` instance. Learn about [how to create a web twain object](/_articles/extended-usage/advanced-initialization.md#instantiating-webtwain-without-onwebtwainready). **Methods** | [`ClearImageTags()`](#clearimagetags) | [`RenameTag()`](#renametag) | [`RemoveTag()`](#removetag) | [`GetTagList()`](#gettaglist) | | [`FilterImagesByTag()`](#filterimagesbytag) | [`ClearFilter()`](#clearfilter) | [`SetDefaultTag()`](#setdefaulttag) | [`TagImages()`](#tagimages) | | [`GetImageBitDepth()`](#getimagebitdepth) | [`GetImageSize()`](#getimagesize) | [`GetImageSizeWithSpecifiedType()`](#getimagesizewithspecifiedtype) | [`GetSelectedImagesSize()`](#getselectedimagessize) | | [`GetImageHeight()`](#getimageheight) | [`GetImageWidth()`](#getimagewidth) | [`GetImagePartURL()`](#getimageparturl) | [`GetImageURL()`](#getimageurl) | | [`GetImageXResolution()`](#getimagexresolution) | [`GetImageYResolution()`](#getimageyresolution) | [`GetSkewAngle()`](#getskewangle) | [`GetSkewAngleEx()`](#getskewangleex) | | [`ImageIDToIndex()`](#imageidtoindex) | [`IndexToImageID()`](#indextoimageid) | [`IsBlankImage()`](#isblankimage) | [`IsBlankImageExpress()`](#isblankimageexpress) | | [`SelectAllImages()`](#selectallimages) | [`MoveImage()`](#moveimage) | [`SwitchImage()`](#switchimage) | [`RemoveImage()`](#removeimage) | | [`IsBlankImageAsync()`](#isblankimageasync) | [`RemoveAllImages()`](#removeallimages) | [`RemoveAllSelectedImages()`](#removeallselectedimages) | [`SelectImages()`](#selectimages) | | [`GetTagListByIndex()`](#gettaglistbyindex) | [`CreateDocument()`](#createdocument) | [`OpenDocument()`](#opendocument) | [`GetCurrentDocumentName()`](#getcurrentdocumentname) | | [`RenameDocument()`](#renamedocument) | [`RemoveDocument()`](#removedocument) | [`GetDocumentInfoList()`](#getdocumentinfolist) | [`CopyToDocumentAsync()`](#copytodocumentasync) | | [`MoveToDocumentAsync()`](#movetodocumentasync) | [`updateImage()`](#updateimage) | | | **Properties** | [`BlankImageCurrentStdDev`](#blankimagecurrentstddev) | [`BlankImageMaxStdDev`](#blankimagemaxstddev) | [`BlankImageThreshold`](#blankimagethreshold) | [`BufferMemoryLimit`](#buffermemorylimit) | | [`CurrentImageIndexInBuffer`](#currentimageindexinbuffer) | [`HowManyImagesInBuffer`](#howmanyimagesinbuffer) | [`IfAllowLocalCache`](#ifallowlocalcache) | [`SelectedImagesIndices`](#selectedimagesindices) | | [`MaxImagesInBuffer`](#maximagesinbuffer) | | | | **Events** | [`OnBufferChanged`](#onbufferchanged) | [`OnBitmapChanged`](#onbitmapchanged) | [`OnIndexChangeDragDropDone`](#onindexchangedragdropdone) | | [`OnTopImageInTheViewChanged`](#ontopimageintheviewchanged) | [`OnDiskExceedLimit`](#ondiskexceedlimit) | | --- ## IndexToImageID() Return the imageId of an image specified by the index. **Syntax** ```typescript IndexToImageID(index: number): string; ``` **Parameters** `index`: The index of the image. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v15.0+ v15.0+ v15.0+ v15.0+
--- ## ImageIDToIndex() Return the index of an image specified by the imageId. **Syntax** ```typescript ImageIDToIndex(imageId: string): number; ``` **Parameters** `imageId`: The imageId of the image. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v15.0+ v15.0+ v15.0+ v15.0+
**Usage notes** An `imageId` is unique and won't change. It's a better way to keep track of an image than the `index` which changes easily. --- ## RenameTag() Rename a tag. **Syntax** ```typescript RenameTag(oldTag:string, newTag:string): boolean; ``` **Parameters** `oldTag`: Specify the tag to change. `newTag`: Specify the new tag name. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
--- ## RemoveTag() Remove the specified tag from one or more images(if not specified, remove from all). **Syntax** ```typescript RemoveTag(tagName: string, indices?: number[]):boolean ``` **Parameters** `tagName`: Specify the tag to be removed. `indices`: Specify the index. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v17.0+ v17.0+ v17.0+ v17.0+
**Usage Notes** If the index is not specified, the tag will be removed from _all images_. If the index is specified, the tag will be removed from the specified image(s). --- ## GetTagList() Return the status of all current tags. **Syntax** ```typescript GetTagList(): TagInfo[]; ``` **Arguments** `TagInfo`: Please refer to [TagInfo](/_articles/info/api/interfaces.md#taginfo). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v17.0+ v17.0+ v17.0+ v17.0+
--- ## ClearImageTags() Remove all tags from the specified image. **Syntax** ```typescript ClearImageTags(index: number): boolean; ``` **Parameters** `index`: Specify the image. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v15.2+ v15.2+ v15.2+ v15.2+
--- ## FilterImagesByTag() Filter images by the specified tag. **Syntax** ```typescript FilterImagesByTag(tag: string): boolean; ``` **Parameters** `tag`: The tag used as the filter. If nothing or an empty string is used, the filter is cleared. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v15.2+ v15.2+ v15.2+ v15.2+
--- ## ClearFilter() Stop filtering images by tag. **Syntax** ```typescript ClearFilter(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
--- ## SetDefaultTag() Set a default tag for newly incoming images. **Syntax** ```typescript SetDefaultTag(tag: string): boolean; ``` **Parameters** `tag`: Specifies the tag. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v15.2+ v15.2+ v15.2+ v15.2+
--- ## TagImages() Add a tag to specified images. **Syntax** ```typescript TagImages(indices: number[], tag: string): boolean; ``` **Parameters** `indices`: Specifies images to be tagged. `tag`: Specify the tag. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v15.2+ v15.2+ v15.2+ v15.2+
--- ## GetImageBitDepth() Return the pixel bit depth of the specified image. **Syntax** ```typescript GetImageBitDepth(index: number): number; ``` **Parameters** `index`: Specify the image. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v6.2+ v6.2+ v6.2+ v6.2+
--- ## GetImageHeight() Return the height (in pixels) of the specified image. **Syntax** ```typescript GetImageHeight(index: number): number; ``` **Parameters** `index`: Specify the image. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v6.2+ v6.2+ v6.2+ v6.2+
--- ## GetImageWidth() Return the width (in pixels) of the specified image. **Syntax** ```typescript GetImageWidth(index: number): number; ``` **Parameters** `index`: Specify the image. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v6.2+ v6.2+ v6.2+ v6.2+
--- ## GetImageXResolution() Return the horizontal resolution of the specified image. **Syntax** ```typescript GetImageXResolution(index: number): number; ``` **Parameters** `index`: Specify the image. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v8.0+ v8.0+ v8.0+ v8.0+
--- ## GetImageYResolution() Return the vertical resolution of the specified image. **Syntax** ```typescript GetImageYResolution(index: number): number; ``` **Parameters** `index`: Specify the image. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v8.0+ v8.0+ v8.0+ v8.0+
--- ## GetSkewAngle() Return the skew angle of the specified image. **Syntax** ```typescript GetSkewAngle( index: number ): number; // Call this API asynchronously to avoid blocking the browser's main thread` GetSkewAngle( index: number, successCallback: (angle: number) => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `index`: Specify the image. `successCallback`: A callback function that is executed if the request succeeds. - `angle`: The skew angle. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v9.0+ v9.0+ v9.0+ v9.0+
--- ## GetSkewAngleEx() Return the skew angle of the specified rectangle on the specified image. **Syntax** ```typescript GetSkewAngleEx( index: number, left: number, top: number, right: number, bottom: number ): number; // Call this API asynchronously to avoid blocking the browser's main thread GetSkewAngleEx( index: number, left: number, top: number, right: number, bottom: number, successCallback: (angle: number) => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `index`: Specify the image. `left`: The x-coordinate of the upper-left corner of the rectangle. `top`: The y-coordinate of the upper-left corner of the rectangle. `right`: The x-coordinate of the lower-right corner of the rectangle. `bottom`: The y-coordinate of the lower-right corner of the rectangle. `successCallback`: A callback function that is executed if the request succeeds. - `angle`: The skew angle. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v9.0+ v9.0+ v9.0+ v9.0+
**Usage notes** After you get the skew angle of an image, you can rotate it with the method [`Rotate()`](/_articles/info/api/WebTwain_Edit.md#rotate) to perform de-skewing. --- ## GetImageSize() Calculate the size in bytes of the specified image assuming it's resized to the given dimensions. **Syntax** ```typescript GetImageSize(index: number, width: number, height: number): number; ``` **Parameters** `index`: Specify the image. `width`: Specify the width. `height`: Specify the height. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
all versions all versions all versions all versions
--- ## GetImageSizeWithSpecifiedType() Calculate the size in bytes of the specified image assuming an expected file type. **Syntax** ```typescript GetImageSizeWithSpecifiedType(index: number, type: Dynamsoft.DWT.EnumDWT_ImageType | number): number; ``` **Parameters** `index`: Specify the image. `type`: Specify the expected file type. Please refer to [`Dynamsoft.DWT.EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
all versions all versions all versions all versions
--- ## GetSelectedImagesSize() Calculate the size in bytes of all selected images assuming an expected file type. **Syntax** ```typescript GetSelectedImagesSize(type: Dynamsoft.DWT.EnumDWT_ImageType | number): number; ``` **Parameters** `type`: Specify the expected file type. Please refer to [`Dynamsoft.DWT.EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v6.0+ v6.0+ v6.0+ v6.0+
**Usage notes** If the calculation fails, -1 is returned. --- ## GetImagePartURL() Return the internal URL of the specified image. **Syntax** ```typescript GetImagePartURL(index: number): string; GetImagePartURL(index: number, width: number, height: number): string; ``` **Parameters** `index`: Specify the image. `width`: The width of the image (>150 px). `height`: The height of the image (>150 px). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v13.0+ v13.0+ v13.0+ v13.0+
**Usage notes** The returned URL looks like this: 'dwt://dwt_trial_13000404/img?id=306159652&index=0&t=1502184632022'. You get the original size (a, b) of the image in PNG format - if either width or height is not set or - if either width or height is set to -1 or - if either width or height is larger than the original width or height Otherwise, you get the image with the specified width (x) or height (y) while keeping the same aspect ratio: if x/a < y/b, return the image (x, b\*x/a); if x/a > y/b, return the image (a\*y/b, y) --- ## GetImageURL() Return the direct URL of the specified image. **Syntax** ```typescript GetImageURL(index: number): string; GetImageURL(index: number, width: number, height: number): string; ``` **Parameters** `index`: Specify the image. `width`: The width of the image (>150 px). `height`: The height of the image (>150 px). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v12.0+ v12.0+ v12.0+ v12.1+
**Usage notes** The returned URL looks like this: "https://127.0.0.1:18623/dwt/dwt_17110818/img?id=795151779&index=1&t=1640936181588". You get the original size (a, b) of the image in PNG format - if either width or height is not set or - if either width or height is set to -1 or - if either width or height is larger than the original width or height Otherwise, you get the image with the specified width (x) or height (y) while keeping the same aspect ratio: if x/a < y/b, return the image (x, b\*x/a); if x/a > y/b, return the image (a\*y/b, y) --- ## SelectAllImages() Select all images and return the indices. Viewer will be scrolled to the last image. **Syntax** ```typescript SelectAllImages(): number[]; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v15.3+ v15.3+ v15.3+ v15.3+
--- ## SelectImages() Select the specified images. **Syntax** ```typescript SelectImages(indices: number[]): boolean; ``` **Parameters** `indices`: Specify one or multiple images **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.0+ v16.0+ v16.0+ v16.0+
--- ## MoveImage() Change the position of an image in the buffer. **Syntax** ```typescript MoveImage(from: number, to: number): boolean; ``` **Parameters** `from`: Specify the original position by index. `to`: Specify the target position by index. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## SwitchImage() Exchange the positions of two images. **Syntax** ```typescript SwitchImage(index1: number, index2: number): boolean; ``` **Parameters** `index1`: Specify the 1st image. `index2`: Specify the 2nd image. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## RemoveImage() Remove the specified image. **Syntax** ```typescript RemoveImage(index: number): boolean; ``` **Parameters** `index`: Specify the image. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## RemoveAllImages() Remove all images. **Syntax** ```typescript RemoveAllImages(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## RemoveAllSelectedImages() Remove all selected images. **Syntax** ```typescript RemoveAllSelectedImages(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## CurrentImageIndexInBuffer Return the index of the current image in the buffer or set the image specified by index as the current image. **Syntax** ```typescript CurrentImageIndexInBuffer: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v4.0+ v4.0+ v4.0+ v4.0+
--- ## HowManyImagesInBuffer Return how many images are held in the buffer **Syntax** ```typescript readonly HowManyImagesInBuffer: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v4.0+ v4.0+ v4.0+ v4.0+
--- ## MaxImagesInBuffer Return or set how many images can be held in the buffer. **Syntax** ```typescript MaxImagesInBuffer: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v4.0+ v4.0+ v4.0+ v4.0+
**Usage notes** When acquiring images and the number of images goes beyond the value set to `MaxImagesInBuffer`, new images will replace old images starting from the 1st one. --- ## SelectedImagesIndices Return the indices of the selected images. **Syntax** ```typescript readonly SelectedImagesIndices: number[]; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.0+ v16.0+ v16.0+ v16.0+
--- ## SelectionRectAspectRatio Specify a aspect ratio to be used when selecting a rectangle on an image. **Syntax** ```typescript SelectionRectAspectRatio: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## BlankImageCurrentStdDev Return the deviation of the pixels of the image on which black image detection was last called. This property is only valid after calling [`IsBlankImageExpress()`](/_articles/info/api/WebTwain_Buffer.md#isblankimageexpress) or [`IsBlankImage()`](/_articles/info/api/WebTwain_Buffer.md#isblankimage). `BlankImageCurrentStdDev` **does not apply to [`IsBlankImageAsync()`](/_articles/info/api/WebTwain_Buffer.md#isblankimageasync)** - it uses its own detection parameters. **Syntax** ```typescript readonly BlankImageCurrentStdDev: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v8.0+ v8.0+ v8.0+ v8.0+
--- ## BlankImageMaxStdDev Return or set the maximum deviation of the pixels in an image which is used to determine whether the image is blank. The value of this property applies on subsequent calls of [`IsBlankImageExpress()`](/_articles/info/api/WebTwain_Buffer.md#isblankimageexpress) or [`IsBlankImage()`](/_articles/info/api/WebTwain_Buffer.md#isblankimage). `BlankImageCurrentStdDev` **does not apply to [`IsBlankImageAsync()`](/_articles/info/api/WebTwain_Buffer.md#isblankimageasync)** - it uses its own detection parameters. **Syntax** ```typescript BlankImageMaxStdDev: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.2+ v5.2+ v5.2+ v5.2+
**Usage notes** [0, 100] is the interval of allowed values, inclusive. For example, a value of 0 detects markings on any image with more than one color. The default value is 1. --- ## BlankImageThreshold Return or set the dividing line between black and white for subsequent calls to [`IsBlankImageExpress()`](/_articles/info/api/WebTwain_Buffer.md#isblankimageexpress) or [`IsBlankImage()`](/_articles/info/api/WebTwain_Buffer.md#isblankimage). `BlankImageCurrentStdDev` **does not apply to [`IsBlankImageAsync()`](/_articles/info/api/WebTwain_Buffer.md#isblankimageasync)** - it uses its own detection parameters. **Syntax** ```typescript BlankImageThreshold: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.2+ v5.2+ v5.2+ v5.2+
**Usage notes** [0, 255] is the interval of allowed values, inclusive. The default value is 128. --- ## BufferMemoryLimit Return or set how much physical memory is allowed for storing images currently loaded in Dynamic Web TWAIN. Once the limit is reached, images will be cached on the hard disk. **Syntax** ```typescript BufferMemoryLimit: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.1+ v10.1+ v11.0+ v12.1+
**Usage notes** Set this property only when you have a very small physical memory (< 2GB) or a very big one (>4GB). The more memory is allowed, the better the performance will be. The default value is set to 800 (MB), anything beyond 800MB gets compressed, encrypted and cached on the local disk. All cached data is encrypted and can only be read by Dynamic Web TWAIN and it will be destroyed when it is no longer used. --- ## IsBlankImage() Check whether the specified image is blank based on the standard deviation in pixels. **Syntax** ```typescript IsBlankImage(index: number): boolean; ``` **Parameters** `index`: Specify the image. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.2+ v5.2+ v5.2+ v5.2+
--- **Usage Notes** See also: - [`BlankImageCurrentStdDev()`](/_articles/info/api/WebTwain_Buffer.md#blankimagecurrentstddev) - [`BlankImageMaxStdDev()`](/_articles/info/api/WebTwain_Buffer.md#blankimagemaxstddev) - [`BlankImageThreshold()`](/_articles/info/api/WebTwain_Buffer.md#blankimagethreshold) ## IsBlankImageAsync() Check whether the specified image is blank. This API employs a different algorithm than the one used in [`IsBlankImage()`](/_articles/info/api/WebTwain_Buffer.md#isblankimage) and [`IsBlankImageExpress()`](/_articles/info/api/WebTwain_Buffer.md#isblankimageexpress) and is the recommended blank image detection method. You can set `minBlockHeight` and `maxBlockHeight` to the expected text pixel height. In most cases, these values do not require adjustment. > [!NOTE] > `IsBlankImageAsync()` **is not** related to [`BlankImageCurrentStdDev()`](/_articles/info/api/WebTwain_Buffer.md#blankimagecurrentstddev), [`BlankImageMaxStdDev()`](/_articles/info/api/WebTwain_Buffer.md#blankimagemaxstddev), or [`BlankImageThreshold()`](/_articles/info/api/WebTwain_Buffer.md#blankimagethreshold). **Syntax** ```typescript IsBlankImageAsync(index: number, options?: { minBlockHeight?: number, maxBlockHeight?: number, } ): Promise ; ``` **Parameters** `index`: Specify the image in buffer to be analyzed. `minBlockHeight`: Minimum height of the blocks to be detected. Default value: 20. `maxBlockHeight`: Maximum height of the blocks to be detected. Default value: 30. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.4+ v19.2+ v19.2+ v19.2+
--- ## IsBlankImageExpress() Check whether the specified image is blank based on the standard deviation in pixels. **Syntax** ```typescript IsBlankImageExpress(index: number): boolean; ``` **Parameters** `index`: Specify the image. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v10.0+ v10.0+
**Usage notes** [`IsBlankImage()`](/_articles/info/api/WebTwain_Buffer.md#isblankimage) is more accurate than [`IsBlankImageExpress()`](/_articles/info/api/WebTwain_Buffer.md#isblankimageexpress) but it works slower. [`BlankImageCurrentStdDev`](/_articles/info/api/WebTwain_Buffer.md#blankimagecurrentstddev) should be read after either [`IsBlankImage()`](/_articles/info/api/WebTwain_Buffer.md#isblankimage) or [`IsBlankImageExpress()`](/_articles/info/api/WebTwain_Buffer.md#isblankimageexpress). If you believe an image should be blank but [`IsBlankImage()`](/_articles/info/api/WebTwain_Buffer.md#isblankimage) or [`IsBlankImageExpress()`](/_articles/info/api/WebTwain_Buffer.md#isblankimageexpress) is returning `false`, you can read [`BlankImageCurrentStdDev`](/_articles/info/api/WebTwain_Buffer.md#blankimagecurrentstddev) for that image and then set a bigger value to [`BlankImageMaxStdDev`](/_articles/info/api/WebTwain_Buffer.md#blankimagemaxstddev). Both [`BlankImageCurrentStdDev`](/_articles/info/api/WebTwain_Buffer.md#blankimagecurrentstddev) and [`BlankImageMaxStdDev`](/_articles/info/api/WebTwain_Buffer.md#blankimagemaxstddev) range from 0 to 100. If the image is not blank and it is not black and white, [`IsBlankImage()`](/_articles/info/api/WebTwain_Buffer.md#isblankimage) or [`IsBlankImageExpress()`](/_articles/info/api/WebTwain_Buffer.md#isblankimageexpress) may return `true`. In that case, you can increase the [`BlankImageThreshold`](/_articles/info/api/WebTwain_Buffer.md#blankimagethreshold) value so that the image is not detected as blank. --- ## IfAllowLocalCache Return or set whether the feature of disk caching is enabled. **Syntax** ```typescript IfAllowLocalCache: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v11.0+ v12.1+
**Usage notes** The default value of `IfAllowLocalCache` is true. When the property is true, you can scan as many images as you want as long as you have a big enough disk. The default threshold is set to 800 (MB), anything beyond 800MB gets compressed, encrypted and cached on the local disk. If necessary, you can set the threshold using [`BufferMemoryLimit`](/_articles/info/api/WebTwain_Buffer.md#buffermemorylimit) for better performance. All cached data is encrypted and can only be read by Dynamic Web TWAIN and it will be destroyed when it is no longer used. --- ## OnBufferChanged An enhanced callback triggered when a change occurs in the buffer. **Syntax** ```typescript RegisterEvent('OnBufferChanged', function (bufferChangeInfo: BufferChangeInfo) {} ): boolean; ``` **Parameters** `bufferChangeInfo`: Details about the buffer change. Please refer to [`BufferChangeInfo`](/_articles/info/api/interfaces.md#bufferchangeinfo). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Usage notes** Action types include - `add`: New pages are added to the buffer. - `remove`: The existing pages are removed. - `modify`: The existing pages are modified. - `shift`: The existing pages are reordered or the selected pages are changed. - `filter`: The existing pages are filtered by a tag. --- ## OnBitmapChanged A built-in callback triggered when the current image in buffer is changed like flipped, cropped, rotated, etc. or a new image has been acquired. **Syntax** ```typescript RegisterEvent('OnBitmapChanged', function ( indices: number[], type: number, index: number ) {} ): boolean; ``` **Parameters** `indices`: Array of the changed index(indices). `type`: Operation type: - `1`: new image(s) added at the tail - `2`: image(s) inserted before the current index - `3`: image(s) deleted - `4`: image(s) modified `index`: Index of the current image. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v11.0+ v12.1+
**Example** ```javascript DWTObject.RegisterEvent("OnBitmapChanged", function (updatedIndices, operationType, currentIndex) { console.log(updatedIndices); }); ``` --- ## OnTopImageInTheViewChanged A built-in callback triggered when the top index currently displayed in the viewer changes. **Syntax** ```typescript RegisterEvent('OnTopImageInTheViewChanged', function (index: number) {} ): boolean; ``` **Parameters** `index`: Index of the current image. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.1+ v11.0+ v11.0+ v12.1+
**Usage notes** This API does not work if the view mode of the viewer is set to -1 by -1. --- ## OnIndexChangeDragDropDone A built-in callback triggered when images in the buffer are dragged to new positions. **Syntax** ```typescript RegisterEvent('OnIndexChangeDragDropDone', function (indexPairs: Pair[]) {} ): boolean; Pair: [from: number, to: number]; ``` **Parameters** `indexPairs`: The list of index changes. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v15.0+ v15.0+ v15.0+ v15.0+
--- ## GetTagListByIndex() Return the tag(s) of a specified image. **Syntax** ```typescript GetTagListByIndex(index: number):string[] ``` **Parameters** `index`: Index of the image. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v17.2+ v17.2+ v17.2+ v17.2+
**Example** ```javascript DWTObject.GetTagListByIndex(0); ``` --- ## CopyToDocumentAsync() Copy specified images to another document. **Syntax** ```typescript CopyToDocumentAsync(from: string, to: string): Promise; CopyToDocumentAsync(from: string, to: string, sourceIndices: number[]): Promise; CopyToDocumentAsync(from: string, to: string, targetIndex: number): Promise; CopyToDocumentAsync(from: string, to: string, sourceIndices: number[], targetIndex: number): Promise; ``` **Parameters** `from`: The source document name. `to`: The destination document name. `sourceIndices`: The indices of the images to be copied. `targetIndex`: The index at which the source images should be inserted into the new document. If not specified, the images will be appended to the destination document. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.4+ v18.4+ v18.4+ v18.4+
**Example** ```typescript DWTObject.CreateDocument("Document1"); DWTObject.CreateDocument("Document2"); DWTObject.OpenDocument("Document1"); await DWTObject.SelectSourceAsync(); await DWTObject.AcquireImageAsync({ //scan 5 Images IfCloseSourceAfterAcquire: true, }); await DWTObject.CopyToDocumentAsync("Document1", "Document2", [0, 1]); DWTObject.OpenDocument("Document2"); ``` --- ## CreateDocument() Create a document for the scanned image(s). **Syntax** ```typescript CreateDocument(documentName:string):boolean; ``` **Parameters** `documentName`: Specify the document name. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v17.2+ v17.2+ v17.2+ v17.2+
**Example** ```javascript //Save the scanned image(s) under 'Document1'. DWTObject.CreateDocument("Document1"); DWTObject.OpenDocument("Document1"); //Need to call OpenDocument after CreateDocument. DWTObject.AcquireImage(successCallback, failureCallback); function successCallback() { console.log("successful"); } function failureCallback(errorCode, errorString) { alert(errorString); } ``` --- ## MoveToDocumentAsync() Move specified images to another document. **Syntax** ```typescript MoveToDocumentAsync(from: string, to: string): Promise; MoveToDocumentAsync(from: string, to: string, sourceIndices: number[]): Promise; MoveToDocumentAsync(from: string, to: string, targetIndex: number): Promise; MoveToDocumentAsync(from: string, to: string, sourceIndices: number[], targetIndex: number): Promise; ``` **Parameters** `from`: The source document name. `to`: The destination document name. `sourceIndices`: The indices of the images to be moved. `targetIndex`: The index at which the source images should be inserted into the new document. If not specified, the images will be appended to the destination document. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.4+ v18.4+ v18.4+ v18.4+
**Example** ```typescript DWTObject.CreateDocument("Document1"); DWTObject.CreateDocument("Document2"); DWTObject.OpenDocument("Document1"); await DWTObject.SelectSourceAsync(); await DWTObject.AcquireImageAsync({ //scan 5 Images IfCloseSourceAfterAcquire: true, }); await DWTObject.MoveToDocumentAsync("Document1", "Document2", [0, 1]); DWTObject.OpenDocument("Document2"); ``` --- ## OpenDocument() Use the specified document for the scanned image(s) **Syntax** ```typescript OpenDocument(documentName:string):boolean; ``` **Parameters** `documentName`: Specify the document name. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v17.2+ v17.2+ v17.2+ v17.2+
**Example** ```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); } ``` --- ## GetCurrentDocumentName() Get the current document name. The default value is 'dynamsoft-default-document'. Scanned image(s) are saved in this document by default if no document name is created. **Syntax** ```typescript GetCurrentDocumentName():string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v17.2+ v17.2+ v17.2+ v17.2+
--- ## RenameDocument() Rename a document. **Syntax** ```typescript RenameDocument(oldDocumentName:string, newDocumentName:string):boolean; ``` **Parameters** `oldDocumentName`: Specify the old document name. `newDocumentName`: Specify the new document name. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v17.3+ v17.3+ v17.3+ v17.3+
--- ## RemoveDocument() Delete the specified document. **Syntax** ```typescript RemoveDocument(documentName:string):boolean; ``` **Parameters** `documentName`: Specify the document name. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v17.2+ v17.2+ v17.2+ v17.2+
--- ## GetDocumentInfoList() Get the list of all documents and their information. **Syntax** ```typescript GetDocumentInfoList(): DocumentInfo[]; ``` **Arguments** `DocumentInfo`: Please refer to [`DocumentInfo`](/_articles/info/api/interfaces.md#documentinfo). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v17.2+ v17.2+ v17.2+ v17.2+
--- ## updateImage() Update the specified image with a new image. **Syntax** ```typescript updateImage(imageId: string, blob: Blob): Promise ; ``` **Parameters** `imageId`: Specify the image to be updated by its image id. `blob`: The blob of the new image. Only support the blob which contains single image page. Multi-pages Tiff and PDF are not supported. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.5+ v18.5+ v18.5+ v18.5+
**Usage notes** Supported blob type: `image/jpeg`, `image/png`, `image/bmp`, `image/tiff`, `application/pdf`, `image/jpg`, `image/tif`. --- ## OnDiskExceedLimit A built-in callback triggered when disk cache exceeds the limit. **Syntax** ```typescript RegisterEvent('OnDiskExceedLimit', function () {} ): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.5+ v18.5+ v18.5+ v18.5+
**Usage notes** | System | Triggered when | | ----------- | -------------- | | Windows x86 | < 1.2GB | | Windows x64 | < 4GB | | macOS 32bit | < 1.2GB | | macOS 64bit | < 4GB | | Linux | < 4GB |
--- title: Dynamic Web TWAIN SDK API Reference - Edit APIs description: Dynamic Web TWAIN SDK Documentation API Reference Edit APIs Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Edit.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/WebTwain_Edit.md --- # {WebTwainObject} Edit The properties and methods on this page live in the namespace {WebTwainObject}. {WebTwainObject} denotes the `WebTwain` instance. Learn about [how to create a web twain object](/_articles/extended-usage/advanced-initialization.md#instantiating-webtwain-without-onwebtwainready). **Methods** | [`Crop()`](#crop) | [`CropToClipboard()`](#croptoclipboard) | [`CutFrameToClipboard()`](#cutframetoclipboard) | [`CutToClipboard()`](#cuttoclipboard) | | [`CopyToClipboard()`](#copytoclipboard) | [`Erase()`](#erase) | [`Flip()`](#flip) | [`Mirror()`](#mirror) | | [`Rotate()`](#rotate) | [`RotateEx()`](#rotateex) | [`RotateLeft()`](#rotateleft) | [`RotateRight()`](#rotateright) | | [`ChangeBitDepth()`](#changebitdepth) | [`SetDPI()`](#setdpi) | [`ConvertToBW()`](#converttobw) | [`ConvertToGrayScale()`](#converttograyscale) | | [`ChangeImageSize()`](#changeimagesize) | [`Invert()`](#invert) | [`SetImageWidth()`](#setimagewidth) | [`ChangeBrightnessAsync()`](#changebrightnessasync) | | [`ChangeContrastAsync()`](#changecontrastasync) | **Properties** | [`BackgroundFillColor`](#backgroundfillcolor) | ## ChangeBitDepth() Change the bit depth of the specified image. **Syntax** ```javascript ChangeBitDepth( index: number, bitDepth: number, highQuality: boolean, ): boolean; ``` **Parameters** `index`: Specify the index of the image to be changed. The index is 0-based. `bitDepth`: Specify the target bit depth. `highQuality`: Whether to keep high quality. When it's true, it takes more time. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** The allowed bit depths are 1, 4, 8, 24. --- ## ChangeImageSize() Change the size of the specified image. **Syntax** ```javascript ChangeImageSize( index: number, width: number, height: number, method: Dynamsoft.DWT.EnumDWT_InterpolationMethod | number ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread ChangeImageSize( index: number, width: number, height: number, method: Dynamsoft.DWT.EnumDWT_InterpolationMethod | number, successCallback: () => void, failureCallback: ( errorCode: number, errorString: string ) => void ): void; ``` **Parameters** `index`: Specify the index of the image to be changed. The index is 0-based. `width`: Specify the new width. `height`: Specify the new height. `method`: Specify the algorithm for the change. Please refer to [EnumDWT_InterpolationMethod](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_interpolationmethod). `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## SetDPI() Change the DPI (dots per inch) of the specified image. **Syntax** ```javascript SetDPI( index: number, xResolution: number, yResolution: number, resample: boolean, method: Dynamsoft.DWT.EnumDWT_InterpolationMethod | number ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread SetDPI( index: number, xResolution: number, yResolution: number, resample: boolean, method: Dynamsoft.DWT.EnumDWT_InterpolationMethod | number, successCallback: () => void, failureCallback: ( errorCode: number, errorString: string ) => void ): void; ``` **Parameters** `index`: Specify the index of the image to be changed. The index is 0-based. `xResolution`: Specify the horizontal DPI. `yResolution`: Specify the vertical DPI. `resample`: Whether to resample the image. When it is true, the image size will change. `method`: Specify the algorithm for the change. Please refer to [EnumDWT_InterpolationMethod](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_interpolationmethod). `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString` The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## ConvertToBW() Convert the specified image to black & white. **Syntax** ```javascript ConvertToBW( index: number ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread ConvertToBW( index: number, successCallback: () => void, failureCallback: ( errorCode: number, errorString: string ) => void ): void; ``` **Parameters** `index`: Specify the index of the image to be converted. The index is 0-based. `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v15.3+ v15.3+ v15.3+ v15.3+
--- ## ConvertToGrayScale() Convert the specified image to grayscale. **Syntax** ```javascript ConvertToGrayScale( index: number ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread ConvertToGrayScale( index: number, successCallback: () => void, failureCallback: ( errorCode: number, errorString: string ) => void ): void; ``` **Parameters** `index`: Specify the index of the image to be converted. The index is 0-based. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## Invert() Invert the color of the pixels on the specified image. **Syntax** ```typescript Invert( index: number ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread Invert( index: number, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `index`: Specify the image. `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v15.3+ v15.3+ v15.3+ v15.3+
--- ## SetImageWidth() Change the width of the specified image by adding a margin or removing part of the image. **Syntax** ```typescript SetImageWidth( index: number, width: number ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread SetImageWidth( index: number, width: number, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `index`: Specify the image. `width`: Specify the new width. `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## Flip() Flip the specified image. **Syntax** ```typescript Flip( index: number ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread Flip( index: number, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `index`: Specify the image. `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## Mirror() Mirror the specified image. **Syntax** ```typescript Mirror( index: number ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread Mirror( index: number, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `index`: Specify the image. `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## RotateLeft() Rotate the specified image 90 degrees counterclockwise. **Syntax** ```typescript RotateLeft( index: number ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread RotateLeft( index: number, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `index`: Specify the image. `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## RotateRight() Rotate the specified image 90 degrees clockwise. **Syntax** ```typescript RotateRight( index: number ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread RotateRight( index: number, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `index`: Specify the image. `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## Rotate() Rotate the specified image by the specified angle. **Syntax** ```typescript Rotate( index: number, angle: number, keepSize: boolean ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread Rotate( index: number, angle: number, keepSize: boolean, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `index`: Specify the image. `angle`: Specify the angle. `keepSize`: Whether to keep the original size. `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## RotateEx() Rotate the specified image by the specified angle. **Syntax** ```typescript RotateEx( index: number, angle: number, keepSize: boolean, method: Dynamsoft.DWT.EnumDWT_InterpolationMethod | number ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread RotateEx( index: number, angle: number, keepSize: boolean, method: Dynamsoft.DWT.EnumDWT_InterpolationMethod | number, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `index`: Specify the image. `angle`: Specify the angle. `keepSize`: Whether to keep the original size. `method`: Specify the algorithm for the change. Please refer to [Dynamsoft.DWT.EnumDWT_InterpolationMethod](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_interpolationmethod). `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## Crop() Crop the specified image using the specified coordinates. **Syntax** ```typescript Crop( index: number, left: number, top: number, right: number, bottom: number ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread Crop( index: number, left: number, top: number, right: number, bottom: number, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `index`: Specify the image. `left`: Specify the rectangle (leftmost coordinate). `top`: Specify the rectangle (topmost coordinate). `right`: Specify the rectangle (rightmost coordinate). `bottom`: Specify the rectangle (bottommost coordinate). `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## Erase() Erase a rectangular area from the specified image. **Syntax** ```typescript Erase( index: number, left: number, top: number, right: number, bottom: number ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread Erase( index: number, left: number, top: number, right: number, bottom: number, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `index`: Specify the image. `left`: Specify the rectangle (leftmost coordinate). `top`: Specify the rectangle (topmost coordinate). `right`: Specify the rectangle (rightmost coordinate). `bottom`: Specify the rectangle (bottommost coordinate). `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## CopyToClipboard() Copy the specified image to the clipboard of the operating system. **Syntax** ```typescript CopyToClipboard(index: number): boolean; ``` **Parameters** `index`: Specify the image. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## CutToClipboard() Cut the specified image to the clipboard of the operating system. **Syntax** ```typescript CutToClipboard(index: number): boolean; ``` **Parameters** `index`: Specify the image. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## CropToClipboard() Crop a rectangular area from the specified image to the clipboard of the operating system. **Syntax** ```typescript CropToClipboard( index: number, left: number, top: number, right: number, bottom: number ): boolean; ``` **Parameters** `index`: Specify the image. `left`: Specify the rectangle (leftmost coordinate). `top`: Specify the rectangle (topmost coordinate). `right`: Specify the rectangle (rightmost coordinate). `bottom`: Specify the rectangle (bottommost coordinate). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## CutFrameToClipboard() Cut a rectangular area from the specified image to the clipboard of the operating system. **Syntax** ```typescript CutFrameToClipboard( index: number, left: number, top: number, right: number, bottom: number ): boolean; ``` **Parameters** `index`: Specify the image. `left`: Specify the rectangle (leftmost coordinate). `top`: Specify the rectangle (topmost coordinate). `right`: Specify the rectangle (rightmost coordinate). `bottom`: Specify the rectangle (bottommost coordinate). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** The empty area resulted from the crop/erase/cut will be filled with the color set with [`BackgroundFillColor`](#backgroundfillcolor). --- ## BackgroundFillColor Return or set the fill color for the empty area on an image that has been cut/cropped/erased. **Syntax** ```typescript BackgroundFillColor: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** By default the color is white (0xffffff). The byte-ordering of the 24-bit RGB value is **RRGGBB**. RR represents red, GG represents green and BB represents blue. --- ## ChangeBrightnessAsync() Change the image brightness. **Syntax** ```typescript ChangeBrightnessAsync( index: number, value: number ): Promise; ``` **Parameters** `index`: Specify the index of image in buffer. `value`: Specify the brightness. Allowed values [-1000~1000]. Negative value means decrease the brightness. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v17.2+ v17.2+ v17.2+ v17.2+
--- ## ChangeContrastAsync() Change the image contrast. **Syntax** ```typescript ChangeContrastAsync( index: number, value: number ): Promise; ``` **Parameters** `index`: Specify the index of image in buffer. `value`: Specify the contrast. Allowed values [-1000~1000]. Negative value means decrease the contrast. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v17.2+ v17.2+ v17.2+ v17.2+
--- title: Dynamic Web TWAIN SDK API Reference - Input and Output APIs description: Dynamic Web TWAIN SDK Documentation | API Reference | IO APIs Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_IO.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/WebTwain_IO.md --- # {WebTwainObject} IO The properties and methods on this page live in the namespace {WebTwainObject}. {WebTwainObject} denotes the `WebTwain` instance. Learn about [how to create a web twain object](/_articles/extended-usage/advanced-initialization.md#instantiating-webtwain-without-onwebtwainready). **Methods** **Input Methods** | [`LoadImage()`](#loadimage) | [`LoadImageEx()`](#loadimageex) | [`LoadImageFromBase64Binary()`](#loadimagefrombase64binary) | [`LoadImageFromBinary()`](#loadimagefrombinary) | | [`LoadDibFromClipboard()`](#loaddibfromclipboard) | [`FTPDownload()`](#ftpdownload) | [`FTPDownloadEx()`](#ftpdownloadex) | [`HTTPDownload()`](#httpdownload) | | [`HTTPDownloadEx()`](#httpdownloadex) | [`HTTPDownloadThroughPost()`](#httpdownloadthroughpost) | [`loadFromLocalStorage()`](#loadfromlocalstorage) | **Output Methods** | [`ConvertToBase64()`](#converttobase64) | [`ConvertToBlob()`](#converttoblob) | [`FTPUpload()`](#ftpupload) | | [`FTPUploadEx()`](#ftpuploadex) | [`FTPUploadAllAsMultiPageTIFF()`](#ftpuploadallasmultipagetiff) | [`FTPUploadAllAsPDF()`](#ftpuploadallaspdf) | | [`FTPUploadAsMultiPagePDF()`](#ftpuploadasmultipagepdf) | [`FTPUploadAsMultiPageTIFF()`](#ftpuploadasmultipagetiff) | [`HTTPUpload()`](#httpupload) | | [`HTTPUploadThroughPutEx()`](#httpuploadthroughputex) | [`HTTPUploadThroughPost()`](#httpuploadthroughpost) | [`HTTPUploadThroughPostEx()`](#httpuploadthroughpostex) | | [`HTTPUploadAllThroughPostAsMultiPageTIFF()`](#httpuploadallthroughpostasmultipagetiff) | [`HTTPUploadAllThroughPostAsPDF()`](#httpuploadallthroughpostaspdf) | [`HTTPUploadThroughPostAsMultiPagePDF()`](#httpuploadthroughpostasmultipagepdf) | | [`HTTPUploadThroughPostAsMultiPageTIFF()`](#httpuploadthroughpostasmultipagetiff) | [`OutputSelectedAreaAsync()`](#outputselectedareaasync) | [`SaveAsBMP()`](#saveasbmp) | | [`SaveAsJPEG()`](#saveasjpeg) | [`SaveAsPDF()`](#saveaspdf) | [`SaveAsPNG()`](#saveaspng) | | [`SaveAsTIFF()`](#saveastiff) | [`SaveSelectedImagesAsMultiPagePDF()`](#saveselectedimagesasmultipagepdf) | [`SaveSelectedImagesAsMultiPageTIFF()`](#saveselectedimagesasmultipagetiff) | | [`SaveAllAsMultiPageTIFF()`](#saveallasmultipagetiff) | [`SaveAllAsPDF()`](#saveallaspdf) | [`httpUploadBlob()`](#httpuploadblob) | | [`saveBlob()`](#saveblob) | [`saveToLocalStorage()`](#savetolocalstorage) | **Other Methods** | [`ClearTiffCustomTag()`](#cleartiffcustomtag) | [`SetTiffCustomTag()`](#settiffcustomtag) | [`ClearAllHTTPFormField()`](#clearallhttpformfield) | [`SetHTTPFormField()`](#sethttpformfield) | | [`SetHTTPHeader()`](#sethttpheader) | [`SetUploadSegment()`](#setuploadsegment) | [`ShowFileDialog()`](#showfiledialog) | [`Print()`](#print) | | [`PrintEx()`](#printex) | [`createLocalStorage()`](#createlocalstorage) | [`localStorageExist()`](#localstorageexist) | [`removeLocalStorage()`](#removelocalstorage) | **Properties** | [`FTPPassword`](#ftppassword) | [`FTPPort`](#ftpport) | [`FTPUserName`](#ftpusername) | [`IfPASVMode`](#ifpasvmode) | | [`HttpFieldNameOfUploadedImage`](#httpfieldnameofuploadedimage) | [`HTTPPort`](#httpport) | [`IfSSL`](#ifssl) | [`HTTPPostResponseString`](#httppostresponsestring) | | [`IfShowFileDialog`](#ifshowfiledialog) | [`IfShowCancelDialogWhenImageTransfer`](#ifshowcanceldialogwhenimagetransfer) | [`IfShowProgressBar`](#ifshowprogressbar) | [`JPEGQuality`](#jpegquality) | | [`IfTiffMultiPage`](#iftiffmultipage) | [`TIFFCompressionType`](#tiffcompressiontype) | [`MaxUploadImageSize`](#maxuploadimagesize) | [`IfSortBySelectionOrder`](#ifsortbyselectionorder) | **Events** | [`OnGetFilePath`](#ongetfilepath) | [`OnPostLoad`](#onpostload) | [`OnInternetTransferPercentage`](#oninternettransferpercentage) | --- ## LoadImage() Load image(s) specified by its absolute path. **Syntax** ```javascript LoadImage( fileName: string ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread LoadImage( fileName: string, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `fileName`: The path of the image to load. `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v11.0+ v12.1+
**Example** ```javascript DWTObject.LoadImage( "C:\\test\\DWT.jpg", function () { console.log("success"); }, function (errorCode, errorString) { console.log(errorString); }, ); ``` --- ## LoadImageEx() Load image(s) specified by its absolute path. **Syntax** ```javascript LoadImageEx( fileName: string, type: Dynamsoft.DWT.EnumDWT_ImageType | number ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread LoadImageEx( fileName: string, type: Dynamsoft.DWT.EnumDWT_ImageType | number, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `fileName`: The path of the image to load. `type`: The format of the image. Please refer to [`EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype). `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v11.0+ v12.1+
**Usage Notes** You can set [`IfShowFileDialog`](/_articles/info/api/WebTwain_IO.md#ifshowfiledialog) before calling this API to enable/disable "Open File" dialog. **Example** ```javascript DWTObject.IfShowFileDialog = true; //"Open File" dialog will be opened. DWTObject.LoadImageEx( "", //file name can be empty if "Open File" dialog is called. Dynamsoft.DWT.EnumDWT_ImageType.IT_JPG, function () { console.log("success"); }, function (errorCode, errorString) { console.log(errorString); }, ); ``` ```javascript DWTObject.IfShowFileDialog = false; //Default value is true. DWTObject.LoadImageEx( "C:\\test\\DWT.jpg", Dynamsoft.DWT.EnumDWT_ImageType.IT_JPG, function () { console.log("success"); }, function (errorCode, errorString) { console.log(errorString); }, ); ``` **Remark** [Load Guide](/_articles/general-usage/scanner-image-acquisition.md#load-files) --- ## LoadImageFromBase64Binary() Load image(s) from a base64 string. **Syntax** ```javascript LoadImageFromBase64Binary( imageData: string, imageType: Dynamsoft.DWT.EnumDWT_ImageType ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread LoadImageFromBase64Binary( imageData: string, imageType: Dynamsoft.DWT.EnumDWT_ImageType, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `imageData`: The image data which is a base64 string without the data URI scheme. `imageType`: The format of the image. Please refer to [`EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype). `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v11.0+ v12.1+
**Usage Notes** You may leverage [`ConvertToBase64()`](/_articles/info/api/WebTwain_IO.md#converttobase64) to get a base64 string. **Example** ```javascript DWTObject.ConvertToBase64( [0, 1, 2], Dynamsoft.DWT.EnumDWT_ImageType.IT_PDF, function (result, indices, type) { DWTObject.LoadImageFromBase64Binary( result.getData(0, result.getLength()), Dynamsoft.DWT.EnumDWT_ImageType.IT_PDF, function () { console.log("success"); }, function (errorCode, errorString) { console.log(errorString); }, ); }, function (errorCode, errorString) { console.log(errorString); }, ); ``` **Remark** [Load Guide](/_articles/general-usage/scanner-image-acquisition.md#load-files-in-binary-or-base64-string-format) --- ## LoadImageFromBinary() Load image(s) from a binary object (Blob or ArrayBuffer). **Syntax** ```javascript LoadImageFromBinary( imageData: Blob | ArrayBuffer, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `imageData`: The image data. `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.0+ v16.0+ v16.0+ v16.0+
**Usage Notes** You may leverage [`ConvertToBlob()`](/_articles/info/api/WebTwain_IO.md#converttoblob) to get a Blob object. **Example** ```javascript DWTObject.ConvertToBlob( [0, 1, 2], Dynamsoft.DWT.EnumDWT_ImageType.IT_PDF, function (result, indices, type) { DWTObject.LoadImageFromBinary( result, function () { console.log("success"); }, function (errorCode, errorString) { console.log(errorString); }, ); }, function (errorCode, errorString) { console.log(errorString); }, ); ``` **Remark** [Load Guide](/_articles/general-usage/scanner-image-acquisition.md#load-files-in-binary-or-base64-string-format) --- ## LoadDibFromClipboard() Load an image from the system clipboard. The image must be in DIB format. **Syntax** ```javascript LoadDibFromClipboard(): boolean; // Call this API asynchronously to avoid blocking the browser's main thread LoadDibFromClipboard( successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v11.0+ v12.1+
**Usage Notes** If called without any callback functions, these methods (except for [`LoadImageFromBinary()`](/_articles/info/api/WebTwain_IO.md#loadimagefrombinary) ) become synchronously and return a boolean value to indicate whether it succeeded. However, calling them asynchronously is recommended. --- ## OnGetFilePath This event is triggered when [`ShowFileDialog()`](/_articles/info/api/WebTwain_IO.md#showfiledialog) is called or when [`LoadImageEx()`](/_articles/info/api/WebTwain_IO.md#loadimageex) is called with [`IfShowFileDialog`](/_articles/info/api/WebTwain_IO.md#ifshowfiledialog) set to true. **Syntax** ```javascript RegisterEvent( "OnGetFilePath", function ( isSave: number, filesCount: number, index: number, directory: string, fileName: string ) {} ); ``` **Parameters** `isSave`: Whether or not the event is triggered after a save-file dialog was shown. `0` means false, `1` means true. `filesCount`: How many files were selected. `index`: The index of the current image. `directory`: The parent directory of currently selected file(s), "\\\\" is not included. If the method [`ShowFileDialog()`](/_articles/info/api/WebTwain_IO.md#showfiledialog) failed, the initial directory path set in the [`ShowFileDialog()`](/_articles/info/api/WebTwain_IO.md#showfiledialog) method is returned. `fileName`: The current file name. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v11.0+ v12.1+
**Example** ```javascript DWTObject.RegisterEvent("OnGetFilePath", function (isSave, filesCount, index, directory, filename) { alert( "isSave:" + isSave + " fileCount: " + filesCount + " index: " + index + " directory: " + directory + "\\" + filename, ); }); ``` --- ## OnPostLoad This event is triggered when a file is loaded in the following cases: - A file is dragged and dropped into the viewer - A local file is loaded using [`LoadImage()`](/_articles/info/api/WebTwain_IO.md#loadimage) or [`LoadImageEx()`](/_articles/info/api/WebTwain_IO.md#loadimageex) - A remote file is downloaded using network methods like [`HTTPDownload()`](/_articles/info/api/WebTwain_IO.md#httpdownload) Note: The event fires regardless of the operation's success. **Syntax** ```javascript RegisterEvent( "OnPostLoad", function (path: string, fileName: string, fileType: string) {} ); ``` **Parameters** `path`: The path of the source. For example, "C:\\Users\\[username]\\Downloads". It is empty if the file is dragged and dropped. `fileName`: The name of the loaded file. For example, "image1.jpg". `fileType`: The file type. Please refer to [`EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v11.0+ v12.1+
**Example** ```javascript DWTObject.RegisterEvent("OnPostLoad", function (path, name, type) { alert(path + "\\" + name); }); ``` --- ## FTPDownload() Download the specified file via FTP. **Syntax** ```javascript FTPDownload( host: string, path: string, successCallback: () => void, failureCallBack: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `host`: The FTP Host. `path`: Specify the file to download. `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v4.0+ v4.0+ v4.0+ v4.0+
--- ## FTPDownloadEx() Download the specified file via FTP. **Syntax** ```javascript FTPDownloadEx( host: string, path: string, type: Dynamsoft.DWT.EnumDWT_ImageType | number, successCallback: () => void, failureCallBack: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `host`: The FTP Host. `path`: Specify the file to download. `type`: The format of the file. Please refer to [`EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype). `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v4.0+ v4.0+ v4.0+ v4.0+
**Example** ```javascript /* The sample file path is: * "ftp://192.168.8.20/files/sample.pdf" */ var onSuccess = function () { console.log("Downloaded a file successfully!"); }; var onFailure = function (errorCode, errorString) { console.log(errorString); }; DWTObject.FTPPort = 21; DWTObject.FTPUserName = "FTPUser"; DWTObject.FTPPassword = "SomePassword"; DWTObject.FTPDownloadEx( "192.168.8.20", "/files/sample.pdf", Dynamsoft.DWT.EnumDWT_ImageType.IT_PDF, onSuccess, onFailure, ); ``` --- ## FTPUpload() Upload the specified image via FTP. **Syntax** ```javascript FTPUpload( host: string, index: number, path: string, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `host`: The FTP Host. `index`: Specify the index of the image in the buffer. The index is 0-based. `path`: The path to save the file. `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v4.0+ v4.0+ v4.0+ v4.0+
**Example** ```javascript var onSuccess = function () { console.log("Uploaded a file successfully!"); }; var onFailure = function (errorCode, errorString) { console.log(errorString); }; DWTObject.FTPUserName = "test"; DWTObject.FTPPort = 21; DWTObject.FTPPassword = "test"; DWTObject.FTPUpload( "192.168.8.222", //The FTP Host 0, // The index of the image "test.pdf", // The path & name of the file onSuccess, // Callback in case of success onFailure, // Callback in case of failure ); ``` --- ## FTPUploadEx() Upload the specified image via FTP. **Syntax** ```javascript FTPUploadEx( host: string, index: number, path: string, type: Dynamsoft.DWT.EnumDWT_ImageType | number, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `host`: The FTP Host. `index`: Specify the index of the image in the buffer. The index is 0-based. `path`: The path to save the file. `type`: The format of the file. Please refer to [`EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype). `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.0+ v5.0+ v5.0+ v5.0+
--- ## FTPUploadAllAsMultiPageTIFF() Upload all images as a multi-page TIFF via FTP. **Syntax** ```javascript FTPUploadAllAsMultiPageTIFF( host: string, path: string, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `host`: The FTP Host. `path`: Specify the path to save the file. `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v4.0+ v4.0+ v4.0+ v4.0+
--- ## FTPUploadAllAsPDF() Upload all images as a multi-page PDF via FTP. **Syntax** ```javascript FTPUploadAllAsPDF( host: string, path: string, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `host`: The FTP Host. `path`: Specify the path to save the file. `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v4.0+ v4.0+ v4.0+ v4.0+
--- ## FTPUploadAsMultiPagePDF() Upload selected images as a multi-page PDF via FTP. **Syntax** ```javascript FTPUploadAsMultiPagePDF( host: string, path: string, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `host`: The FTP Host. `path`: Specify the path to save the file. `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v6.0+ v6.0+ v6.0+ v6.0+
--- ## FTPUploadAsMultiPageTIFF() Upload selected images as a multi-page TIFF via FTP. **Syntax** ```javascript FTPUploadAsMultiPageTIFF( host: string, path: string, type: Dynamsoft.DWT.EnumDWT_ImageType | number, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `host`: The FTP Host. `path`: Specify the path to save the file. `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v6.0+ v6.0+ v6.0+ v6.0+
--- ## FTPUserName The user name to connect to the FTP. **Syntax** ```javascript FTPUserName: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.2+ v5.2+ v5.2+ v5.2+
--- ## FTPPassword The password to connect to the FTP. **Syntax** ```javascript FTPPassword: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.2+ v5.2+ v5.2+ v5.2+
--- ## FTPPort The port to connect to the FTP. **Syntax** ```javascript FTPPort: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.2+ v5.2+ v5.2+ v5.2+
--- ## IfPASVMode Return or set whether to use passive mode when connect to the FTP. **Syntax** ```javascript IfPASVMode: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v6.0+ v6.0+ v6.0+ v6.0+
--- ## HTTPPassword Return or set the password used to log into the HTTP server. **Syntax** ```javascript HTTPPassword: string; ``` --- ## HTTPUserName Return or set the user name used to log into the HTTP server. **Syntax** ```javascript HTTPUserName: string; ``` --- ## HTTPDownload() Download the specified file via a HTTP Get request. **Syntax** ```javascript HTTPDownload( host: string, path: string, successCallback: () => void, failureCallback: ( errorCode: number, errorString: string) => void ): void; ``` **Parameters** `host`: The HTTP Host. `path`: Specify the path of the file to download. `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v4.0+ v4.0+ v4.0+ v4.0+
**Example** ```javascript /* The sample file path is: * "http://localhost:300/files/sample.tif" */ var onSuccess = function () { console.log("Downloaded a file successfully!"); }; var onFailure = function (errorCode, errorString) { console.log(errorString); }; DWTObject.HTTPPort = 300; DWTObject.HTTPDownload("localhost", "/files/sample.tif", onSuccess, onFailure); ``` **Remark** [Download Guide](/_articles/general-usage/scanner-image-acquisition.md#download) --- ## HTTPDownloadEx() Download the specified file via a HTTP Get request. **Syntax** ```javascript HTTPDownloadEx( host: string, path: string, type: Dynamsoft.DWT.EnumDWT_ImageType | number, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `host`: The HTTP Host. `path`: Specify the path of the file to download. `type`: The format of the file. Please refer to [`EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype). `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.0+ v5.0+ v5.0+ v5.0+
**Usage Notes** If you want to use this method to upload / download files through HTTPS, please don't forget to set [`IfSSL`](/_articles/info/api/WebTwain_IO.md#ifssl) to true and set the correct [`HTTPPort`](/_articles/info/api/WebTwain_IO.md#httpport). **Example** In this example, the URL points to a server-side script. The server-side script can be written in any language and in any logic as long as it returns a file. Please refer to [Download-Server-Script](/_articles/general-usage/server-side-scripting.md#download-a-file). ```javascript /* The sample file path is: * "http://localhost:300/files/sample.tif" */ var onSuccess = function () { console.log("Downloaded a file successfully!"); }; var onFailure = function (errorCode, errorString) { console.log(errorString); }; DWTObject.HTTPPort = 300; DWTObject.HTTPDownloadEx( "localhost", "/getFile.aspx", Dynamsoft.DWT.EnumDWT_ImageType.IT_TIF, onSuccess, onFailure, ); ``` **Remark** [Download Guide](/_articles/general-usage/scanner-image-acquisition.md#download) --- ## HTTPDownloadThroughPost() Download the specified file via a HTTP Post request. **Syntax** ```javascript HTTPDownloadThroughPost( host: string, path: string, type: Dynamsoft.DWT.EnumDWT_ImageType | number, successCallback: () => void, failureCallback: (errorCode: number, errorString: string, response?: any) => void, ): void; ``` **Parameters** `host`: The HTTP Host. `path`: Specify the path of the file to download. `type`: The format of the file. Please refer to [`EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype). `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. - `response`: The response from your server. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.0+ v5.0+ v5.0+ v5.0+
--- ## HTTPUpload() Upload the specified image(s) via a HTTP Post. **Syntax** ```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; ``` **Parameters** `URL`: The server-side script to receive the post. For the sample code of Server Script, please refer to [Upload-Server-Script](/_articles/general-usage/server-side-scripting.md#how-to-process-uploaded-files). `indices`: Specify the image(s). `type`: The format of the file. Please refer to [`EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype). `dataFormat`: Whether to upload the file as binary or a base64 string. Please refer to [`EnumDWT_UploadDataFormat`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_uploaddataformat). `fileName`: The file name. Additionally, if `fileName` specifies the extension of the file, - If the extension is not the same as the format of the file which is specified by `type`, the extra extension will be added to the file name. - e.g. if `fileName` is set to `"test.jpg"`, and `type` is `Dynamsoft.DWT.EnumDWT_ImageType.IT_PDF`, then the final file name would be `test.jpg.pdf` and the file format would be PDF. - If the extension is the same as the format of the file which is specified by `type`, the file name equals to the string which is specified by `fileName`. - e.g. if `fileName` is set to `"test.pdf"`, and `type` is `Dynamsoft.DWT.EnumDWT_ImageType.IT_PDF`, then the final file name would be `test.pdf` and the file format would be PDF. `onEmptyResponse`: A callback function that is executed if the response is empty. `onServerReturnedSomething`: A callback function that is executed if the response is not empty. The accepted response type is `string`. - `errorCode` The error code. - `errorString` The error string. - `response` The response string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v12.0+ v12.0+ v12.0+ v12.0+
**Usage Notes** If you want to use this method to upload / download files through HTTPS, please don't forget to set [`IfSSL`](/_articles/info/api/WebTwain_IO.md#ifssl) to true and set the correct [`HTTPPort`](/_articles/info/api/WebTwain_IO.md#httpport). **Example** ```javascript DWTObject.HTTPUpload( "https://www.dynamsoft.com/SaveToFile.aspx", [0, 1], Dynamsoft.DWT.EnumDWT_ImageType.IT_PDF, Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, "test.pdf", OnEmptyResponse, OnServerReturnedSomething, ); function OnEmptyResponse() { console.log("Success"); } function OnServerReturnedSomething(errCode, errString, responseStr) { console.log(errString); } ``` **Remark** [Upload Guide](/_articles/general-usage/image-export/index.md#upload) --- ## HTTPUploadThroughPutEx() Upload the specified image via a HTTP Put request. **Syntax** ```javascript HTTPUploadThroughPutEx( host: string, index: number, path: string, type: Dynamsoft.DWT.EnumDWT_ImageType | number, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `host`: The HTTP Host. `index`: Specify the image. `path`: Specify the path to put the file. `type`: The format of the file. Please refer to [`EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype). `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.0+ v5.0+ v5.0+ v5.0+
--- ## HTTPUploadThroughPost() Upload the specified image via a HTTP Post request. **Syntax** ```javascript HTTPUploadThroughPost( host: string, index: number, target: string, fileName: string, onEmptyResponse: () => void, onServerReturnedSomething: (errorCode: number, errorString: string, response: string) => void ): void; ``` **Parameters** `host`: The HTTP Host. `index`: Specify the image. `target`: The target where the request is sent. For the sample code of Server Script, please refer to [Upload-Server-Script](/_articles/general-usage/server-side-scripting.md#how-to-process-uploaded-files). `fileName`: The file name. `onEmptyResponse`: A callback function that is executed if the response is empty. `onServerReturnedSomething`: A callback function that is executed if the response is not empty. - `errorCode`: The error code. - `errorString`: The error string. - `response`: The response string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v4.0+ v4.0+ v4.0+ v4.0+
**Usage Notes** If you want to use this method to upload / download files through HTTPS, please don't forget to set [`IfSSL`](/_articles/info/api/WebTwain_IO.md#ifssl) to true and set the correct [`HTTPPort`](/_articles/info/api/WebTwain_IO.md#httpport). **Example** ```javascript var strHTTPServer = location.hostname; //The name of the HTTP server. For example: "www.dynamsoft.com"; var CurrentPathName = unescape(location.pathname); var CurrentPath = CurrentPathName.substring(0, CurrentPathName.lastIndexOf("/") + 1); var strActionPage = CurrentPath + "SaveToFile.aspx"; DWTObject.IfSSL = false; // Set whether SSL is used DWTObject.HTTPPort = location.port == "" ? 100 : location.port; var Digital = new Date(); var uploadfilename = Digital.getMilliseconds(); DWTObject.HTTPUploadThroughPost( strHTTPServer, DWTObject.CurrentImageIndexInBuffer, strActionPage, uploadfilename + ".jpg", function () { console.log("Empty response"); }, function (errorCode, errorString, response) { console.log(response); }, ); ``` --- ## HTTPUploadThroughPostEx() Upload the specified image in a specific image format via a HTTP Post request. **Syntax** ```javascript HTTPUploadThroughPostEx( host: string, index: number, target: string, fileName: string, type: Dynamsoft.DWT.EnumDWT_ImageType | number, onEmptyResponse: () => void, onServerReturnedSomething: ( errorCode: number, errorString: string, response: string) => void ): void; ``` **Parameters** `host`: The HTTP Host. `index`: Specify the image. `target`: The target where the request is sent. For the sample code of Server Script, please refer to [Upload-Server-Script](/_articles/general-usage/server-side-scripting.md#how-to-process-uploaded-files). `fileName`: The file name. `type`: The format of the file. Please refer to [`EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype). `onEmptyResponse`: A callback function that is executed if the response is empty. `onServerReturnedSomething`: A callback function that is executed if the response is not empty. - `errorCode`: The error code. - `errorString`: The error string. - `response`: The response string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.0+ v5.0+ v5.0+ v5.0+
**Usage Notes** If you want to use this method to upload / download files through HTTPS, please don't forget to set [`IfSSL`](/_articles/info/api/WebTwain_IO.md#ifssl) to true and set the correct [`HTTPPort`](/_articles/info/api/WebTwain_IO.md#httpport). --- ## HTTPUploadAllThroughPostAsMultiPageTIFF() Upload all images in the buffer as a TIFF file via a HTTP Post request. **Syntax** ```javascript HTTPUploadAllThroughPostAsMultiPageTIFF( host: string, target: string, fileName: string, onEmptyResponse: () => void, onServerReturnedSomething: ( errorCode: number, errorString: string, response: string) => void ): void; ``` **Parameters** `host`: The HTTP Host. `target`: The target where the request is sent. For the sample code of Server Script, please refer to [Upload-Server-Script](/_articles/general-usage/server-side-scripting.md#how-to-process-uploaded-files). `fileName`: The file name. `onEmptyResponse`: A callback function that is executed if the response is empty. `onServerReturnedSomething`: A callback function that is executed if the response is not empty. - `errorCode`: The error code. - `errorString`: The error string. - `response`: The response string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v4.0+ v4.0+ v4.0+ v4.0+
**Usage Notes** If you want to use this method to upload / download files through HTTPS, please don't forget to set [`IfSSL`](/_articles/info/api/WebTwain_IO.md#ifssl) to true and set the correct [`HTTPPort`](/_articles/info/api/WebTwain_IO.md#httpport). --- ## HTTPUploadAllThroughPostAsPDF() Upload all images in the buffer as a PDF file via a HTTP Post request. **Syntax** ```javascript HTTPUploadAllThroughPostAsPDF( host: string, target: string, fileName: string, onEmptyResponse: () => void, onServerReturnedSomething: ( errorCode: number, errorString: string, response: string) => void ): void; ``` **Parameters** `host`: The HTTP Host. `target`: The target where the request is sent. For the sample code of Server Script, please refer to [Upload-Server-Script](/_articles/general-usage/server-side-scripting.md#how-to-process-uploaded-files). `fileName`: The file name. `onEmptyResponse`: A callback function that is executed if the response is empty. `onServerReturnedSomething`: A callback function that is executed if the response is not empty. - `errorCode`: The error code. - `errorString`: The error string. - `response`: The response string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.0+ v5.0+ v5.0+ v5.0+
**Usage Notes** If you want to use this method to upload / download files through HTTPS, please don't forget to set [`IfSSL`](/_articles/info/api/WebTwain_IO.md#ifssl) to true and set the correct [`HTTPPort`](/_articles/info/api/WebTwain_IO.md#httpport). --- ## HTTPUploadThroughPostAsMultiPagePDF() Upload all selected images in the buffer as a PDF file via a HTTP Post request. **Syntax** ```javascript HTTPUploadThroughPostAsMultiPagePDF( host: string, target: string, fileName: string, onEmptyResponse: () => void, onServerReturnedSomething: ( errorCode: number, errorString: string, response: string) => void ): void; ``` **Parameters** `host`: The HTTP Host. `target`: The target where the request is sent. For the sample code of Server Script, please refer to [Upload-Server-Script](/_articles/general-usage/server-side-scripting.md#how-to-process-uploaded-files). `fileName`: The file name. `onEmptyResponse`: A callback function that is executed if the response is empty. `onServerReturnedSomething`: A callback function that is executed if the response is not empty. - `errorCode`: The error code. - `errorString`: The error string. - `response`: The response string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v6.0+ v6.0+ v6.0+ v6.0+
**Usage Notes** If you want to use this method to upload / download files through HTTPS, please don't forget to set [`IfSSL`](/_articles/info/api/WebTwain_IO.md#ifssl) to true and set the correct [`HTTPPort`](/_articles/info/api/WebTwain_IO.md#httpport). --- ## HTTPUploadThroughPostAsMultiPageTIFF() Upload all selected images in the buffer as a TIFF file via a HTTP Post request. **Syntax** ```javascript HTTPUploadThroughPostAsMultiPageTIFF( host: string, target: string, fileName: string, onEmptyResponse: () => void, onServerReturnedSomething: ( errorCode: number, errorString: string, response: string) => void ): void; ``` **Parameters** `host`: The HTTP Host. `target`: The target where the request is sent. For the sample code of Server Script, please refer to [Upload-Server-Script](/_articles/general-usage/server-side-scripting.md#how-to-process-uploaded-files). `fileName`: The file name. `onEmptyResponse`: A callback function that is executed if the response is empty. `onServerReturnedSomething`: A callback function that is executed if the response is not empty. - `errorCode`: The error code. - `errorString`: The error string. - `response`: The response string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v6.0+ v6.0+ v6.0+ v6.0+
**Usage Notes** If you want to use this method to upload / download files through HTTPS, please don't forget to set [`IfSSL`](/_articles/info/api/WebTwain_IO.md#ifssl) to true and set the correct [`HTTPPort`](/_articles/info/api/WebTwain_IO.md#httpport). --- ## httpUploadBlob() Upload images which are in blob format. **Syntax** ```typescript httpUploadBlob( URL: string, blobData: Blob, fileName: string, optionConfig?:{ responseType?: Dynamsoft.DWT.EnumDWT_ResponseType, formFields?:{ name: string, value: Blob | string, fileName?: string }[], headers?:{ name: string, value: string }[] } ): Promise; ``` **Parameters** `URL`: The server-side script to receive the post. For the sample code of Server Script, please refer to [Upload-Server-Script](/_articles/general-usage/server-side-scripting.md#how-to-process-uploaded-files). `blobData`: The blob data of the image to upload. `fileName`: The file name. Additionally, if `fileName` specifies the extension of the file, - If the extension is not the same as the blob type, the extra extension will be added to the file name. - e.g. if `fileName` is set to `"test.jpg"`, and blob type is `application/pdf`, then the final file name would be `test.jpg.pdf` and the file format would be PDF. - If the extension is the same as the blob type, the file name equals to the string which is specified by `fileName`. - e.g. if `fileName` is set to `"test.pdf"`, and blob type is `application/pdf`, then the final file name would be `test.pdf` and the file format would be PDF. `optionConfig`: - `responseType`: The response type. Please refer to [`EnumDWT_ResponseType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_responsetype). - `formFields`: The fields to the HTTP Post Form. - `name`: The name of field. - `value`: The value of field. - `fileName`: Specify the file name, if `value` is `Blob`. - `headers`: The headers to the HTTP Post Form. - `name`: The name of header. - `value`: The value of header. **Return Values** A Promise object of the response that is resolved based on the `responseType` parameter. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.5+ v18.5+ v18.5+ v18.5+
**Usage notes** Supported blob type: `image/jpeg`, `image/png`, `image/bmp`, `image/tiff`, `application/pdf`, `image/jpg`, `image/tif`. --- ## HttpFieldNameOfUploadedImage Return or set the field name for the uploaded file. By default, it's "RemoteFile". **Syntax** ```javascript HttpFieldNameOfUploadedImage: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v6.0+ v6.0+ v6.0+ v6.0+
--- ## HTTPPort Return or set the HTTP Port. The default value is `80`. **Syntax** ```javascript HTTPPort: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v4.2.1+ v4.2.1+ v4.2.1+ v4.2.1+
--- ## IfSSL Return or set whether to use SSL in HTTP requests. The default value is `false`. **Syntax** ```javascript IfSSL: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.2+ v5.2+ v5.2+ v5.2+
--- ## HTTPPostResponseString Return the response string of the latest HTTP Post request. **Syntax** ```javascript readonly HTTPPostResponseString: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v3.0.3+ v3.0.3+ v3.0.3+ v3.0.3+
--- ## MaxUploadImageSize Return or set the maximum allowed size of a file to upload (in bytes). The default value is `-1` which indicates there is no limit over the upload size. The value should be equal or smaller than `2147483647` which essentially means `2 GB`. **Syntax** ```javascript MaxUploadImageSize: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.2+ v5.2+ v5.2+ v5.2+
--- ## OnInternetTransferPercentage This event is triggered multiple times during a HTTP upload or download request. **Syntax** ```javascript RegisterEvent("OnInternetTransferPercentage", function (percentage: number) {}); ``` **Parameters** `percentage`: Return the progress by percentage. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.0+ v5.0+ v5.0+ v5.0+
--- ## ConvertToBase64() Convert the specified images to a base64 string. **Syntax** ```javascript ConvertToBase64( indices: number[], type: Dynamsoft.DWT.EnumDWT_ImageType | number, successCallback: (result: Base64Result, indices: number[], type: number) => void, failureCallBack: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `indices`: Specify one or multiple images. `type`: The file type. Please refer to [`EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype). `successCallback`: A callback function that is executed if the request succeeds. - `result`: The resulting base64 string. Please refer to [`Base64Result`](/_articles/info/api/interfaces.md#base64result). - `indices`: The indices of the converted images. - `type`: The file type. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v12.0+ v12.0+ v12.0+ v12.1+
**Usage Notes** `getData()` returns the pure base64 string without the data URI scheme. For example, "/9j/4AAQSkZJRgABA...". If you want to use the string, you probably need to add the scheme. For example, "data:image/png; base64, /9j/4AAQSkZJRgABA...". **Example** Convert the first three images in the buffer to `base64`, and print to the browser console. ```javascript DWTObject.ConvertToBase64( [0, 1, 2], Dynamsoft.DWT.EnumDWT_ImageType.IT_PDF, function (result, indices, type) { console.log(result.getData(0, result.getLength())); }, function (errorCode, errorString) { console.log(errorString); }, ); ``` Convert all the images in the buffer to a `base64` PDF, and print the `base64` string to the browser console. ```javascript // Index array of all images in buffer in ascending order bufferIndices = Array.from({ length: DWTObject.HowManyImagesInBuffer }, (value, index) => index); DWTObject.ConvertToBase64( bufferIndices, Dynamsoft.DWT.EnumDWT_ImageType.IT_PDF, // Encode image as PDF (base64Result, indices) => { console.log(base64Result.getData(0, base64Result.getLength()))); }, (errorCode, errorString) => { console.log(errorString); }) ``` --- ## ConvertToBlob() Convert the specified images to a blob. **Syntax** ```javascript ConvertToBlob( indices: number[], type: Dynamsoft.DWT.EnumDWT_ImageType | number, successCallback: (result: Blob, indices: number[], type: number) => void, failureCallBack: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `indices`: Specify one or multiple images. `type`: The file type. Please refer to [`EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype). `successCallback`: A callback function that is executed if the request succeeds. - `result`: The resulting blob. - `indices`: The indices of the converted images. - `type`: The file type. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v13.0+ v13.0+ v13.0+ v13.0+
**Example** ```javascript DWTObject.ConvertToBlob( [0, 1, 2], Dynamsoft.DWT.EnumDWT_ImageType.IT_PDF, function (result, indices, type) { console.log(result.size); }, function (errorCode, errorString) { console.log(errorString); }, ); ``` --- ## OutputSelectedAreaAsync() Copy selected area to Blob or base64. **Syntax** ```typescript OutputSelectedAreaAsync( index: number, area: { x: number, y: number, width: number, height: number }, type: Dynamsoft.DWT.EnumDWT_ImageType | number, imageFormatType: Dynamsoft.DWT.EnumDWT_ImageFormatType | number ): Promise < Blob | string > ; ``` **Parameters** `index`: Image to be copied from. `area`: Area of image to be copied. X,Y is top left corner origin, width and height is size of area to be copied `type`: The target image type of the blob/base64 (See [`Dynamsoft.DWT.EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype) for allowable types). `imageFormatType`: Specify if the return should be Blob or base64 string ([`Dynamsoft.DWT.EnumDWT_ImageFormatType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imageformattype) for values) **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.4+ v18.4+ v18.4+ v18.4+
**Example** Output the square portion of page index 0 in the buffer with its top left corner at pixel coordinates (50, 50), with height and width 100. Pass it to the console as a `base64` string, and also load it back into the WebTwain buffer as a separate page. ```js DWTObject.OutputSelectedAreaAsync( 0, { x: 50, y: 50, width: 100, height: 100 }, Dynamsoft.DWT.EnumDWT_ImageType.IT_JPG, Dynamsoft.DWT.EnumDWT_ImageFormatType.Base64, ).then((base64) => { console.log(base64); DWTObject.LoadImageFromBase64Binary(base64, Dynamsoft.DWT.EnumDWT_ImageType.IT_JPG); }); ``` --- ## SaveAsBMP() Save the specified image as a BMP file. **Syntax** ```javascript SaveAsBMP( fileName: string, index: number ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread SaveAsBMP( fileName: string, index: number, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `fileName`: The name to save to (or specify the absolute path). `index`: The index which specifies the image to save. `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage Notes** If you would like to save images by showing the 'Save File' dialog box, you can set [`IfShowFileDialog`](/_articles/info/api/WebTwain_IO.md#ifshowfiledialog) to `true`. --- ## SaveAsJPEG() Save the specified image as a JPEG file. **Syntax** ```javascript SaveAsJPEG( fileName: string, index: number ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread SaveAsJPEG( fileName: string, index: number, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `fileName`: The name to save to (or specify the absolute path). `index`: The index which specifies the image to save. `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v11.0+ v12.1+
**Usage notes** If you would like to save images by showing the 'Save File' dialog box, you can set [`IfShowFileDialog`](/_articles/info/api/WebTwain_IO.md#ifshowfiledialog) to `true`. --- ## SaveAsPDF() Save the specified image as a PDF file. **Syntax** ```javascript SaveAsPDF( fileName: string, index: number ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread SaveAsPDF( fileName: string, index: number, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `fileName`: The name to save to (or specify the absolute path). `index`: The index which specifies the image to save. `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v11.0+ v12.1+
**Usage notes** Learn about [how to config PDF save settings](/_articles/info/api/Addon_PDF.md#writesetup). If you would like to save images by showing the 'Save File' dialog box, you can set [`IfShowFileDialog`](/_articles/info/api/WebTwain_IO.md#ifshowfiledialog) to `true`. --- ## SaveAsPNG() Save the specified image as a PNG file. **Syntax** ```javascript SaveAsPNG( fileName: string, index: number ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread SaveAsPNG( fileName: string, index: number, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `fileName`: The name to save to (or specify the absolute path). `index`: The index which specifies the image to save. `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v11.0+ v12.1+
**Usage notes** If you would like to save images by showing the 'Save File' dialog box, you can set [`IfShowFileDialog`](/_articles/info/api/WebTwain_IO.md#ifshowfiledialog) to true. --- ## SaveAsTIFF() Save the specified image as a TIFF file. **Syntax** ```javascript SaveAsTIFF( fileName: string, index: number ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread SaveAsTIFF( fileName: string, index: number, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v11.0+ v12.1+
**Parameters** `fileName`: The name to save to (or specify the absolute path). `index`: The index which specifies the image to save. `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Usage notes** If you would like to save images by showing the 'Save File' dialog box, you can set [`IfShowFileDialog`](/_articles/info/api/WebTwain_IO.md#ifshowfiledialog) to true. --- ## SaveAllAsMultiPageTIFF() Saves all the images in buffer as a multi-page TIFF file. **Syntax** ```javascript SaveAllAsMultiPageTIFF( fileName: string ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread SaveAllAsMultiPageTIFF( fileName: string, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `fileName`: The name to save to (or specify the absolute path). `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode` The error code. - `errorString` The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v11.0+ v12.1+
**Usage notes** {% comment %}If you are using WASM mode on the desktop, the image will always be saved to the Downloads folder even if you specify an absolute path.{% endcomment %} If you would like to save images by showing the 'Save File' dialog box, you can set [`IfShowFileDialog`](/_articles/info/api/WebTwain_IO.md#ifshowfiledialog) to true. --- ## SaveAllAsPDF() Saves all the images in buffer as a multi-page PDF file. **Syntax** ```javascript SaveAllAsPDF( fileName: string ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread SaveAllAsPDF( fileName: string, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `fileName`: The name to save to (or specify the absolute path). `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v11.0+ v12.1+
**Usage notes** Learn about [how to config PDF save settings](/_articles/info/api/Addon_PDF.md#writesetup). If you would like to save images by showing the 'Save File' dialog box, you can set [`IfShowFileDialog`](/_articles/info/api/WebTwain_IO.md#ifshowfiledialog) to true. --- ## SaveSelectedImagesAsMultiPagePDF() Saves all selected images in buffer as a multi-page PDF file. **Syntax** ```javascript SaveSelectedImagesAsMultiPagePDF( fileName: string ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread SaveSelectedImagesAsMultiPagePDF( fileName: string, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `fileName`: The name to save to (or specify the absolute path). `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v11.0+ v12.1+
**Usage notes** Learn about [how to config PDF save settings](/_articles/info/api/Addon_PDF.md#write-setup). If you would like to save images by showing the 'Save File' dialog box, you can set [`IfShowFileDialog`](/_articles/info/api/WebTwain_IO.md#ifshowfiledialog) to `true`. --- ## SaveSelectedImagesAsMultiPageTIFF() Saves all selected images in buffer as a multi-page TIFF file. **Syntax** ```javascript SaveSelectedImagesAsMultiPageTIFF( fileName: string ): boolean; // Call this API asynchronously to avoid blocking the browser's main thread SaveSelectedImagesAsMultiPageTIFF( fileName: string, successCallback: () => void, failureCallback: (errorCode: number, errorString: string) => void ): void; ``` **Parameters** `fileName`: The name to save to (or specify the absolute path). `successCallback`: A callback function that is executed if the request succeeds. `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v11.0+ v12.1+
**Usage notes** If called without any callback functions, these methods become synchronously and return a boolean value to indicate whether it succeeded. However, calling them asynchronously is recommended. If you would like to save images by showing the 'Save File' dialog box, you can set [`IfShowFileDialog`](/_articles/info/api/WebTwain_IO.md#ifshowfiledialog) to `true`. --- ## saveBlob() Save image which are in blob format. **Syntax** ```typescript saveBlob( fileName: string, blobData: Blob, ): Promise; ``` **Parameters** `fileName`: The file name. Additionally, if `fileName` specifies the extension of the file, - If the extension is not the same as the blob type, the extra extension will be added to the file name. - e.g. if `fileName` is set to `"test.jpg"`, and blob type is `application/pdf`, then the final file name would be `test.jpg.pdf` and the file format would be PDF. - If the extension is the same as the blob type, the file name equals to the string which is specified by `fileName`. - e.g. if `fileName` is set to `"test.pdf"`, and blob type is `application/pdf`, then the final file name would be `test.pdf` and the file format would be PDF. `blobData`: The blob data of the image to save. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.5+ v18.5+ v18.5+ v18.5+
**Usage notes** Supported blob type: `image/jpeg`, `image/png`, `image/bmp`, `image/tiff`, `application/pdf`, `image/jpg`, `image/tif`. --- ## ClearTiffCustomTag() Clear the content of all custom tiff tags. **Syntax** ```javascript ClearTiffCustomTag(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v11.0+ v12.1+
--- ## SetTiffCustomTag() Sets a custom tiff tag (up to 32 tags). The string to be set in a tag can be base64 encoded. **Syntax** ```javascript SetTiffCustomTag( id: number, content: string, useBase64Encoding: boolean ): boolean; ``` **Parameters** `id`: The id of the custom tag. `content`: The content of the tag. `useBase64Encoding`: Whether the content is encoded. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v11.0+ v12.1+
**Usage notes** The method `SetTiffCustomTag()` sets one or up to 32 tags to be added to a TIFF file when generating it. The content of the tags can be plain text or a base64-encoded string. If it's encoded, it'll be decoded when generating the TIFF file. To make sure you don't included unwanted tags, call [`ClearTiffCustomTag()`](/_articles/info/api/WebTwain_IO.md#cleartiffcustomtag) to clear old tags before setting up new ones. **Example** ```javascript DWTObject.ClearTiffCustomTag(); DWTObject.SetTiffCustomTag(700, "Created By DWT", false); DWTObject.SaveAsTIFF("C:\\DWT.tiff", 0); ``` --- ## ClearAllHTTPFormField() Clear all the custom fields from the HTTP Post Form. **Syntax** ```javascript ClearAllHTTPFormField(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.0+ v5.0+ v5.0+ v5.0+
--- ## SetHTTPFormField() Add a custom field to the HTTP Post Form. Or add a binary file to the HTTP Post Form. **Syntax** ```javascript SetHTTPFormField( name: string, value: string ): boolean; ``` ```javascript SetHTTPFormField( name: string, content: Blob, fileName?: string ): boolean; ``` **Parameters** `name`: The name of the field. `value`: The value of the field. `content`: The content of the file. `fileName`: The name of the file. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.0+ v5.0+ v5.0+ v5.0+
--- ## SetHTTPHeader() Add a custom header to the HTTP Post Form. **Syntax** ```javascript SetHTTPHeader( name: string, value: string ): boolean; ``` **Parameters** `name`: The name of the header. `value`: The value of the header. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v12.0+ v12.0+ v12.0+ v12.0+
--- ## SetUploadSegment() Set the segmentation threshold and segment size. **Syntax** ```javascript SetUploadSegment( threshold: number, size: number ): boolean; ``` **Parameters** `threshold`: Specify the threshold (in MB). `size`: Specify the segment size (in KB). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v12.1+ v12.1+ v12.1+ v12.1+
--- ## IfShowFileDialog Return or set whether to show open/save file dialog when saving images in the buffer or loading images from a local directory. **Syntax** ```javascript IfShowFileDialog: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## IfShowCancelDialogWhenImageTransfer Return or set whether to show the progress of an operation with a button to cancel it. **Syntax** ```javascript IfShowCancelDialogWhenImageTransfer: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.2+ v5.2+ v5.2+ v5.2+
**Usage Notes** This API is only valid if [`IfShowProgressBar`](/_articles/info/api/WebTwain_IO.md#ifshowprogressbar) is set to `true`. --- ## IfShowProgressBar Return or set whether the progress bar will be displayed during any encoding, decoding, or transfer activities. **Syntax** ```javascript IfShowProgressBar: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v11.0+ v12.1+
--- ## ShowFileDialog() Show the system's save-file dialog or open-file dialog. **Syntax** ```javascript ShowFileDialog( isSave: boolean, filter: string, filterIndex: number, defaultExtension: string, initialDirectory: string, allowMultiSelect: boolean, showOverwritePrompt: boolean, flag: number ): boolean; ``` **Parameters** `isSave`: Whether to show a save-file dialog or an open-file dialog. `filter`: The filter pattern like `JPG` or `*.jpg`. See usage notes below for details. `filterIndex`: The default file type `filter` selected in the open-file dialog. The filters are 1-indexed. Default value: 1. `defaultExtension`: Extension to be appended to the file name. Only valid in a save-file dialog. `initialDirectory`: The initial directory that the dialog opens. `allowMultiSelect`: Whether or not multiple files can be selected at the same time. Only valid in an open-file dialog. `showOverwritePrompt`: Whether to display a prompt if saving a file which would overwrite an existing file (only valid for Windows). `flag`: If set to 0, `allowMultiSelect` and `showOverwritePrompt` take effect. Otherwise, ignore those two parameters. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v11.0+ v12.1+
**Usage notes** The `filter` is a concatenation of **pattern strings** of valid file extensions. Each pattern string has a **text label**. The text label precedes the pattern string and is separated by a pipe `|`. The pattern string is a combination of semicolon-separated valid file extensions with asterisks. For example, the following is a single entry that allows JPG, PNG, and TIF: `JPG, PNG and TIF|*.jpg;*png;*.tif`. You can concatenate multiple combinations separated by pipes `|`, e.g. `BMP|*.bmp|TIF|*.tif|JPG|*.jpg|PNG|*.png|PDF|*.pdf` creates one entry for each of the five file types instead of combining multiple file types into one entry. The open-file dialog display the combinations in order in the file type drop-down. You can use the `filterIndex` argument to set the default combination to use (1-indexed). On macOS, the string is different, e.g. `JPG, PNG , TIF`. To show all files, use `All Files | *.*`. Do not include spaces in the pattern string. This method triggers the [`OnGetFilePath`](/_articles/info/api/WebTwain_IO.md#ongetfilepath) event even when it fails. If multiple files are selected, the event triggers multiple times. **Example** ```javascript DWTObject.RegisterEvent("OnGetFilePath", function (isSave, filesCount, index, directory, fileName) { alert(" directory: " + directory + "\\" + fileName); }); //On macOS DWTObject.ShowFileDialog( false, "TIF,TIFF,JPG,JPEG,PNG,PDF", 1, "", "", true, false, 0, ); //On Windows DWTObject.ShowFileDialog( false, "BMP,TIF,JPG,PNG,PDF|*.bmp;*.tif;*.png;*.jpg;*.pdf;*.tiff;*.jpeg", 1, "", "", true, false, 0, ); ``` --- ## Print() > [!NOTE] > This API has been deprecated as of release 19.3. Please use the [`PrintEX()`](#printex) function. Export all image data in the buffer to a new browser window and use the browser's built-in print feature to print the image(s). **Syntax** ```javascript Print(useOSPrintWindow?: boolean): boolean; ``` **Parameters** `useOSPrintWindow`: Whether to use the print feature of the operating system instead. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## PrintEx() Print selected image(s). **Syntax** ```javascript PrintEx(indices: number[], settings?: PrintSettings): boolean; ``` **Parameters** `indices`: Specify the image. `settings`: Settings for printing. Refer to [`PrintSettings`](/_articles/info/api/interfaces.md#printsettings). (Only available since v19.3.) **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v17.0+ v17.0+ v17.0+ v17.0+
--- ## createLocalStorage() Create a storage folder locally to save the cache of encrypted images. **Syntax** ```typescript createLocalStorage( settings?: { password?: string; } ): Promise; ``` **Parameters** `settings`: - `password`: Specify the password which is used to protect the storage folder. Up to 32 characters. **Return value** A Promise object which will be resolved with the uid string which will be used as the storage folder's name when the folder is created successfully. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.5+ v18.5+ v18.5+ v18.5+
**Usage notes** - If `password` is not specified, the returned `uid` string will be set as the password of the storage folder. - The local directory of the created storage folder is under the service's [installation folder](/_articles/extended-usage/dynamsoft-service-configuration.md#installation-folder). - The creation will not be successful, if the remaining disk space is less than | System | Remaining Disk Space | | ----------- | -------------------- | | Windows x86 | < 1.2GB | | Windows x64 | < 4GB | | macOS 32bit | < 1.2GB | | macOS 64bit | < 4GB | | Linux | < 4GB | --- ## localStorageExist() Determine whether the storage folder exists or not. **Syntax** ```typescript localStorageExist(uid: string):Promise; ``` **Parameters** `uid`: Specify the uid of the storage folder to determine. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.5+ v18.5+ v18.5+ v18.5+
--- ## saveToLocalStorage() Save encrypted image caches to the specified storage folder. **Syntax** ```typescript saveToLocalStorage( settings:{ uid: string; password?: string; maxThreads?: number; indices?: number[]; } ): Promise; ``` **Parameters** `settings`: - `uid`: Specify the storage folder to save the images cache. - `password`: The password of the specified storage folder. - `maxThreads`: The maximum number of threads used for saving. You can set this to improve the speed. The default value is 1. Available for v19.4+. Windows only. - `indices`: Specify the indices to save. - If not set, means all images in buffer. - If set to `[]`, all cache in the specified storage folder will be clear. **Return value** A Promise object which will be resolved with the array of image ids which are saved to the storage folder successfully. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.5+ v18.5+ v18.5+ v18.5+
**Usage notes** - Each time this method is called successfully, the original cache in the specified folder will be overwritten by the new cache. - The remaining disk space is calculated before saving each encrypted image caches. Subsequent saves will not be successful, if the remaining disk space is less than | System | Remaining Disk Space | | ----------- | -------------------- | | Windows x86 | < 1.2GB | | Windows x64 | < 4GB | | macOS 32bit | < 1.2GB | | macOS 64bit | < 4GB | | Linux | < 4GB | --- ## loadFromLocalStorage() Load image from the specified storage folder. **Syntax** ```typescript loadFromLocalStorage ( settings:{ uid: string; password?:string; maxThreads?: number; } ): Promise<{oriImageId: string, newImageId: string}[]>; ``` **Parameters** `settings`: - `uid`: Specify the storage folder to load the images. - `password`: The password of the specified storage folder. - `maxThreads`: The maximum number of threads used for loading. You can set this to improve the speed. The default value is 1. Available for v19.4+. Windows only. **Return value** A Promise object which will be resolved with the array of object which contains the original image id (in storage folder) and the new image id (in Web TWAIN buffer) of the loaded image. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.5+ v18.5+ v18.5+ v18.5+
--- ## removeLocalStorage() Remove the specified storage folder. **Syntax** ```typescript removeLocalStorage( settings:{ uid: string; password?: string; } ): Promise; ``` **Parameters** `settings`: - `uid`: Specify the storage folder to remove. - `password`: The password of the specified storage folder. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.5+ v18.5+ v18.5+ v18.5+
--- ## JPEGQuality Return or set the quality for JPEG compression. **Syntax** ```javascript JPEGQuality: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** The default value of `JPEGQuality` property is 80. The valid range is 0-100. The higher the `JPEGQuality` property, the better the quality and the bigger the size of the file. --- ## IfTiffMultiPage Return or set whether to append to or replace an existing TIFF file with the same name. **Syntax** ```javascript IfTiffMultiPage: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** When you save a new image in the same name of an existing TIFF file: 1. If this property is true, the new image will be added to the existing file. 2. If this property is false, the new image will replace the existing file. --- ## TIFFCompressionType Return or set the compression type for TIFF files. Please refer to [`EnumDWT_TIFFCompressionType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_tiffcompressiontype). **Syntax** ```javascript TIFFCompressionType: Dynamsoft.DWT.EnumDWT_TIFFCompressionType | number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** When set to `TIFF_AUTO` (0), 1-bit images will be compressed in `TIFF_T6` (4) while images with other bit depth will be compressed in `TIFF_LZW` (5). When set to `TIFF_JPEG` (7), 1-bit images will be compressed in `TIFF_T6` (4), color images or grey images (8-bit or higher) in `TIFF_JPEG` (7) standard, and other images by `TIFF_LZW` (5). `TIFF_T4` (3) and `TIFF_FAX3` (3) are two names for the same compression type. So are `TIFF_T6` (4) and `TIFF_FAX4` (4). `TIFF_RLE` (2), `TIFF_T4` (3), `TIFF_FAX3` (3) and `TIFF_PACKBITS` (32773) only support compression of 1-bit images. `TIFF_JPEG` (7) supports compression of 8-bit above color images and 8-bit grey images. When `TIFF_JPEG` (7) is used, you can use [`JPEGQuality`](/_articles/info/api/WebTwain_IO.md#jpegquality) to further reduce the size of the TIFF file. ## IfSortBySelectionOrder Whether to load the files by the selection order when load files by open file dialog. **Syntax** ```javascript IfSortBySelectionOrder: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.5+ v18.5+ v18.5+ v18.5+
--- title: Dynamic Web TWAIN SDK API Reference - Utility APIs description: Dynamic Web TWAIN SDK Documentation API Reference Utility APIs Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Util.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/WebTwain_Util.md --- # {WebTwainObject} Util The properties and methods on this page live in the namespace {WebTwainObject}. {WebTwainObject} denotes the `WebTwain` instance. Learn about [how to create a web twain object](/_articles/extended-usage/advanced-initialization.md#instantiating-webtwain-without-onwebtwainready). **Methods** | [`RegisterEvent()`](#registerevent) | [`UnregisterEvent()`](#unregisterevent) | [`GenerateURLForUploadData()`](#generateurlforuploaddata) | **Properties** | [`ErrorCode`](#errorcode) | [`ErrorCause`](#errorcause) | [`ErrorString`](#errorstring) | [`LogLevel`](#loglevel) | | [`Manufacturer`](#manufacturer) | [`ProductFamily`](#productfamily) | [`ProductName`](#productname) | [`VersionInfo`](#versioninfo) | --- ## RegisterEvent() Specify an event listener for the specified built-in event. **Syntax** ```typescript RegisterEvent(name: string, callback: (...arg: any[]) => void): boolean; ``` **Parameters** `name`: Specify the event. `callback`: The event listener. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** There can only be one listener for each built-in event. If you call `RegisterEvent` on the same event again, the new callback will replace the old one. --- ## UnregisterEvent() Remove an event listener from the specified built-in event. **Syntax** ```typescript UnregisterEvent(name: string, callback?: (...arg: any[]) => void): boolean; ``` **Parameters** `name`: Specify the event. `callback`: The event listener. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
--- ## GenerateURLForUploadData() Generate a URL to be used by a [FileUploader](/_articles/info/api/Dynamsoft_FileUploader.md) instance to fetch the data to upload. **Syntax** ```typescript GenerateURLForUploadData( indices: number[], type: Dynamsoft.DWT.EnumDWT_ImageType | number, successCallback: ( resultURL: string, indices: number[], type: Dynamsoft.DWT.EnumDWT_ImageType | number ) => void, failureCallback: ( errorCode: number, errorString: string ) => void ): void; ``` **Parameters** `indices`: Specify the images to upload. `type`: Specify the file type. Please refer to [`EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype). `successCallback`: A callback function that is executed if the request succeeds. - `resultURL`: The generated URL. - `indices`: The indices of the images. - `type`: The file type. Please refer to [`EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype). `failureCallback`: A callback function that is executed if the request fails. - `errorCode`: The error code. - `errorString`: The error string. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.0+ v15.1+ v15.1+ v15.1+
**Example** ```javascript var dsUploadManager; Dynamsoft.FileUploader.Init( "", function (obj) { dsUploadManager = obj; }, function () {}, ); DWTObject.GenerateURLForUploadData( [0, 1], EnumDWT_ImageType.IT_PDF, function (resultURL, newIndices, enumImageType) { var serverUrl = "https://yoursite/yourserverurl.aspx"; var jobtemp = dsUploadManager.CreateJob(); jobtemp.ServerUrl = serverUrl; jobtemp.SourceValue.Add(resultURL, "uploadedFile.pdf"); dsUploadManager.Run(jobtemp); }, function (errorCode, errorString) {}, ); ``` --- ## ErrorCode Return the error code. **Syntax** ```typescript readonly ErrorCode: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** The [`ErrorCode`](/_articles/info/api/WebTwain_Util.md#errorcode) and [`ErrorString`](/_articles/info/api/WebTwain_Util.md#errorstring) always reflect the result of the last API call. So make sure you read them in time. --- ## ErrorCause Return the error cause from the operating system. **Syntax** ```typescript readonly ErrorCause: null | {code: number, message: string}; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v19.0+ v19.0+ v19.0+ v19.0+
--- ## ErrorString Return the error string. **Syntax** ```typescript readonly ErrorString: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** The [`ErrorCode`](/_articles/info/api/WebTwain_Util.md#errorcode) and [`ErrorString`](/_articles/info/api/WebTwain_Util.md#errorstring) always reflect the result of the last API call. So make sure you read them in time. --- ## LogLevel Return or set the log level for debugging. **Syntax** ```typescript LogLevel: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** The logs for the Dynamic Web TWAIN library are saved in the `log` folder under its [installation folder](/_articles/extended-usage/dynamsoft-service-configuration.md#installation-folder). By default, `LogLevel` is 0 and nothing is recorded. When it is set to 1, all debugging information is recorded. This setting in your application will apply to all machines. Please set it back to 0 if you don't need to record log as it will slow down the speed. --- ## Manufacturer Manufacturer in the identity string of the Dynamic Web TWAIN library. **Syntax** ```typescript readonly Manufacturer: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** [`Manufacturer`](/_articles/info/api/WebTwain_Util.md#manufacturer), [`ProductFamily`](/_articles/info/api/WebTwain_Util.md#productfamily), [`ProductName`](/_articles/info/api/WebTwain_Util.md#productname) and [`VersionInfo`](/_articles/info/api/WebTwain_Util.md#versioninfo) together form the identity string of the Dynamic Web TWAIN library. --- ## ProductFamily ProductFamily in the identity string of the Dynamic Web TWAIN library. **Syntax** ```typescript readonly ProductFamily: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** [`Manufacturer`](/_articles/info/api/WebTwain_Util.md#manufacturer), [`ProductFamily`](/_articles/info/api/WebTwain_Util.md#productfamily), [`ProductName`](/_articles/info/api/WebTwain_Util.md#productname) and [`VersionInfo`](/_articles/info/api/WebTwain_Util.md#versioninfo) together form the identity string of the Dynamic Web TWAIN library. --- ## ProductName ProductName in the identity string of the Dynamic Web TWAIN library. **Syntax** ```typescript readonly ProductName: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** [`Manufacturer`](/_articles/info/api/WebTwain_Util.md#manufacturer), [`ProductFamily`](/_articles/info/api/WebTwain_Util.md#productfamily), [`ProductName`](/_articles/info/api/WebTwain_Util.md#productname) and [`VersionInfo`](/_articles/info/api/WebTwain_Util.md#versioninfo) together form the identity string of the Dynamic Web TWAIN library. --- ## VersionInfo VersionInfo in the identity string of the Dynamic Web TWAIN library. **Syntax** ```typescript readonly VersionInfo: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+
**Usage notes** [`Manufacturer`](/_articles/info/api/WebTwain_Util.md#manufacturer), [`ProductFamily`](/_articles/info/api/WebTwain_Util.md#productfamily), [`ProductName`](/_articles/info/api/WebTwain_Util.md#productname) and [`VersionInfo`](/_articles/info/api/WebTwain_Util.md#versioninfo) together form the identity string of the Dynamic Web TWAIN library.
--- title: Dynamic Web TWAIN SDK API Reference - Viewer APIs description: Dynamic Web TWAIN SDK Documentation API Reference Viewer APIs Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Viewer.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/WebTwain_Viewer.md --- # {WebTwainObject}.Viewer > {WebTwainObject} denotes the `WebTwain` instance. **Methods** | [`bind()`](#bind) | [`clearSelectedAreas()`](#clearselectedareas) | [`createCustomElement()`](#createcustomelement) | [`createImageEditor()`](#createimageeditor) | | [`createThumbnailViewer()`](#createthumbnailviewer) | [`first()`](#first) | [`fitWindow()`](#fitwindow) | [`gotoPage()`](#gotopage) | | [`getVisiblePagesInfo()`](#getvisiblepagesinfo) | [`hide()`](#hide) | [`last()`](#last) | [`next()`](#next) | | [`off()`](#off) | [`on()`](#on) | [`previous()`](#previous) | [`render()`](#render) | | [`setButtonClass()`](#setbuttonclass) | [`setSelectedAreas()`](#setselectedareas) | [`setViewMode()`](#setviewmode) | [`show()`](#show) | | [`unbind()`](#unbind) | [`updateCheckboxStyle()`](#updatecheckboxstyle) | [`updatePageNumberStyle()`](#updatepagenumberstyle) | [`updateSelectionBoxStyle()`](#updateselectionboxstyle) | **Properties** | [`acceptDrop`](#acceptdrop) | [`allowPageDragging`](#allowpagedragging) | [`allowSlide`](#allowslide) | [`autoChangeIndex`](#autochangeindex) | | [`background`](#background) | [`border`](#border) | [`cursor`](#cursor) | [`focusOutlineEnabled`](#focusoutlineenabled) | | [`height`](#height) | [`idPostfix`](#idpostfix) | [`ifAutoScroll`](#ifautoscroll) | [`innerBorder`](#innerborder) | | [`pageMargin`](#pagemargin) | [`selectedAreaBorderColor`](#selectedareabordercolor) | [`selectedPageBackground`](#selectedpagebackground) | [`selectedPageBorder`](#selectedpageborder) | | [`selectionMode`](#selectionmode) | [`selectionRectAspectRatio`](#selectionrectaspectratio) | [`singlePageMode`](#singlepagemode) | [`width`](#width) | | [`zoom`](#zoom) | [`zoomOrigin`](#zoomorigin) | | | **Events** | [`click`](#on) | [`contextmenu`](#on) | [`dblclick`](#on) | [`mousemove`](#on) | | [`mousedown`](#on) | [`mouseup`](#on) | [`mouseout`](#on) | [`mouseover`](#on) | | [`keydown`](#on) | [`keyup`](#on) | [`pageAreaSelected`](#pageareaselected) | [`pageAreaUnselected`](#pageareaunselected) | | [`pageRendered`](#pagerendered) | [`resize`](#resize) | --- ## bind() Create a Dynamsoft Viewer instance and bind it to the WebTwain instance. **Syntax** ```typescript bind(element: HTMLDivElement | HTMLElement) : boolean; ``` **Parameters** `element`: Specify an HTML element to create the viewer. **Example** ```javascript var DWTObject; Dynamsoft.DWT.CreateDWTObjectEx( { WebTwainId: "dwtControl", }, function (obj) { DWTObject = obj; DWTObject.Viewer.bind("dwtcontrolContainer"); DWTObject.Viewer.width = 600; DWTObject.Viewer.height = 800; DWTObject.Viewer.show(); }, function (err) { console.log(err); }, ); ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v17.2+ v17.2+ v17.2+ v17.2+
**Usage notes** Replace the previous `BindViewer` method. --- ## clearSelectedAreas() Clear the selected area(s) on the current page. **Syntax** ```typescript clearSelectedAreas(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Example** ```javascript DWTObject.Viewer.clearSelectedAreas(); ``` --- ## createCustomElement() Add a custom page DIV element and specify its position and display order. Generate an independent CustomElement object. **Syntax** ```typescript createCustomElement( element: HTMLDivElement, location?: string, ifFull?: boolean ): CustomElement; ``` **Parameters** `element`: Specify the HTMLDivElement. `location`: Define where to place the custom element. The allowed values are "left" and "right", and the default value is "right". `ifFull`: The default value is `false`, that is, the created [`CustomElement`](/_articles/info/api/interfaces.md#customelement) is displayed according to the set area. If set to true, the main viewer will be covered by the [`CustomElement`](/_articles/info/api/interfaces.md#customelement). **Arguments** `CustomElement`: Please refer to [`CustomElement`](/_articles/info/api/interfaces.md#customelement). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Example** ```javascript var myElement = document.createElement("div"); myElement.style = "width:100px;height:200px;background:red"; var customElement = DWTObject.Viewer.createCustomElement(myElement, "right", false); customElement.show(); ``` **Usage notes** Only one CustomElement object can be created. If you try creating another one, you'll get the error 'A CustomElement already exists.', and the existing CustomElement object will be returned. If the width defined by the CustomElement object exceeds the width of the main viewer, the width of the main viewer is used. The method [`unbind()`](/_articles/info/api/WebTwain_Viewer.md#unbind) will dispose all created CustomElement objects. --- ## createImageEditor() Generate an independent ImageEditor object. **Syntax** ```typescript createImageEditor( editorSettings?: EditorSettings ): ImageEditor; ``` **Parameters** `editorSettings`: Configure the object. Please refer to [`EditorSettings`](/_articles/info/api/interfaces.md#editorsettings). **Returns** `ImageEditor`: Please refer to [`ImageEditor`](/_articles/info/api/interfaces.md#imageeditor). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Example** > The example code shows 2 ways to use the API `createImageEditor()`
>- v18.3 >- v18.2 > > ```javascript // Use default settings var imageEditor = DWTObject.Viewer.createImageEditor(); imageEditor.zoomOrigin = {x:"center", y:"center"}; imageEditor.show(); ``` ```javascript // Use default settings var imageEditor = DWTObject.Viewer.createImageEditor(); imageEditor.show(); ```
>- v18.3+ >- v18.2 > > ```javascript // Customize the editor var editorSettings = { /* Show the editor within the DIV 'imageEditor'*/ element: document.getElementById("imageEditor"), width: 600, height: 400, border: "1px solid rgb(204, 204, 204)", 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: { previous:true, next:true, 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", ], }, workMode:Dynamsoft.DWT.EnumDWT_WorkMode.balance, zoomOrigin: { x: "center", y: "center", }, }; //Create the editor var imageEditor = DWTObject.Viewer.createImageEditor(editorSettings); imageEditor.show(); ``` ```javascript // Customize the editor var editorSettings = { /* Show the editor within the DIV 'imageEditor'*/ element: document.getElementById("imageEditor"), width: 600, height: 400, border: "1px solid rgb(204, 204, 204)", 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", ], }, workMode:Dynamsoft.DWT.EnumDWT_WorkMode.balance, }; //Create the editor var imageEditor = DWTObject.Viewer.createImageEditor(editorSettings); imageEditor.show(); ``` **Usage notes** Replace the previous `ShowImageEditor()` method. Only one ImageEditor object can be created. If you try creating it again, you'll get the error 'An ImageEditor already exists.' and the existing ImageEditor object will be returned. The method [`unbind()`](/_articles/info/api/WebTwain_Viewer.md#unbind) will dispose all created ImageEditor objects. --- ## createThumbnailViewer() Generate a independent `ThumbnailViewer` object. This `ThumbnailViewer` behaves in the same way as the default `{WebTwainObject}.Viewer`, and uses the same APIs. If a `ThumbnailViewer` object already exists, this API gives the error 'A ThumbnailViewer already exists.' and returns the existing `ThumbnailViewer` object. **Syntax** ```typescript createThumbnailViewer( thumbnailViewerSettings?: ThumbnailViewerSettings ): ThumbnailViewer; ``` **Parameters** `thumbnailViewerSettings`: Configure the `ThumbnailViewer` object. Please refer to [`ThumbnailViewerSettings`](/_articles/info/api/interfaces.md#thumbnailviewersettings). **Returns** `ThumbnailViewer`: Please refer to [`ThumbnailViewer`](/_articles/info/api/interfaces.md#thumbnailviewer). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Example** > The example code shows 2 ways to create a `ThumbnailViewer` and configure events for the new viewer. ```javascript // Use default settings var objThumbnailViewer = DWTObject.Viewer.createThumbnailViewer(); objThumbnailViewer.background = "rgb(0,0,255)"; objThumbnailViewer.show(); // Log the index of the image that the user clicked on (primary mouse button) objThumbnailViewer.on("click", function(thumbnailViewerEvent, domEvent) { console.log("Selected image index: " + thumbnailViewerEvent.index); }); // Log the width of the thumbnail container that the user clicked on (secondary mouse button) objThumbnailViewer.on("contextmenu",function(thumbnailViewerEvent, domEvent) { console.log("Width of selected thumbnail container: " + thumbnailViewerEvent.pageWidth); }); // Log the index of the image when rendered objThumbnailViewer.on("pageRendered", function(index) { console.log("Index of rendered page: " + index); }); ``` ```javascript // Customize the thumbnail viewer var thumbnailViewerSettings = { location: 'left', size: '30%', columns: 1, rows: 3, scrollDirection: 'vertical', // 'horizontal' pageMargin: 10, background: "rgb(255, 255, 255)", border: '', allowKeyboardControl: true, allowPageDragging: true, allowResizing: false, pageBackground: "transparent", pageBorder: "1px solid rgb(238, 238, 238)", hoverPageBackground: "rgb(239, 246, 253)", hoverPageBorder: "1px solid rgb(238, 238, 238)", placeholderBackground: "rgb(251, 236, 136)", selectedPageBorder: "1px solid rgb(125,162,206)", selectedPageBackground: "rgb(199, 222, 252)" }; var objThumbnailViewer = DWTObject.Viewer.createThumbnailViewer(thumbnailViewerSettings); objThumbnailViewer.show(); // Log the index of the image that the user clicked on (primary mouse button) objThumbnailViewer.on("click", function(thumbnailViewerEvent, domEvent) { console.log("Selected image index: " + thumbnailViewerEvent.index); }); // Log the width of the thumbnail container that the user clicked on (secondary mouse button) objThumbnailViewer.on("contextmenu",function(thumbnailViewerEvent, domEvent) { console.log("Width of selected thumbnail container: " + thumbnailViewerEvent.pageWidth); }); // Log the index of the image when rendered objThumbnailViewer.on("pageRendered", function(index) { console.log("Index of rendered page: " + index); }); ``` **Usage notes** The method [`unbind()`](/_articles/info/api/WebTwain_Viewer.md#unbind) will dispose all created ThumbnailViewer objects. For the `CheckboxSettings` and `PageNumberSettings` interface, please refer to the APIs [`updateCheckboxStyle()`](/_articles/info/api/WebTwain_Viewer.md#updatecheckboxstyle) and [`updatePageNumberStyle()`](/_articles/info/api/WebTwain_Viewer.md#updatepagenumberstyle). The following table shows the events available to a ThumbnailViewer object. | Event Name | Arguments | Description | | :------------- | :------------------------------------------------ | :------------------------------------------------------------------- | | `click` | event: [ThumbnailViewerEvent](/_articles/info/api/interfaces.md#thumbnailviewerevent), domEvent: [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent){:target="_blank"} | Triggered upon primary mouse click | | `dblclick` | event: [ThumbnailViewerEvent](/_articles/info/api/interfaces.md#thumbnailviewerevent), domEvent: [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent){:target="_blank"} | Triggered upon primary mouse double click | | `contextmenu` | event: [ThumbnailViewerEvent](/_articles/info/api/interfaces.md#thumbnailviewerevent), domEvent: [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent){:target="_blank"} | Triggered upon secondary mouse click | | `mousemove` | event: [ThumbnailViewerEvent](/_articles/info/api/interfaces.md#thumbnailviewerevent), domEvent: [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent){:target="_blank"} | Triggered upon mouse movements within the `ThumbnailViewer` | | `mousedown` | event: [ThumbnailViewerEvent](/_articles/info/api/interfaces.md#thumbnailviewerevent), domEvent: [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent){:target="_blank"} | Triggered upon pressing down the primary mouse button | | `mouseup` | event: [ThumbnailViewerEvent](/_articles/info/api/interfaces.md#thumbnailviewerevent), domEvent: [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent){:target="_blank"} | Triggered upon releasing the primary mouse button | | `resize` | width:number, height:number | Triggered when the width or height of the `ThumbnailViewer` object changes | | `pageRendered` | index: number | Triggered when a page becomes rendered. | | `mouseout` | event: [ThumbnailViewerEvent](/_articles/info/api/interfaces.md#thumbnailviewerevent), domEvent: [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent){:target="_blank"} | Triggered upon the mouse leaving the `ThumbnailViewer`; **only supported on desktop browsers** | | `mouseover` | event: [ThumbnailViewerEvent](/_articles/info/api/interfaces.md#thumbnailviewerevent), domEvent: [MouseEvent](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent){:target="_blank"} | Triggered upon mouse hovering over the `ThumbnailViewer`; **only supported on desktop browsers** | | `keydown` | keyboardEvent: KeyboardEvent | Triggered upon pressing a key; **only supported on desktop browsers** | | `keyup` | keyboardEvent: KeyboardEvent | Triggered upon releasing a key; **only supported on desktop browsers** | --- ## first() Show the first page and return the index which should be 0. If there is no page in the viewer, -1 is returned. **Syntax** ```typescript first():number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Example** ```javascript DWTObject.Viewer.first(); ``` --- ## fitWindow() Set how the page is fit in the viewer. **Syntax** ```typescript fitWindow( type?: string ): void ``` **Parameters** `type`: Specify how to fit. Allowed values are "width" and "height" **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Example** ```javascript DWTObject.Viewer.fitWindow(); ``` **Usage notes** This API only works if the view mode of the viewer is set to -1 by -1 ([`singlePageMode`](/_articles/info/api/WebTwain_Viewer.md#singlepagemode) is true). The allowed values are width: Fit the page vertically. height: Fit the page horizontally. If no parameter is provided, it tries to fit the whole page within the viewer. --- ## getVisiblePagesInfo() Return the information of visible pages. It is useful to add elements to document page images in the viewer. Please refer to [`VisiblePageInfo`](/_articles/info/api/interfaces.md#visiblepageinfo). **Syntax** ```typescript getVisiblePagesInfo():VisiblePageInfo[]; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v19.1+ v19.1+ v19.1+ v19.1+
--- ## gotoPage() Show the specified page and return its index. **Syntax** ```typescript gotoPage( index: number ): number; ``` **Parameters** `index`: Specify the page. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Example** ```javascript DWTObject.Viewer.gotoPage(0); ``` --- ## hide() Hide the viewer. **Syntax** ```typescript hide(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Example** ```javascript DWTObject.Viewer.hide(); ``` --- ## last() Show the last page and return its index. If there is no page in the viewer, -1 is returned. **Syntax** ```typescript last():number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Example** ```javascript DWTObject.Viewer.last(); ``` --- ## next() Show the next page and return its index. If there is no page in the viewer, -1 is returned. **Syntax** ```typescript next(): number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Example** ```javascript DWTObject.SelectImages([3]); //Select the 4th page. var currentIndex = DWTObject.Viewer.next(); // return 4 which represents the 5th page. ``` --- ## previous() Show the previous page and return its index. If there is no page in the viewer, -1 is returned. **Syntax** ```typescript previous(): number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Example** ```javascript DWTObject.SelectImages([3]); //Select the 4th page. var currentIndex = DWTObject.Viewer.previous(); // return 2 which represents the 3rd page. ``` --- ## render() Refresh the viewer. **Syntax** ```typescript render(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Example** ```javascript DWTObject.Viewer.on("pageRendered", function (index) { console.log(index); }); DWTObject.Viewer.render(); //It will trigger the pageRendered event ``` --- ## setButtonClass() Set the CSS class name of the specified button. **Syntax** ```typescript setButtonClass( name: string, className: string ): boolean; ``` **Parameters** `name`: Specify the button. `className`: Specify the CSS class name. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.0+ v16.0+ v16.0+ v16.0+
**Usage notes** Use this method to fine-tune the buttons in the viewer with CSS. **Example** ```javascript DWTObject.Viewer.setButtonClass("crop", "CropClass"); ``` --- ## setSelectedAreas() Set one or more rectangular area(s) on the current page. **Syntax** ```typescript setSelectedAreas( areas: Area[] ): boolean; ``` **Parameters** `areas`: Specify the rectangular area(s). Please refer to [`Area`](/_articles/info/api/interfaces.md#area). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Usage notes** The coordinates are based on the size of the original page (instead of the size of the viewer). This method only works when [`cursor`](/_articles/info/api/WebTwain_Viewer.md#cursor) is set to "crosshair". **Example** ```javascript DWTObject.Viewer.setSelectedAreas([ { left: 0, top: 0, right: 100, bottom: 100, }, { left: 200, top: 200, right: 400, bottom: 500, }, ]); ``` --- ## setViewMode() Set the view mode of the viewer. **Syntax** ```typescript setViewMode( columns: number, rows: number ): boolean; ``` **Parameters** `columns`: Specify the number of images per column. `rows`: Specify the number of images per row. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.1+ v16.1+ v16.1+ v16.1+
**Usage notes** Setting the view mode as -1 by -1 is equivalent to setting [`singlePageMode`](/_articles/info/api/WebTwain_Viewer.md#singlepagemode) to true. **Example** ```javascript DWTObject.Viewer.setViewMode(2, 2); ``` --- ## show() Show the viewer. **Syntax** ```typescript show(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Example** ```javascript DWTObject.Viewer.show(); ``` --- ## unbind() Unbind and destroy the viewer. **Syntax** ```typescript unbind(): boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Usage notes** Replace the previous `UnbindViewer` method. **Example** ```javascript DWTObject.Viewer.unbind(); ``` --- ## acceptDrop Set whether to load files dropped over the viewer area. The default value is true. **Syntax** ```typescript acceptDrop: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Example** ```javascript DWTObject.Viewer.acceptDrop = true; ``` --- ## allowSlide Set whether to allow image navigation by swiping left or right on the viewer. The default value is true. ```typescript allowSlide: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Usage notes** This API only works if the view mode of the viewer is set to -1 by -1. **Example** ```javascript DWTObject.Viewer.allowSlide = true; ``` --- ## allowPageDragging Set whether to allow page dragging to reorder the pages in the viewer. The default value is true. ```typescript allowPageDragging: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v17.3+ v17.3+ v17.3+ v17.3+
**Example** ```javascript DWTObject.Viewer.setViewMode(2, 2); DWTObject.Viewer.cursor = "pointer"; DWTObject.Viewer.allowPageDragging = false; //Disable drag&drop. ``` --- ## background Return or set the background of the viewer. **Syntax** ```typescript background: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Usage notes** Replace the previous `BackgroundColor` method. Now you can specify the background by CSS which may be a single color or even an image. Read more on the [background shorthand CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/background). **Example** ```javascript DWTObject.Viewer.background = "rgb(255, 255, 255)"; ``` --- ## border Return or set the border of the viewer. **Syntax** ```typescript border: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Usage notes** The default value is "1px solid rgb(204, 204, 204)". Now you can specify the border by CSS. Read more on the [border shorthand CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/border). **Example** ```javascript DWTObject.Viewer.border = "2px solid rgb(204, 204, 204)"; ``` --- ## cursor Return or set the shape of the cursor. **Syntax** ```typescript cursor: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Usage Notes** The allowed values are: | Value | Description | | :---------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- | | `default` | The shape is ![default](/assets/imgs/default.gif). | | `crosshair` | The shape is ![crosshair](/assets/imgs/crosshair.gif)(default setting), you can select one or multiple area(s) on the page. | | `pointer` | The shape is ![pointer](/assets/imgs/pointer.gif). If the displayed page is bigger than the viewer, the page can be moved. | | `zoom-in` | The shape is ![zoom-in](/assets/imgs/zoom-in.gif), supports click the page to zoom in. Only works if the view mode of the viewer is set to -1 by -1. | If there are selected areas on the page, changing the `cursor` property will clear them. **Example** ```javascript DWTObject.Viewer.cursor = "crosshair"; ``` --- ## focusOutlineEnabled Control whether the viewer removes the focus border after selecting with the Tab key - defaults to `false` to remove the focus border. **Syntax** ```typescript focusOutlineEnabled: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v19.2+ v19.2+ v19.2+ v19.2+
--- ## height Return or set the height of the viewer. **Syntax** ```typescript height: number | string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Usage Notes** If a number is assigned, it means that number of pixels (px). If a string is assigned, it is either a fixed size like "500px" or a dynamic size like "50%" which follows standard CSS rules. When reading the property, the value is always in pixels no matter what value was set to it. **Example** ```javascript DWTObject.Viewer.height = 350; DWTObject.Viewer.height = "350px"; DWTObject.Viewer.height = "100%"; ``` --- ## idPostfix Return the postfix of the Ids of the elements in the viewer. **Syntax** ```typescript readonly idPostfix: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Example** ```javascript var myViewerIdPostfix = DWTObject.Viewer.idPostfix; ``` --- ## ifAutoScroll Return or set whether to scroll the viewer automatically when new pages are imported. Default: true; **Syntax** ```typescript ifAutoScroll: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Example** ```javascript DWTObject.Viewer.ifAutoScroll = false; ``` --- ## innerBorder Return or set the inner border of the viewer. **Syntax** ```typescript innerBorder: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Example** ```javascript DWTObject.Viewer.innerBorder = "1px solid rgb(204, 204, 204)"; ``` **Usage notes** The default value is null. You can specify the border by CSS. Read more on the [border shorthand CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/border). --- ## pageMargin Return or set the margin between images. **Syntax** ```typescript pageMargin: number | string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Usage Notes** The page margin is only effective when the view mode is not -1 \* -1 (in other words, [`singlePageMode`](/_articles/info/api/WebTwain_Viewer.md#singlepagemode) is `false` ). **Example** ```javascript DWTObject.Viewer.pageMargin = 10; ``` --- ## selectedAreaBorderColor > [!NOTE] > This API has been deprecated as of release 18.4. Please use the [`updateSelectionBoxStyle()`](/_articles/info/api/WebTwain_Viewer.md#updateselectionboxstyle) function. Set the border color of the selected area. Also applies to the selection box on the video opened by the method `showVideo`. **Syntax** ```typescript selectedAreaBorderColor: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Usage notes** The default value is "rgba(0, 0, 0, 1)". **Example** ```javascript DWTObject.Viewer.selectedAreaBorderColor = "rgba(0, 0, 0, 1)"; ``` --- ## selectedPageBackground Set the selected page background color of the Thumbnail viewer. **Syntax** ```typescript selectedPageBackground: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Usage notes** The default value is "rgb(199, 222, 252)". You can specify the background by CSS which may be a single color or even an image. Read more on the [background shorthand CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/background). **Example** ```javascript DWTObject.Viewer.selectedPageBackground = "rgb(255, 0, 0)"; ``` --- ## selectedPageBorder Return or set the border style for selected page(s). **Syntax** ```typescript selectedPageBorder: string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Usage Notes** This API is only effective when the view mode is not -1 \* -1 (in other words, [`singlePageMode`](/_articles/info/api/WebTwain_Viewer.md#singlepagemode) is `false` ). The default value is "1px solid rgb(125, 162, 206)". Now you can specify the border by CSS. Read more on the [border shorthand CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/border). **Example** ```javascript DWTObject.Viewer.selectedPageBorder = "3px solid rgb(125,162,206)"; ``` --- ## selectionRectAspectRatio Specify an aspect ratio to be used when selecting an rectangular area on a page. **Syntax** ```typescript selectionRectAspectRatio: number | string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Usage Notes** This API is only effective when drawing manually (it won't work if the selection is done with the API [`setSelectedAreas()`](/_articles/info/api/WebTwain_Viewer.md#setselectedareas)). **Example** ```javascript DWTObject.Viewer.selectionRectAspectRatio = 0.5; ``` --- ## singlePageMode Set whether to use single page mode. **Syntax** ```typescript singlePageMode: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Usage notes** The default value is `false`. If the thumbnail viewer is not shown, setting `singlePageMode` to `true` is equivalent to setting the view mode to -1 by -1. But if the thumbnail viewer is shown, `singlePageMode` will be changed to `true` automatically. **Example** ```javascript // Use single page mode in the main viewer DWTObject.Viewer.singlePageMode = true; ``` ```javascript // Use single page mode in the thumbnail viewer var objThumbnailViewer = DWTObject.Viewer.createThumbnailViewer(); objThumbnailViewer.show(); DWTObject.Viewer.singlePageMode = true; ``` --- ## updateSelectionBoxStyle() Sets the graphical style for the selection box in the Viewer. **Syntax** ```javascript updateSelectionBoxStyle(selectionBoxStyleSettings?: SelectionBoxStyleSettings): boolean; ``` **Parameters** `selectionBoxStyleSettings`: Selection box settings. Please refer to [`SelectionBoxStyleSettings`](/_articles/info/api/interfaces.md#selectionboxstylesettings) for details. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.4+ v18.4+ v18.4+ v18.4+
**Example** ```javascript let styleSettings = { borderColor: "rgba(255, 105, 110, 1)", borderWidth: 4, lineDash: [4, 2], handleWidth: 10, handleHeight: 10, handleColor: "rgba(252, 92, 255, 1)", }; DWTObject.Viewer.updateSelectionBoxStyle(styleSettings); ``` **Usage Notes** If creating an `ImageEditor` object, the `Viewer` styling will be inherited by the `ImageEditor` on creation, but styles will be maintained separately. That is to say that after creating the `ImageEditor`, changing one style will not affect the other. --- ## width Return or set the width of the viewer. **Syntax** ```typescript width: number | string; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Usage Notes** If a number is assigned, it means that number of pixels (px). If a string is assigned, it is either a fixed size like "500px" or a dynamic size like "50%" which follows standard CSS rules. When reading the property, the value is always in pixels no matter what value was set to it. **Example** ```javascript DWTObject.Viewer.width = 270; DWTObject.Viewer.width = "270px"; DWTObject.Viewer.width = "100%"; ``` --- ## zoom Return or set the zoom factor, and then the current page will be enlarged or reduced. **Syntax** ```typescript zoom: number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Usage Notes** The zoom factor is only effective when the view mode is -1 \* -1. Allowed values is from 0.02 to 65. **Example** ```javascript DWTObject.Viewer.zoom = 2.0; ``` --- ## autoChangeIndex Set whether to make sure the first image in the viewer is always selected when scrolling through multiple images. The default value is false. **Syntax** ```typescript autoChangeIndex: boolean; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v17.0+ v17.0+ v17.0+ v17.0+
**Usage Notes** When set to true, the index in the upper left corner of the viewer will be selected when scrolling. **Example** ```javascript DWTObject.Viewer.autoChangeIndex = true; ``` --- ## updateCheckboxStyle() Update checkbox style **Syntax** ```typescript updateCheckboxStyle(checkboxSettings?: CheckboxSettings): boolean; ``` **Parameters** `checkboxSettings`: Settings for checkboxes. Please refer to [`CheckboxSettings`](/_articles/info/api/interfaces.md#checkboxsettings). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v17.3+ v17.3+ v17.3+ v17.3+
--- ## updatePageNumberStyle() Update page number style **Syntax** ```typescript updatePageNumberStyle(pageNumberSettings?: PageNumberSettings): boolean; ``` **Parameters** `pageNumberSettings`: Settings for page numbers. Please refer to [`PageNumberSettings`](/_articles/info/api/interfaces.md#pagenumbersettings). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v17.3+ v17.3+ v17.3+ v17.3+
--- ## selectionMode Return or set the selection mode used. **Syntax** ```typescript selectionMode: Dynamsoft.DWT.EnumDWT_SelectionMode | number; ``` **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v17.3+ v17.3+ v17.3+ v17.3+
**Usage notes** The default value is 0 (Single). Even if checkbox is used, only one image can be selected if the selection mode is set to 0 (Single). Please refer to [`EnumDWT_SelectionMode`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_selectionmode). **Example** ```javascript DWTObject.Viewer.setViewMode(2, 2); DWTObject.Viewer.cursor = "pointer"; DWTObject.Viewer.updateCheckboxStyle({ visibility: "visible", }); DWTObject.Viewer.selectionMode = Dynamsoft.DWT.EnumDWT_SelectionMode.Multiple; // Multiple Selection ``` --- ## zoomOrigin Set the zoom origin. **Syntax** ```typescript zoomOrigin: { x: string; y: string; } ``` **Parameters** `x`: x-coordinate. Default is "center", values: "left", "right", "center". `y`: y-coordinate. Default is "center", values: "top", "bottom", "center". **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.3+ v18.3+ v18.3+ v18.3+
**Usage notes** The default value is `{x:"center", y:"center"}`, which means the zoom origin is center point of the image. **Example** ```javascript DWTObject.Viewer.zoomOrigin = { x: "left", y: "top" }; // Set the zoom origin to top left corner. ``` --- ## Events ### on() Built-in callbacks that are triggered for a certain mouse event or keyboard event on a page. **Syntax** ```typescript on( eventName: string, callback: (dwtEvent: ViewerEvent | KeyboardEvent, domEvent: MouseEvent) => void ): void; ``` **Parameters** `eventName`: Specify the event. Value: click, contextmenu, dblclick, mousemove, mousedown, mouseup, mouseout, mouseover, keydown, keyup, pageAreaSelected, pageAreaUnselected, pageRendered and resize. `callback`: Specify the callback. - `dwtEvent`: The viewer-specific event object. Please refer to [`ViewerEvent`](/_articles/info/api/interfaces.md#viewerevent) and `KeyboardEvent`. - `domEvent`: The original mouse event object. Please refer to `MouseEvent`. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Usage notes** The events `mouseout`, `mouseover`, `keydown` and `keyup` are only triggered on desktop browsers. **Example** ```javascript DWTObject.Viewer.on("click", function (dwtEvent, domEvent) { console.log(dwtEvent, domEvent); }); DWTObject.Viewer.on("dblclick", function (dwtEvent, domEvent) { console.log(dwtEvent, domEvent); }); DWTObject.Viewer.on("contextmenu", function (dwtEvent, domEvent) { console.log(dwtEvent, domEvent); }); DWTObject.Viewer.on("mousemove", function (dwtEvent, domEvent) { console.log(dwtEvent, domEvent); }); DWTObject.Viewer.on("mousedown", function (dwtEvent, domEvent) { console.log(dwtEvent, domEvent); }); DWTObject.Viewer.on("mouseup", function (dwtEvent, domEvent) { console.log(dwtEvent, domEvent); }); DWTObject.Viewer.on("mouseout", function (dwtEvent, domEvent) { console.log(dwtEvent, domEvent); }); DWTObject.Viewer.on("mouseover", function (dwtEvent, domEvent) { console.log(dwtEvent, domEvent); }); DWTObject.Viewer.on("keydown", function (keyboardEvent) { console.log(keyboardEvent); }); DWTObject.Viewer.on("keyup", function (keyboardEvent) { console.log(keyboardEvent); }); ``` ### off() Unbind event listener(s) from the specified viewer event. **Syntax** ```typescript off( eventName: string, callback?: () => void ): void; ``` **Parameters** `eventName`: Specify the event. `callback`: Specify the listener to remove **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Example** ```javascript DWTObject.Viewer.off("pageAreaSelected"); ``` **Usage notes** If no listener is specified, all listeners will be removed. --- ### pageAreaSelected This event is triggered when user selects an area (draws a rectangle) or move a selected area on the current page. **Syntax** ```typescript on('pageAreaSelected', (index: number, rect: rect[])=> void ): void; ``` **Parameters** `index`: The index of the current page. `rect`: Some attribute values of the selected area. Please refer to [`rect`](/_articles/info/api/interfaces.md#rect). **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Example** ```javascript DWTObject.Viewer.on("pageAreaSelected", function (sImageIndex, rect) { console.log(sImageIndex); }); DWTObject.Viewer.off("pageAreaSelected"); ``` --- ### pageAreaUnselected This event is triggered when selected area(s) get cleared (when the user clicks outside of the drawn rectangle). **Syntax** ```typescript on('pageAreaUnselected', (index: number) => void ): void; ``` **Parameters** `index`: The index of the current page. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Example** ```javascript DWTObject.Viewer.on("pageAreaUnselected", function (sImageIndex) { console.log("The selected areas on the page with index " + sImageIndex + " have been cleared"); }); DWTObject.Viewer.off("pageAreaUnselected"); ``` --- ### pageRendered This event is triggered when a page is rendered. **Syntax** ```typescript on('pageRendered', (index: number) => void ): void; ``` **Parameters** `index`: The index of the current page. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Example** ```javascript DWTObject.Viewer.on("pageRendered", function (index) { console.log(index); }); DWTObject.Viewer.render(); //It will trigger the pageRendered event ``` --- ### resize This event is triggered when width & height of the viewer has been changed. **Syntax** ```typescript on('resize', (width: number, height: number) => void ): void; ``` **Parameters** `width`: The new width of the viewer. `height`: The new height of the viewer. **Availability**
H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v16.2+ v16.2+ v16.2+ v16.2+
**Example** ```javascript DWTObject.Viewer.on("resize", function (width, height) { console.log(width, height); }); DWTObject.Viewer.width = 100; ``` ---
--- title: Dynamic Web TWAIN SDK API - Appendix description: Dynamic Web TWAIN SDK Documentation API Appendix Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/api/appendix.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/appendix.md --- # Web TWAIN Appendix ## Error List | Error Code | Error Message | |:-|:-| |0 | Successful | |-1001 | General failure | |-1002 | Not enough memory to perform operation | |-1003 | Source Manager unable to find the specified Source | |-1004 | Source is connected to maximum supported number of applications | |-1005 | Source or Source Manager reported an error to the user and handled the error | |-1006 | Capability not supported by Source or operation is not supported on capability, or capability had dependencies on other capabilities and cannot be operated upon at this time | |-1009 | Unrecognized operation triplet | |-1010 | Data parameter out of supported range | |-1011 | Operation out of expected sequence | |-1012 | Unknown destination in DSM_Entry | |-1013 | Capability not supported by source | |-1014 | Operation not supported by capability | |-1015 | Capability has dependency on other capability and cannot be operated upon at this time | |-1016 | File System operation is denied (file is protected) | |-1017 | Operation failed because file already exists | |-1018 | File not found | |-1019 | Operation failed because directory is not empty | |-1020 | The feeder is jammed | |-1021 | The feeder detected multiple pages | |-1022 | Error writing file | |-1023 | The device went offline prior to or during this operation | |-1030 | Can not open Source Manager "TWain_32.dll" is missing or is in use by another application | |-1031 | Sequence error. The operation can not be performed upon the current Source Manager or Source state | |-1032 | User cancelled the operation | |-1033 | Invalid Enumerations | |-1034 | Invalid value | |-1035 | There is no image | |-1036 | Error reading file | |-1070 | BMP file or format error | |-1071 | JPEG file or format error | |-1073 | Only 24-bit true color and 8-bit gray-scaled images are supported for JPEG compression | |-1080 | General TIFF error | |-1081 | TIFF format error or not supported | |-1090 | BMP format error or not supported | |-1100 | PNG format error or not supported | |-1110 | Unrecognized file extension | |-1119 | This PDF file is not supported by the Core module. You may need to activate your PDF Rasterizer license to support this PDF file. Please contact support for further information. | |-1120 | Failed to read the PDF file because it's encrypted and the correct password is not provided. | |-1126 | The specified module could not be found. | |-1200 | PDF format error or not supported | |-2007 | The system is busy, some operations are not completed. Please try later | |-2137 | Cross-Origin Resource Sharing (CORS) policy is blocking the access. Please contact the Administrator to configure 'Access-Control-Allow-Origin'.| |-2207 | The Dynamic Web TWAIN Service installed on your computer is outdated and no longer works with the JavaScript code on the website \| The installed Dynamic Web TWAIN Service (old version) is incompatible with the JavaScript version x.x.x used on this website. \| The installed Dynamic Web TWAIN Service (version x.x.x) is incompatible with the JavaScript version x.x.x used on this website. | |-2208 | The connection with the local Dynamic Web TWAIN Service encountered a problem and has been reset | |-2209 | The HTML5 (Chrome&Firefox) edition does not support this method or property | |-2210 | You cannot call this method on this WebTwain instance because it does not use the default viewer. | |-2211 | The element is already bound to the viewer. | |-2217 | Missing dependent files for OCR Kit. | |-2300 | Http upload error: the HTTP Server cannot empty | |-2301 | Network error | |-2302 | The result format is invalid | |-2303 | Upload cancelled | |-2304 | Http download error: the url is invalid | |-2305 | User cancelled the operation | |-2306 | Upload Error: the upload file cannot be empty | |-2307 | The width or height you entered is invalid | |-2308 | The Dynamic Web TWAIN Service has been stopped | |-2309 | The LocalFile is empty in the Function | |-2310 | The Enumerations is out of range | |-2311 | The RemoteFile is empty in Barcode Download Function | |-2312 | The file length is empty | |-2313 | The size of the images you are about to upload has exceeded the allowed size | |-2314 | The parameter cannot be empty | |-2315 | The Enumerations is out of range | |-2316 | The RemoteFile is empty in Webcam Download Function | |-2317 | The RemoteFile is empty in Pdf Download Function | |-2318 | Invalid destination file | |-2319 | Invalid source file | |-2320 | Invalid file | |-2321 | The Enumerations is out of range | |-2322 | The left or top or right or bottom you entered is invalid | |-2325 | The license is invalid. \| The current product key is empty or invalid. | |-2326 | The Dynamic Web TWAIN license expired${sDate}. Please contact the website developer for further assistance. \| The document scanning SDK license expired${sDate}. Please contact the website developer for further assistance. \| The Dynamic Web TWAIN product key expired${sDate}. Please contact the website developer for further assistance. \| The document scanning SDK product key expired${sDate}. Please contact the website developer for further assistance. | |-2327 | The current product key does not support Chrome. Please contact the site administrator | |-2328 | The current product key does not support Firefox. Please contact the site administrator | |-2329 | The current product key does not support IE. Please contact the site administrator | |-2330 | The current product key does not support Edge. Please contact the site administrator | |-2338 | The current product key does not support Webcam. Please contact the site administrator | |-2339 | The current product key does not support pdf rasterizer. Please contact the site administrator | |-2340 | The license for the module OCR Kit is not found or has expired. | |-2342 | The domain of your current site does not match the domain bound in the current product key. Please contact the site administrator | |-2343 | The current product key does not support your browser. Please contact the site administrator | |-2344 | The current product key does not support Windows OS. Please contact the site administrator | |-2345 | The current product key does not support MAC OS. Please contact the site administrator | |-2346 | The current product key does not support Linux OS. Please contact the site administrator | |-2347 | The current product key does not support your OS. Please contact the site administrator | |-2348 | The current product key is invalid because it's generated with the licenses of a different major version | |-2349 | The current product key does not include a license for reading barcode. Please contact the site administrator | |-2350 | The indices cannot be empty | |-2351 | You cannot upload more than one image when the format is BMP, JPG or PNG | |-2352 | The indices are out of range | |-2353 | The header name being used is a protected keyword and is not allowed | |-2354 | The header name cannot be empty | |-2355 | The header name cannot be null | |-2356 | The header name cannot be undefined | |-2357 | The header name you entered is invalid | |-2358 | The type of the parameter indices must be an Array | |-2359 | The Enumerations is out of range | |-2360 | The Enumerations is null or undefined | |-2361 | You cannot convert more than one image to base64 string when the format is BMP, JPG or PNG | |-2362 | Convert to base64 failed | |-2363 | The data format is not supported. | |-2365 | The url is invalid. | |-2366 | Converting images to a base64 string failed. | |-2367 | Invalid value for the parameter segmentUploadThreshold | |-2368 | Invalid value for the parameter moduleSize | |-2369 | The module for Dynamic Web TWAIN has failed to download | |-2370 | The current product key is invalid. Please contact the site administrator | |-2372 | You cannot convert more than one image to binary when the format is BMP, JPG or PNG | |-2375 | The left or top or right or bottom you entered is invalid. | |-2376 | The generate url failed. | |-2377 | Failed to set Image Capture Driver Type. | |-2378 | Invalid value for the tiff tag code. | |-2380 | Please make sure the Uploader Module has been installed. | |-2381 | scanSetup is invalid. | |-2382 | Scanner setup error: Invalid Transfer Mode. | |-2383 | Scanner setup error: fileXfer is invalid. | |-2384 | Scanner setup error: Invalid fileName in fileXfer. | |-2385 | Scanner setup error: Invalid fileFormat in fileXfer. | |-2386 | Output setup error: Invalid httpParams in outputSetup. | |-2387 | Output setup error: Invalid type in outputSetup. | |-2388 | Output setup error: Invalid url in outputSetup.httpParams. | |-2389 | Output setup error: Invalid fileName in outputSetup.httpParams. | |-2390 | Output setup error: Invalid format in outputSetup. | |-2391 | Invalid event name. | |-2392 | The current product key does not support Safari. Please contact the site administrator. | |-2393 | Failed to convert the data to blob. | |-2394 | Invalid tag name. | |-2395 | The module for Dynamic Web TWAIN failed to download.| |-2396 | The current product key is invalid. Please contact the site administrator. | |-2397 | API + " doesn't work under current settings." | |-2399 | Invalid imageId.| |-2400 | API + " doesn't work under current settings." | |-2401 | Failed to load image: XXX | |-2416 | Invalid parameter. | |-2417 | The left or top or right or bottom you entered is invalid. | |-2418 | The width you entered is invalid. | |-2419 | The height you entered is invalid. | |-2420 | The width or height is out of image size. | |-2423 | The index is invalid. | |-2426 | You have used a full license with a trial license which is not permitted. Please check and update Dynamsoft.DWT.ProductKey. | |-2428 | Tiff tag count has exceeded the limit. | |-2429 | The method SelectSource() must be invoked asynchronously (i.e. with callback functions) when ImageCaptureDriverType is set to TWAIN_AND_ICA or TWAIN_AND_TWAIN64. | |-2432 | Operation in progress, please try again when the current operation has finished. | |-2436 | Mixed Content: The page at "' + url + '" was loaded over HTTPS, but requested an insecure resource "' + serverUrl + '/ddm/18625/ddm/SearchScanner". This request has been blocked; the content must be served over HTTPS. | |-2438 | SelectSource cannot be used synchronously when Object is created by CreateRemoteScanObjectAsync. Please use SelectSourceAsync instead. | |-2439 | You cannot call the method bindViewer() when Dynamsoft.DWT.UseDefaultViewer is set to false. | |-2444 | A license can only be specified once and has already been set using the ProductKey API. | |-2500 | An ImageEditor already exists. | |-2501 | A ThumbnailViewer already exists. | |-2502 | A CustomElement already exists. | |-2504 | The ImageEditor object has been disposed. | |-2505 | This ThumbnailViewer doesn't exist. | |-2506 | The ThumbnailViewer object has been disposed. | |-2507 | This CustomElement doesn't exist. | |-2508 | The CustomElement object has been disposed. | |-2510 | The callback is not a function. | |-2511 | Parameter 'element' is required. | |-2512 | Parameter 'element' doesn't instanceof HTMLDivElement. | |-2513 | The WebTwain instance has been destroyed and can not be used anymore. | |-2514 | Invalid property value. | |-2517 | Old tag name is required. | |-2518 | New tag name is required. | |-2519 | The current mode does not support setting the cursor to zoom. | |-2530 | Document name cannot be empty. | |-2531 | Document name is not a string. | |-2539 | The current product key is not for version ${currentVer}. Please contact the site administrator. | |-2540 | The document does not exist. | |-2541 | The document already exists. | |-2543 | You are using two different generations of Dynamsoft licenses. Please check the "Dynamsoft.DWT.ProductKey" specified in your application. | |-2546 | The license is invalid. | |-2548 | You cannot call this function when Dynamsoft.DWT.UseDefaultViewer is set to false. | |-2549 | You cannot call this function when there is no ui binding. | |-2612 | The devices must be an Array. | |-2613 | The Dynamic Web TWAIN Service on ${serviceName} has been stopped. | |-2614 | The Dynamic Web TWAIN Service has been restarted. | |-2615 | User cancelled the operation. | |-2616 | Invalid image format type. | |-2618 | Only single index selection is allowed when enumImageType is set to BMP, JPG or PNG. | |-2619 | Only single index selection is allowed when enumImageFormatType is set to url. | |-2620 | The RemoteScan object has been disposed. | |-2621 | Dynamsoft.DWT.Containers was not set. | |-2622 | Please do not set enumImageType to "IT_MULTIPAGE_PDF", "IT_MULTIPAGE_TIF" or "IT_ALL". | |-2623 | Saving multiple images is not allowable when the selected output format is BMP, JPG or PNG. | |-2624 | The element within Dynamsoft.DWT.Containers should be a valid object. | |-2625 | Error: The WebTwainId cannot be empty string while creating a Dynamic Web TWAIN object. | |-2626 | Error: The ContainerId cannot be empty string while creating a Dynamic Web TWAIN object. | |-2701 | The OCR Kit feature is only supported on x64 versions of Windows. | |-2800 | Please make sure the Dynamic Web TWAIN Service has been installed. | |-2801 | Invalid response data was returned from the Dynamic Web TWAIN Service. | |-2802 | The file dynamsoft.webtwain.config.js timed out while loading. | |-2803 | Loading the WebTwain JavaScript source files has failed. | |-2804 | Loading the WebTwain css files has failed. | |-2805 | Error: The "WebTwainId" is not a string. | |-2806 | Error: The argument passed to the parameter "containerId" is not a string. | |-2807 | Error: The element specified by the id XXX doesn't exist. | |-2808 | The license for v' + majorVersion + ' Service Core Module has expired. | |-2809 | The license for v' + majorVersion + ' Service Core Module is not found. | |-2810 | The product key for the current operating system is missing the Service Core license. Please contact the site administrator. \| The current product key does not support REST Call for the current operating system. | |-2812 | Error: Duplicate ID detected while creating a Dynamic Web TWAIN object. | |-2813 | Error: The ID of the target DIV for the new DWT object is invalid. | |-2814 | Error: The Dynamic Web TWAIN module is not installed. | |-2815 | Error: Duplicate ContainerId detected while creating a Dynamic Web TWAIN object. | |-2816 | HTTP process error: XXX | |-2817 | The Connection from the insecure (HTTP) web page failed for HTST. | |-2818 | The Dynamic Web TWAIN Service SSL certificate has expired. | |-2819 | The Dynamic Web TWAIN Service SSL certificate is invalid. | |-2820 | The Connection from the insecure (HTTP) web page to the local "Dynamic Web TWAIN Service" failed! | |-2821 | The Dynamsoft Service is not ready, please try again later. | |-2822 | The WebTwain JavaScript lts.js load failed. | |-2823 | The http url redirected. | |-2824 | The Connection from the web page failed. Please make sure the Dynamic Web TWAIN Service is running. | |-2825 | Failed to setup the Default Dynamic Web TWAIN Service. | |-2826 | Failed to connect the Dynamic Web TWAIN Service on ${name} | |-2827 | Failed to get Machine ID. | |-2828 | Invalid PDF Convert Mode Value. | |-2829 | The type of the PDF password must be a string. | |-2830 | The PDF resolution must be a positive number. | |-2831 | The PDF max width must be a positive number. | |-2832 | The PDF max height must be a positive number. | |-2833 | The PDF render grayscale must be a boolean. | |-2834 | The PDF reader options is invalid. | |-2835 | Failed to load CSS file "{filename}". | |-2839 | The DocumentCombiner object has been disposed.| |-2840 | The file type only supports PDF or TIFF.| |-2841 | Add failed, the filetype of the Blob is different from the filetype specified in the createDocumentCombiner parameter.| |-2843 | The blob cannot be empty.| |-2844 | Only Blob of JPEG, PNG, BMP, TIFF and PDF image types can be saved.| |-2845 | Only Blob of JPEG, PNG, BMP, TIFF and PDF image types can be uploaded.| |-2846 | The uid cannot be empty.| |-2847 | The uid is invalid.| |-2848 | The capability value is out of range.| |-2849 | The password must not exceed 32 characters in length.| |-2850 | The password is not a string.| |-2851 | The password must not exceed 32 characters in length.| |-2852 | The password is not a string.| |-2853 | The imageId cannot be empty.| |-2854 | The imageId does not exist.| |-2855 | The blob cannot be empty.| |-2856 | Cannot convert blob to array buffer. \| Invalid blob value. | |-2857 | Invalid blob value. | |-2901 | Source document does not exist. Please check the document name or create the document before performing this operation. | |-2902 | Target document does not exist. Please check the document name or create the document before performing this operation. | |-2905 | This API is not supported on the current operating system. Please contact your system administrator. | |-2906 | After initialization, the product key cannot be changed. | |-2907 | Starting from version 19, ActiveX controls are no longer supported. | |-2908 | The parameter is not a Dynamic Web TWAIN object. | |-2909 | Access to the local scanning service is blocked. | |-2910 | The OS print functionality is not supported on the current operating system. | |-2911 | Please grant access to the local scanning service. | |<= -3000 | See ErrorString property for details | ## Dynamsoft License Server Error List | Error Code | Error Message | | :--------- | :------------------------------------------------------------------------------- | | -20100 | The standby DLS refuses to provide service while the main DLS is working. | | -20100 | DLS refuses to provide service while under construction. | | -20101 | The handshake code you are using does not exist on the Dynamsoft License Server. | | -20102 | Session password is incorrect. | | -20103 | AppDomain for handshake is not matched. | | -20104 | No item matched. Please check your handshake and client settings. | | -20105 | License item does not exist. | | -20106 | Product is not matched. | | -20107 | Version mismatch. | | -20108 | DeploymentType is not matched. | | -20109 | Edition is not matched. | | -20111 | License has expired. | | -20111 | License for this ip has expired. | | -20112 | License has not yet taken effect. | | -20113 | This license item "+item.getLicenseItemId()+" has been invalid. | | -20114 | AppDomain for licenseItem is not matched. | | -20115 | ChargeWay for licenseItem is not matched. | | -20120 | License has exceeded its limit. | | -20151 | Cloned device detected. | --- title: Dynamic Web TWAIN SDK API Reference - Index description: Dynamic Web TWAIN Documentation API List source_url: html: https://www.dynamsoft.com/web-twain/docs/info/api/index.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/index.md --- > Some old APIs are deprecated, check out [Deprecated Features and APIs](/_articles/info/schedule/deprecated.md) # API List ## Global ### Methods | [`CreateDWTObject()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#createdwtobject) | [`CreateDWTobjectEx()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#createdwtobjectex) | [`DeleteDWTObject()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#deletedwtobject) | [`GetWebTwain()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#getwebtwain) | | [`Load()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#load) | [`RegisterEvent()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#registerevent) | [`Unload()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#unload) | | ### Properties | [`AutoLoad`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#autoload) | [`Containers`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#containers) | [`CustomizableDisplayInfo`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#customizabledisplayinfo) | [`DeviceFriendlyName`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#devicefriendlyname) | | [`EnableLocalNetworkMixedContent`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#enablelocalnetworkmixedcontent) | [`Host`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#host) | [`IfAddMD5InUploadHeader`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#ifaddmd5inuploadheader) | [`IfConfineMaskWithinTheViewer`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#ifconfinemaskwithintheviewer) | | [`JSVersion`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#jsversion) | [`ProductKey`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#productkey) | [`ResourcesPath`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#resourcespath) | [`ServiceInstallerLocation`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#serviceinstallerlocation) | | [`UseDefaultViewer`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#usedefaultviewer) | [`IfCheckCORS`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#ifcheckcors) | [`IfAlwaysFocusOnPopupWindow`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#ifalwaysfocusonpopupwindow) | | ### Events | [`OnWebTwainReady`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainready) | [`OnWebTwainError`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainerror) | [`OnWebTwainPostExecute`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainpostexecute) | [`OnWebTwainPreExecute`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainpreexecute) | ## Buffer ### Methods | [`ClearImageTags()`](/_articles/info/api/WebTwain_Buffer.md#clearimagetags) | [`RenameTag()`](/_articles/info/api/WebTwain_Buffer.md#renametag) | [`RemoveTag()`](/_articles/info/api/WebTwain_Buffer.md#removetag) | [`GetTagList()`](/_articles/info/api/WebTwain_Buffer.md#gettaglist) | | [`FilterImagesByTag()`](/_articles/info/api/WebTwain_Buffer.md#filterimagesbytag) | [`ClearFilter()`](/_articles/info/api/WebTwain_Buffer.md#clearfilter) | [`SetDefaultTag()`](/_articles/info/api/WebTwain_Buffer.md#setdefaulttag) | [`TagImages()`](/_articles/info/api/WebTwain_Buffer.md#tagimages) | | [`GetImageBitDepth()`](/_articles/info/api/WebTwain_Buffer.md#getimagebitdepth) | [`GetImageSize()`](/_articles/info/api/WebTwain_Buffer.md#getimagesize) | [`GetImageSizeWithSpecifiedType()`](/_articles/info/api/WebTwain_Buffer.md#getimagesizewithspecifiedtype) | [`GetSelectedImagesSize()`](/_articles/info/api/WebTwain_Buffer.md#getselectedimagessize) | | [`GetImageHeight()`](/_articles/info/api/WebTwain_Buffer.md#getimageheight) | [`GetImageWidth()`](/_articles/info/api/WebTwain_Buffer.md#getimagewidth) | [`GetImagePartURL()`](/_articles/info/api/WebTwain_Buffer.md#getimageparturl) | [`GetImageURL()`](/_articles/info/api/WebTwain_Buffer.md#getimageurl) | | [`GetImageXResolution()`](/_articles/info/api/WebTwain_Buffer.md#getimagexresolution) | [`GetImageYResolution()`](/_articles/info/api/WebTwain_Buffer.md#getimageyresolution) | [`GetSkewAngle()`](/_articles/info/api/WebTwain_Buffer.md#getskewangle) | [`GetSkewAngleEx()`](/_articles/info/api/WebTwain_Buffer.md#getskewangleex) | | [`ImageIDToIndex()`](/_articles/info/api/WebTwain_Buffer.md#imageidtoindex) | [`IndexToImageID()`](/_articles/info/api/WebTwain_Buffer.md#indextoimageid) | [`IsBlankImage()`](/_articles/info/api/WebTwain_Buffer.md#isblankimage) | [`IsBlankImageExpress()`](/_articles/info/api/WebTwain_Buffer.md#isblankimageexpress) | | [`SelectAllImages()`](/_articles/info/api/WebTwain_Buffer.md#selectallimages) | [`MoveImage()`](/_articles/info/api/WebTwain_Buffer.md#moveimage) | [`SwitchImage()`](/_articles/info/api/WebTwain_Buffer.md#switchimage) | [`RemoveImage()`](/_articles/info/api/WebTwain_Buffer.md#removeimage) | | [`RemoveAllImages()`](/_articles/info/api/WebTwain_Buffer.md#removeallimages) | [`RemoveAllSelectedImages()`](/_articles/info/api/WebTwain_Buffer.md#removeallselectedimages) | [`SelectImages()`](/_articles/info/api/WebTwain_Buffer.md#selectimages) | [`GetTagListByIndex()`](/_articles/info/api/WebTwain_Buffer.md#gettaglistbyindex) | | [`CreateDocument()`](/_articles/info/api/WebTwain_Buffer.md#createdocument) | [`OpenDocument()`](/_articles/info/api/WebTwain_Buffer.md#opendocument) | [`GetCurrentDocumentName()`](/_articles/info/api/WebTwain_Buffer.md#getcurrentdocumentname) | [`RenameDocument()`](/_articles/info/api/WebTwain_Buffer.md#renamedocument) | | [`RemoveDocument()`](/_articles/info/api/WebTwain_Buffer.md#removedocument) | [`GetDocumentInfoList()`](/_articles/info/api/WebTwain_Buffer.md#getdocumentinfolist) | [`IsBlankImageAsync()`](/_articles/info/api/WebTwain_Buffer.md#isblankimageasync) | [`CopyToDocumentAsync()`](/_articles/info/api/WebTwain_Buffer.md#copytodocumentasync) | | [`MoveToDocumentAsync()`](/_articles/info/api/WebTwain_Buffer.md#movetodocumentasync) | [`updateImage()`](/_articles/info/api/WebTwain_Buffer.md#updateimage) | ### Properties | [`BlankImageCurrentStdDev`](/_articles/info/api/WebTwain_Buffer.md#blankimagecurrentstddev) | [`BlankImageMaxStdDev`](/_articles/info/api/WebTwain_Buffer.md#blankimagemaxstddev) | [`BlankImageThreshold`](/_articles/info/api/WebTwain_Buffer.md#blankimagethreshold) | [`BufferMemoryLimit`](/_articles/info/api/WebTwain_Buffer.md#buffermemorylimit) | | [`CurrentImageIndexInBuffer`](/_articles/info/api/WebTwain_Buffer.md#currentimageindexinbuffer) | [`HowManyImagesInBuffer`](/_articles/info/api/WebTwain_Buffer.md#howmanyimagesinbuffer) | [`IfAllowLocalCache`](/_articles/info/api/WebTwain_Buffer.md#ifallowlocalcache) | [`SelectedImagesIndices`](/_articles/info/api/WebTwain_Buffer.md#selectedimagesindices) | | [`MaxImagesInBuffer`](/_articles/info/api/WebTwain_Buffer.md#maximagesinbuffer) | ### Events | [`OnBufferChanged`](/_articles/info/api/WebTwain_Buffer.md#onbufferchanged) | [`OnBitmapChanged`](/_articles/info/api/WebTwain_Buffer.md#onbitmapchanged) | [`OnIndexChangeDragDropDone`](/_articles/info/api/WebTwain_Buffer.md#onindexchangedragdropdone) | [`OnTopImageInTheViewChanged`](/_articles/info/api/WebTwain_Buffer.md#ontopimageintheviewchanged) | | [`OnDiskExceedLimit`](/_articles/info/api/WebTwain_Buffer.md#ondiskexceedlimit) | ## Edit ### Methods | [`Crop()`](/_articles/info/api/WebTwain_Edit.md#crop) | [`CropToClipboard()`](/_articles/info/api/WebTwain_Edit.md#croptoclipboard) | [`CutFrameToClipboard()`](/_articles/info/api/WebTwain_Edit.md#cutframetoclipboard) | [`CutToClipboard()`](/_articles/info/api/WebTwain_Edit.md#cuttoclipboard) | | [`CopyToClipboard()`](/_articles/info/api/WebTwain_Edit.md#copytoclipboard) | [`Erase()`](/_articles/info/api/WebTwain_Edit.md#erase) | [`Flip()`](/_articles/info/api/WebTwain_Edit.md#flip) | [`Mirror()`](/_articles/info/api/WebTwain_Edit.md#mirror) | | [`Rotate()`](/_articles/info/api/WebTwain_Edit.md#rotate) | [`RotateEx()`](/_articles/info/api/WebTwain_Edit.md#rotateex) | [`RotateLeft()`](/_articles/info/api/WebTwain_Edit.md#rotateleft) | [`RotateRight()`](/_articles/info/api/WebTwain_Edit.md#rotateright) | | [`ChangeBitDepth()`](/_articles/info/api/WebTwain_Edit.md#changebitdepth) | [`SetDPI()`](/_articles/info/api/WebTwain_Edit.md#setdpi) | [`ConvertToBW()`](/_articles/info/api/WebTwain_Edit.md#converttobw) | [`ConvertToGrayScale()`](/_articles/info/api/WebTwain_Edit.md#converttograyscale) | | [`ChangeImageSize()`](/_articles/info/api/WebTwain_Edit.md#changeimagesize) | [`Invert()`](/_articles/info/api/WebTwain_Edit.md#invert) | [`SetImageWidth()`](/_articles/info/api/WebTwain_Edit.md#setimagewidth) | [`ChangeBrightnessAsync()`](/_articles/info/api/WebTwain_Edit.md#changebrightnessasync) | | [`ChangeContrastAsync()`](/_articles/info/api/WebTwain_Edit.md#changecontrastasync) | ### Properties |[`BackgroundFillColor`](/_articles/info/api/WebTwain_Edit.md#backgroundfillcolor) | ## Scan ### Methods | [`GetSourceNameItems()`](/_articles/info/api/WebTwain_Acquire.md#getsourcenameitems) | [`GetSourceNames()`](/_articles/info/api/WebTwain_Acquire.md#getsourcenames) | [`GetSourceNamesAsync()`](/_articles/info/api/WebTwain_Acquire.md#getsourcenamesasync) | [`SelectSource()`](/_articles/info/api/WebTwain_Acquire.md#selectsource) | | [`SelectSourceAsync()`](/_articles/info/api/WebTwain_Acquire.md#selectsourceasync) | [`SelectSourceByIndex()`](/_articles/info/api/WebTwain_Acquire.md#selectsourcebyindex) | [`SelectSourceByIndexAsync()`](/_articles/info/api/WebTwain_Acquire.md#selectsourcebyindexasync) | [`SetOpenSourceTimeout()`](/_articles/info/api/WebTwain_Acquire.md#setopensourcetimeout) | | [`OpenSource()`](/_articles/info/api/WebTwain_Acquire.md#opensource) | [`OpenSourceAsync()`](/_articles/info/api/WebTwain_Acquire.md#opensourceasync) | [`EnableSourceUI()`](/_articles/info/api/WebTwain_Acquire.md#enablesourceui) | [`EnableSource()`](/_articles/info/api/WebTwain_Acquire.md#enablesource) | | [`AcquireImage()`](/_articles/info/api/WebTwain_Acquire.md#acquireimage) | [`startScan()`](/_articles/info/api/WebTwain_Acquire.md#startscan) | [`DisableSource()`](/_articles/info/api/WebTwain_Acquire.md#disablesource) | [`CloseSource()`](/_articles/info/api/WebTwain_Acquire.md#closesource) | | [`CloseSourceAsync()`](/_articles/info/api/WebTwain_Acquire.md#closesourceasync) | [`CloseWorkingProcess()`](/_articles/info/api/WebTwain_Acquire.md#closeworkingprocess) | [`GetDevicesAsync()`](/_articles/info/api/WebTwain_Acquire.md#getdevicesasync) | [`SelectDeviceAsync()`](/_articles/info/api/WebTwain_Acquire.md#selectdeviceasync) | | [`AcquireImageAsync()`](/_articles/info/api/WebTwain_Acquire.md#acquireimageasync) | ### Properties |[`CurrentSourceName`](/_articles/info/api/WebTwain_Acquire.md#currentsourcename) |[`IfDisableSourceAfterAcquire`](/_articles/info/api/WebTwain_Acquire.md#ifdisablesourceafteracquire) |[`IfDuplexEnabled`](/_articles/info/api/WebTwain_Acquire.md#ifduplexenabled) |[`IfFeederEnabled`](/_articles/info/api/WebTwain_Acquire.md#iffeederenabled)| | [`PageSize`](/_articles/info/api/WebTwain_Acquire.md#pagesize) |[`PixelType`](/_articles/info/api/WebTwain_Acquire.md#pixeltype) |[`Resolution`](/_articles/info/api/WebTwain_Acquire.md#resolution) |[`SourceCount`](/_articles/info/api/WebTwain_Acquire.md#sourcecount)| ### Events | [`OnPostAllTransfers`](/_articles/info/api/WebTwain_Acquire.md#onpostalltransfers) | [`OnPostTransfer`](/_articles/info/api/WebTwain_Acquire.md#onposttransfer) | [`OnPostTransferAsync`](/_articles/info/api/WebTwain_Acquire.md#onposttransferasync) | | [`OnPreAllTransfers`](/_articles/info/api/WebTwain_Acquire.md#onprealltransfers) | [`OnPreTransfer`](/_articles/info/api/WebTwain_Acquire.md#onpretransfer) | > The following APIs are compatible with TWAIN and ICA ### Methods |[`getCapabilities()`](/_articles/info/api/WebTwain_Acquire.md#getcapabilities) | [`setCapabilities()`](/_articles/info/api/WebTwain_Acquire.md#setcapabilities)| > The following APIs are compatible with TWAIN (mostly Windows, but could also be macOS) ### Methods | [`OpenSourceManager()`](/_articles/info/api/WebTwain_Acquire.md#opensourcemanager) | [`OpenSourceManagerAsync()`](/_articles/info/api/WebTwain_Acquire.md#opensourcemanagerasync) | [`CloseSourceManager()`](/_articles/info/api/WebTwain_Acquire.md#closesourcemanager) | [`CloseSourceManagerAsync()`](/_articles/info/api/WebTwain_Acquire.md#closesourcemanagerasync) | | [`GetCustomDSData()`](/_articles/info/api/WebTwain_Acquire.md#getcustomdsdata) | [`GetCustomDSDataEx()`](/_articles/info/api/WebTwain_Acquire.md#getcustomdsdataex) | [`CancelAllPendingTransfers()`](/_articles/info/api/WebTwain_Acquire.md#cancelallpendingtransfers) | [`FeedPage()`](/_articles/info/api/WebTwain_Acquire.md#feedpage) | | [`ResetImageLayout()`](/_articles/info/api/WebTwain_Acquire.md#resetimagelayout) | [`RewindPage()`](/_articles/info/api/WebTwain_Acquire.md#rewindpage) | [`SetCustomDSData()`](/_articles/info/api/WebTwain_Acquire.md#setcustomdsdata) | [`SetCustomDSDataEx()`](/_articles/info/api/WebTwain_Acquire.md#setcustomdsdataex) | | [`SetFileXferInfo()`](/_articles/info/api/WebTwain_Acquire.md#setfilexferinfo) | [`SetImageLayout()`](/_articles/info/api/WebTwain_Acquire.md#setimagelayout) | ### Properties | [`BitDepth`](/_articles/info/api/WebTwain_Acquire.md#bitdepth) | [`Brightness`](/_articles/info/api/WebTwain_Acquire.md#brightness) | [`Contrast`](/_articles/info/api/WebTwain_Acquire.md#contrast) | [`DataSourceStatus`](/_articles/info/api/WebTwain_Acquire.md#datasourcestatus) | | [`DefaultSourceName`](/_articles/info/api/WebTwain_Acquire.md#defaultsourcename) | [`Duplex`](/_articles/info/api/WebTwain_Acquire.md#duplex) | [`IfAutoBright`](/_articles/info/api/WebTwain_Acquire.md#ifautobright) | [`IfAutoDiscardBlankpages`](/_articles/info/api/WebTwain_Acquire.md#ifautodiscardblankpages) | | [`IfAutoFeed`](/_articles/info/api/WebTwain_Acquire.md#ifautofeed) | [`IfAutomaticBorderDetection`](/_articles/info/api/WebTwain_Acquire.md#ifautomaticborderdetection) | [`IfAutomaticDeskew`](/_articles/info/api/WebTwain_Acquire.md#ifautomaticdeskew) | [`IfAutoScan`](/_articles/info/api/WebTwain_Acquire.md#ifautoscan) | | [`IfFeederLoaded`](/_articles/info/api/WebTwain_Acquire.md#iffeederloaded) | [`IfPaperDetectable`](/_articles/info/api/WebTwain_Acquire.md#ifpaperdetectable) | [`IfShowIndicator`](/_articles/info/api/WebTwain_Acquire.md#ifshowindicator) | [`IfShowUI`](/_articles/info/api/WebTwain_Acquire.md#ifshowui) | | [`IfUIControllable`](/_articles/info/api/WebTwain_Acquire.md#ifuicontrollable) | [`IfUseTwainDSM`](/_articles/info/api/WebTwain_Acquire.md#ifusetwaindsm) | [`ImageCaptureDriverType`](/_articles/info/api/WebTwain_Acquire.md#imagecapturedrivertype) | [`ImageLayoutDocumentNumber`](/_articles/info/api/WebTwain_Acquire.md#imagelayoutdocumentnumber) | | [`ImageLayoutFrameBottom`](/_articles/info/api/WebTwain_Acquire.md#imagelayoutframebottom) | [`ImageLayoutFrameLeft`](/_articles/info/api/WebTwain_Acquire.md#imagelayoutframeleft) | [`ImageLayoutFrameNumber`](/_articles/info/api/WebTwain_Acquire.md#imagelayoutframenumber) | [`ImageLayoutFrameRight`](/_articles/info/api/WebTwain_Acquire.md#imagelayoutframeright) | | [`ImageLayoutFrameTop`](/_articles/info/api/WebTwain_Acquire.md#imagelayoutframetop) | [`ImageLayoutPageNumber`](/_articles/info/api/WebTwain_Acquire.md#imagelayoutpagenumber) | [`ImagePixelType`](/_articles/info/api/WebTwain_Acquire.md#imagepixeltype) | [`MagData`](/_articles/info/api/WebTwain_Acquire.md#magdata) | | [`MagType`](/_articles/info/api/WebTwain_Acquire.md#magtype) | [`PendingXfers`](/_articles/info/api/WebTwain_Acquire.md#pendingxfers) | [`PixelFlavor`](/_articles/info/api/WebTwain_Acquire.md#pixelflavor) | [`TransferMode`](/_articles/info/api/WebTwain_Acquire.md#transfermode) | | [`Unit`](/_articles/info/api/WebTwain_Acquire.md#unit) | [`XferCount`](/_articles/info/api/WebTwain_Acquire.md#xfercount) | [`IfAppendImage`](/_articles/info/api/WebTwain_Acquire.md#ifappendimage) | ### Events | [`OnSourceUIClose`](/_articles/info/api/WebTwain_Acquire.md#onsourceuiclose) | ## Input/Output ### Input #### Methods | [`LoadImage()`](/_articles/info/api/WebTwain_IO.md#loadimage) | [`LoadImageEx()`](/_articles/info/api/WebTwain_IO.md#loadimageex) | [`LoadImageFromBase64Binary()`](/_articles/info/api/WebTwain_IO.md#loadimagefrombase64binary) | [`LoadImageFromBinary()`](/_articles/info/api/WebTwain_IO.md#loadimagefrombinary) | | [`LoadDibFromClipboard()`](/_articles/info/api/WebTwain_IO.md#loaddibfromclipboard) | [`FTPDownload()`](/_articles/info/api/WebTwain_IO.md#ftpdownload) | [`FTPDownloadEx()`](/_articles/info/api/WebTwain_IO.md#ftpdownloadex) | [`HTTPDownload()`](/_articles/info/api/WebTwain_IO.md#httpdownload) | | [`HTTPDownloadEx()`](/_articles/info/api/WebTwain_IO.md#httpdownloadex) | [`HTTPDownloadThroughPost()`](/_articles/info/api/WebTwain_IO.md#httpdownloadthroughpost) | [`loadFromLocalStorage()`](/_articles/info/api/WebTwain_IO.md#loadfromlocalstorage) | ### Output #### Methods | [`ConvertToBase64()`](/_articles/info/api/WebTwain_IO.md#converttobase64) | [`ConvertToBlob()`](/_articles/info/api/WebTwain_IO.md#converttoblob) | [`FTPUpload()`](/_articles/info/api/WebTwain_IO.md#ftpupload) | | [`FTPUploadEx()`](/_articles/info/api/WebTwain_IO.md#ftpuploadex) | [`FTPUploadAllAsMultiPageTIFF()`](/_articles/info/api/WebTwain_IO.md#ftpuploadallasmultipagetiff) | [`FTPUploadAllAsPDF()`](/_articles/info/api/WebTwain_IO.md#ftpuploadallaspdf) | | [`FTPUploadAsMultiPagePDF()`](/_articles/info/api/WebTwain_IO.md#ftpuploadasmultipagepdf) | [`FTPUploadAsMultiPageTIFF()`](/_articles/info/api/WebTwain_IO.md#ftpuploadasmultipagetiff) | [`HTTPUpload()`](/_articles/info/api/WebTwain_IO.md#httpupload) | | [`HTTPUploadThroughPutEx()`](/_articles/info/api/WebTwain_IO.md#httpuploadthroughputex) | [`HTTPUploadThroughPost()`](/_articles/info/api/WebTwain_IO.md#httpuploadthroughpost) | [`HTTPUploadThroughPostEx()`](/_articles/info/api/WebTwain_IO.md#httpuploadthroughpostex) | | [`HTTPUploadAllThroughPostAsMultiPageTIFF()`](/_articles/info/api/WebTwain_IO.md#httpuploadallthroughpostasmultipagetiff) | [`HTTPUploadAllThroughPostAsPDF()`](/_articles/info/api/WebTwain_IO.md#httpuploadallthroughpostaspdf) | [`HTTPUploadThroughPostAsMultiPagePDF()`](/_articles/info/api/WebTwain_IO.md#httpuploadthroughpostasmultipagepdf) | | [`HTTPUploadThroughPostAsMultiPageTIFF()`](/_articles/info/api/WebTwain_IO.md#httpuploadthroughpostasmultipagetiff) | [`OutputSelectedAreaAsync()`](/_articles/info/api/WebTwain_IO.md#outputselectedareaasync) | [`SaveAsBMP()`](/_articles/info/api/WebTwain_IO.md#saveasbmp) | | [`SaveAsJPEG()`](/_articles/info/api/WebTwain_IO.md#saveasjpeg) | [`SaveAsPDF()`](/_articles/info/api/WebTwain_IO.md#saveaspdf) | [`SaveAsPNG()`](/_articles/info/api/WebTwain_IO.md#saveaspng) | | [`SaveAsTIFF()`](/_articles/info/api/WebTwain_IO.md#saveastiff) | [`SaveSelectedImagesAsMultiPagePDF()`](/_articles/info/api/WebTwain_IO.md#saveselectedimagesasmultipagepdf) | [`SaveSelectedImagesAsMultiPageTIFF()`](/_articles/info/api/WebTwain_IO.md#saveselectedimagesasmultipagetiff) | | [`SaveAllAsMultiPageTIFF()`](/_articles/info/api/WebTwain_IO.md#saveallasmultipagetiff) | [`SaveAllAsPDF()`](/_articles/info/api/WebTwain_IO.md#saveallaspdf) | [`httpUploadBlob()`](/_articles/info/api/WebTwain_IO.md#httpuploadblob) | | [`saveBlob()`](/_articles/info/api/WebTwain_IO.md#saveblob) | [`saveToLocalStorage()`](/_articles/info/api/WebTwain_IO.md#savetolocalstorage) | ### Others #### Methods | [`ClearTiffCustomTag()`](/_articles/info/api/WebTwain_IO.md#cleartiffcustomtag) | [`SetTiffCustomTag()`](/_articles/info/api/WebTwain_IO.md#settiffcustomtag) | [`ClearAllHTTPFormField()`](/_articles/info/api/WebTwain_IO.md#clearallhttpformfield) | [`SetHTTPFormField()`](/_articles/info/api/WebTwain_IO.md#sethttpformfield) | | [`SetHTTPHeader()`](/_articles/info/api/WebTwain_IO.md#sethttpheader) | [`SetUploadSegment()`](/_articles/info/api/WebTwain_IO.md#setuploadsegment) | [`ShowFileDialog()`](/_articles/info/api/WebTwain_IO.md#showfiledialog) | [`Print()`](/_articles/info/api/WebTwain_IO.md#print) | | [`PrintEx()`](/_articles/info/api/WebTwain_IO.md#printex) | [`createLocalStorage()`](/_articles/info/api/WebTwain_IO.md#createlocalstorage) | [`localStorageExist()`](/_articles/info/api/WebTwain_IO.md#localstorageexist) | [`removeLocalStorage()`](/_articles/info/api/WebTwain_IO.md#removelocalstorage) | #### Properties | [`FTPPassword`](/_articles/info/api/WebTwain_IO.md#ftppassword) | [`FTPPort`](/_articles/info/api/WebTwain_IO.md#ftpport) | [`FTPUserName`](/_articles/info/api/WebTwain_IO.md#ftpusername) | [`IfPASVMode`](/_articles/info/api/WebTwain_IO.md#ifpasvmode) | | [`HttpFieldNameOfUploadedImage`](/_articles/info/api/WebTwain_IO.md#httpfieldnameofuploadedimage) | [`HTTPPort`](/_articles/info/api/WebTwain_IO.md#httpport) | [`IfSSL`](/_articles/info/api/WebTwain_IO.md#ifssl) | [`HTTPPostResponseString`](/_articles/info/api/WebTwain_IO.md#httppostresponsestring) | | [`IfShowFileDialog`](/_articles/info/api/WebTwain_IO.md#ifshowfiledialog) | [`IfShowCancelDialogWhenImageTransfer`](/_articles/info/api/WebTwain_IO.md#ifshowcanceldialogwhenimagetransfer) | [`IfShowProgressBar`](/_articles/info/api/WebTwain_IO.md#ifshowprogressbar) | [`JPEGQuality`](/_articles/info/api/WebTwain_IO.md#jpegquality) | | [`IfTiffMultiPage`](/_articles/info/api/WebTwain_IO.md#iftiffmultipage) | [`TIFFCompressionType`](/_articles/info/api/WebTwain_IO.md#tiffcompressiontype) | [`MaxUploadImageSize`](/_articles/info/api/WebTwain_IO.md#maxuploadimagesize) | [`IfSortBySelectionOrder`](/_articles/info/api/WebTwain_IO.md#ifsortbyselectionorder) | #### Events |[`OnGetFilePath`](/_articles/info/api/WebTwain_IO.md#ongetfilepath)|[`OnPostLoad`](/_articles/info/api/WebTwain_IO.md#onpostload)| [`OnInternetTransferPercentage`](/_articles/info/api/WebTwain_IO.md#oninternettransferpercentage)| ## Util ### Methods |[`RegisterEvent()`](/_articles/info/api/WebTwain_Util.md#registerevent) | [`UnregisterEvent()`](/_articles/info/api/WebTwain_Util.md#unregisterevent) | [`GenerateURLForUploadData()`](/_articles/info/api/WebTwain_Util.md#generateurlforuploaddata) | ### Properties | [`ErrorCode`](/_articles/info/api/WebTwain_Util.md#errorcode) | [`ErrorCause`](/_articles/info/api/WebTwain_Util.md#errorcause) | [`ErrorString`](/_articles/info/api/WebTwain_Util.md#errorstring) | [`LogLevel`](/_articles/info/api/WebTwain_Util.md#loglevel) | [`Manufacturer`](/_articles/info/api/WebTwain_Util.md#manufacturer) | | [`ProductFamily`](/_articles/info/api/WebTwain_Util.md#productfamily) | [`ProductName`](/_articles/info/api/WebTwain_Util.md#productname) | [`VersionInfo`](/_articles/info/api/WebTwain_Util.md#versioninfo) | | ## Viewer ### Methods | [`bind()`](/_articles/info/api/WebTwain_Viewer.md#bind) | [`clearSelectedAreas()`](/_articles/info/api/WebTwain_Viewer.md#clearselectedareas) | [`createCustomElement()`](/_articles/info/api/WebTwain_Viewer.md#createcustomelement) | [`createImageEditor()`](/_articles/info/api/WebTwain_Viewer.md#createimageeditor) | | [`createThumbnailViewer()`](/_articles/info/api/WebTwain_Viewer.md#createthumbnailviewer) | [`first()`](/_articles/info/api/WebTwain_Viewer.md#first) | [`fitWindow()`](/_articles/info/api/WebTwain_Viewer.md#fitwindow) | [`gotoPage()`](/_articles/info/api/WebTwain_Viewer.md#gotopage) | | [`getVisiblePagesInfo()`](/_articles/info/api/WebTwain_Viewer.md#getvisiblepagesinfo) | [`hide()`](/_articles/info/api/WebTwain_Viewer.md#hide) | [`last()`](/_articles/info/api/WebTwain_Viewer.md#last) | [`next()`](/_articles/info/api/WebTwain_Viewer.md#next) | | [`off()`](/_articles/info/api/WebTwain_Viewer.md#off) | [`on()`](/_articles/info/api/WebTwain_Viewer.md#on) | [`previous()`](/_articles/info/api/WebTwain_Viewer.md#previous) | [`render()`](/_articles/info/api/WebTwain_Viewer.md#render) | | [`setButtonClass()`](/_articles/info/api/WebTwain_Viewer.md#setbuttonclass) | [`setSelectedAreas()`](/_articles/info/api/WebTwain_Viewer.md#setselectedareas) | [`setViewMode()`](/_articles/info/api/WebTwain_Viewer.md#setviewmode) | [`show()`](/_articles/info/api/WebTwain_Viewer.md#show) | | [`unbind()`](/_articles/info/api/WebTwain_Viewer.md#unbind) | [`updateCheckboxStyle()`](/_articles/info/api/WebTwain_Viewer.md#updatecheckboxstyle) | [`updatePageNumberStyle()`](/_articles/info/api/WebTwain_Viewer.md#updatepagenumberstyle) | [`updateSelectionBoxStyle()`](/_articles/info/api/WebTwain_Viewer.md#updateselectionboxstyle) | ### Properties | [`acceptDrop`](/_articles/info/api/WebTwain_Viewer.md#acceptdrop) | [`allowPageDragging`](/_articles/info/api/WebTwain_Viewer.md#allowpagedragging) | [`allowSlide`](/_articles/info/api/WebTwain_Viewer.md#allowslide) | [`autoChangeIndex`](/_articles/info/api/WebTwain_Viewer.md#autochangeindex) | | [`background`](/_articles/info/api/WebTwain_Viewer.md#background) | [`border`](/_articles/info/api/WebTwain_Viewer.md#border) | [`cursor`](/_articles/info/api/WebTwain_Viewer.md#cursor) | [`focusOutlineEnabled`](/_articles/info/api/WebTwain_Viewer.md#focusoutlineenabled) | | [`height`](/_articles/info/api/WebTwain_Viewer.md#height) | [`idPostfix`](/_articles/info/api/WebTwain_Viewer.md#idpostfix) | [`ifAutoScroll`](/_articles/info/api/WebTwain_Viewer.md#ifautoscroll) | [`innerBorder`](/_articles/info/api/WebTwain_Viewer.md#innerborder) | | [`pageMargin`](/_articles/info/api/WebTwain_Viewer.md#pagemargin) | [`selectedAreaBorderColor`](/_articles/info/api/WebTwain_Viewer.md#selectedareabordercolor) | [`selectedPageBackground`](/_articles/info/api/WebTwain_Viewer.md#selectedpagebackground) | [`selectedPageBorder`](/_articles/info/api/WebTwain_Viewer.md#selectedpageborder) | | [`selectionMode`](/_articles/info/api/WebTwain_Viewer.md#selectionmode) | [`selectionRectAspectRatio`](/_articles/info/api/WebTwain_Viewer.md#selectionrectaspectratio) | [`singlePageMode`](/_articles/info/api/WebTwain_Viewer.md#singlepagemode) | [`width`](/_articles/info/api/WebTwain_Viewer.md#width) | | [`zoom`](/_articles/info/api/WebTwain_Viewer.md#zoom) | [`zoomOrigin`](/_articles/info/api/WebTwain_Viewer.md#zoomorigin) | | | ### Events | [`click`](/_articles/info/api/WebTwain_Viewer.md#on) | [`contextmenu`](/_articles/info/api/WebTwain_Viewer.md#on) | [`dblclick`](/_articles/info/api/WebTwain_Viewer.md#on) | [`mousemove`](/_articles/info/api/WebTwain_Viewer.md#on) | | [`mousedown`](/_articles/info/api/WebTwain_Viewer.md#on) | [`mouseup`](/_articles/info/api/WebTwain_Viewer.md#on) | [`mouseout`](/_articles/info/api/WebTwain_Viewer.md#on) | [`mouseover`](/_articles/info/api/WebTwain_Viewer.md#on) | | [`keydown`](/_articles/info/api/WebTwain_Viewer.md#on) | [`keyup`](/_articles/info/api/WebTwain_Viewer.md#on) | [`pageAreaSelected`](/_articles/info/api/WebTwain_Viewer.md#pageareaselected) | [`pageAreaUnselected`](/_articles/info/api/WebTwain_Viewer.md#pageareaunselected) | | [`pageRendered`](/_articles/info/api/WebTwain_Viewer.md#pagerendered) | [`resize`](/_articles/info/api/WebTwain_Viewer.md#resize) | ## Addon ## BarcodeReader ### Methods | [`decode()`](/_articles/info/api/Addon_BarcodeReader.md#decode) | [`getRuntimeSettings()`](/_articles/info/api/Addon_BarcodeReader.md#getruntimesettings) | [`updateRuntimeSettings()`](/_articles/info/api/Addon_BarcodeReader.md#updateruntimesettings) | | [`resetRuntimeSettings()`](/_articles/info/api/Addon_BarcodeReader.md#resetruntimesettings) | [`initRuntimeSettingsWithString()`](/_articles/info/api/Addon_BarcodeReader.md#initruntimesettingswithstring) | ## PDF ### Methods | [`GetConvertMode()`](/_articles/info/api/Addon_PDF.md#getconvertmode) | [`IsModuleInstalled()`](/_articles/info/api/Addon_PDF.md#ismoduleinstalled) | [`IsRasterizationRequired()`](/_articles/info/api/Addon_PDF.md#israsterizationrequired) | [`IsTextBasedPDF()`](/_articles/info/api/Addon_PDF.md#istextbasedpdf) | [`SetConvertMode()`](/_articles/info/api/Addon_PDF.md#setconvertmode) | | [`SetPassword()`](/_articles/info/api/Addon_PDF.md#setpassword) | [`SetResolution()`](/_articles/info/api/Addon_PDF.md#setresolution) | [`Write.Setup()`](/_articles/info/api/Addon_PDF.md#writesetup) | [`GetReaderOptions()`](/_articles/info/api/Addon_PDF.md#getreaderoptions) | | [`SetReaderOptions()`](/_articles/info/api/Addon_PDF.md#setreaderoptions) | ## OCR ### Methods | [`GetInstalledOCRInfo()`](/_articles/info/api/Addon_OCR.md#getinstalledocrinfo) | [`DetectPageOrientation()`](/_articles/info/api/Addon_OCR.md#detectpageorientation) | [`Recognize()`](/_articles/info/api/Addon_OCR.md#recognize) | [`SaveToPath()`](/_articles/info/api/Addon_OCR.md#savetopath) | | [`SaveAsBase64()`](/_articles/info/api/Addon_OCR.md#saveasbase64) | [`SaveAsBlob()`](/_articles/info/api/Addon_OCR.md#saveasblob) | ## Webcam ### Methods | [`CaptureImage()`](/_articles/info/api/Addon_Webcam.md#captureimage) | [`CloseSource()`](/_articles/info/api/Addon_Webcam.md#closesource) | [`GetCameraControlPropertySetting()`](/_articles/info/api/Addon_Webcam.md#getcameracontrolpropertysetting) | [`GetCameraControlPropertyMoreSetting()`](/_articles/info/api/Addon_Webcam.md#getcameracontrolpropertymoresetting) | | [`GetVideoPropertySetting()`](/_articles/info/api/Addon_Webcam.md#getvideopropertysetting) | [`GetVideoPropertyMoreSetting()`](/_articles/info/api/Addon_Webcam.md#getvideopropertymoresetting) | [`SetCameraControlPropertySetting()`](/_articles/info/api/Addon_Webcam.md#setcameracontrolpropertysetting) | [`SetVideoPropertySetting()`](/_articles/info/api/Addon_Webcam.md#setvideopropertysetting) | | [`GetFrameRate()`](/_articles/info/api/Addon_Webcam.md#getframerate) | [`SetFrameRate()`](/_articles/info/api/Addon_Webcam.md#setframerate) | [`GetMediaType()`](/_articles/info/api/Addon_Webcam.md#getmediatype) | [`SetMediaType()`](/_articles/info/api/Addon_Webcam.md#setmediatype) | | [`GetResolution()`](/_articles/info/api/Addon_Webcam.md#getresolution) | [`SetResolution()`](/_articles/info/api/Addon_Webcam.md#setresolution) | [`GetFramePartURL()`](/_articles/info/api/Addon_Webcam.md#getframeparturl) | [`GetFrameURL()`](/_articles/info/api/Addon_Webcam.md#getframeurl) | | [`GetSourceList()`](/_articles/info/api/Addon_Webcam.md#getsourcelist) | [`SelectSource()`](/_articles/info/api/Addon_Webcam.md#selectsource) | [`PauseVideo()`](/_articles/info/api/Addon_Webcam.md#pausevideo) | [`PlayVideo()`](/_articles/info/api/Addon_Webcam.md#playvideo) | | [`SetVideoRotateMode()`](/_articles/info/api/Addon_Webcam.md#setvideorotatemode) | [`StopVideo()`](/_articles/info/api/Addon_Webcam.md#stopvideo) | ## Dynamsoft.FileUploader ### Methods | [`Init()`](/_articles/info/api/Dynamsoft_FileUploader.md#init) | [`CreateJob()`](/_articles/info/api/Dynamsoft_FileUploader.md#createjob) | [`Run()`](/_articles/info/api/Dynamsoft_FileUploader.md#run) | [`Cancel()`](/_articles/info/api/Dynamsoft_FileUploader.md#cancel) | | [`CancelAllUpload()`](/_articles/info/api/Dynamsoft_FileUploader.md#cancelallupload) | --- title: Dynamic Web TWAIN API Reference - Interfaces description: Dynamic Web TWAIN SDK Documentation API Reference Interfaces Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/api/interfaces.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/interfaces.md --- # Interfaces ## Global ### DWTInitialConfig **Syntax** ```typescript interface DWTInitialConfig { WebTwainId: string; Host ? : string; // Default value: "127.0.0.1" } ``` ### Container **Syntax** ``` typescript interface Container { WebTwainId?: string; // ID of the WebTwain instance ContainerId?: string; // ID of the container element to bind Width?: string | number; // Width of the div element appended to the container Height?: string | number; // Height of the div element appended to the container } ``` - `WebTwainId` and `ContainerId` are both optional but one must exist as the identifier for that `WebTwain` instance. If you don't need to use the viewer (headless), you can leave `ContainerId` empty. - `Width` and `Height` determine the initial size of `Viewer` object. ### DisplayInfo **Syntax** ```typescript interface DisplayInfo { loaderBarSource?: string; loaderBarClassName?: string; buttons?: any; customProgressText?: any; dialogText?: any; errorMessages?: any; generalMessages?: any; } ``` ## Scan ### Device **Syntax** ```typescript interface Device{ name: string; displayName: string; deviceType: Dynamsoft.DWT.EnumDWT_DeviceType; serviceInfo?: ServiceInfo; deviceInfo?: any; } ``` - [`EnumDWT_DeviceType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_devicetype) - [`ServiceInfo`](/_articles/info/api/interfaces.md#serviceinfo) ### ServiceInfo **Syntax** ```typescript interface ServiceInfo { server: string; attrs?: any; } ``` ### DeviceConfiguration **Syntax** ```typescript interface DeviceConfiguration { IfShowUI?: boolean; //Whether to show the built-in User Interface from the device vendor PixelType?: Dynamsoft.DWT.EnumDWT_PixelType | number | string; //Whether to scan in color, grey or black & white Resolution?: number; //Measured by dots per pixel (DPI) IfFeederEnabled?: boolean; //Whether to use the document feeder or the flatbed of the device IfDuplexEnabled?: boolean; //Whether to scan one side or both sides IfDisableSourceAfterAcquire?: boolean; //Whether to close the built-in User Interface after acquisition. Only valid when {IfShowUI} is true. IfGetImageInfo?: boolean; //Whether to retrieve information about the image after it's transferred. IfGetExtImageInfo?: boolean; //Whether to retrieve extended information about the image after it's transferred. extendedImageInfoQueryLevel?: Dynamsoft.DWT.EnumDWT_ExtImageInfo | number; //How much extended information is retrieved. Only valid when {IfGetExtImageInfo} is true. SelectSourceByIndex?: number; //Specify a source by its index. IfCloseSourceAfterAcquire?: boolean; //Whether to close the data source after acquisition. Default: false. PageSize?: Dynamsoft.DWT.EnumDWT_CapSupportedSizes | number; //Specify page size } ``` - [`EnumDWT_PixelType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_pixeltype) - [`EnumDWT_ExtImageInfo`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_extimageinfo) - [`EnumDWT_CapSupportedSizes`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_capsupportedsizes) `extendedImageInfoQueryLevel` is 0 (`default`) by default which means the following information will be retrieved (if available): | Label | Value | | :--------------------- | :----- | | TWEI_BARCODEX | 0x1200 | | TWEI_BARCODEY | 0x1201 | | TWEI_BARCODETEXT | 0x1202 | | TWEI_BARCODETYPE | 0x1203 | | TWEI_ENDORSEDTEXT | 0x1213 | | TWEI_BARCODECONFIDENCE | 0x121A | | TWEI_BARCODEROTATION | 0x121B | | TWEI_BARCODETEXTLENGTH | 0x121C | | TWEI_BOOKNAME | 0x1238 | | TWEI_CHAPTERNUMBER | 0x1239 | | TWEI_DOCUMENTNUMBER | 0x123A | | TWEI_PAGENUMBER | 0x123B | | TWEI_CAMERA | 0x123C | | TWEI_FRAMENUMBER | 0x123D | | TWEI_FRAME | 0x123E | | TWEI_PIXELFLAVOR | 0x123F | | TWEI_MAGDATA | 0x1243 | | TWEI_MAGTYPE | 0x1244 | | TWEI_PAGESIDE | 0x1245 | If it's set to 1 (`standard`), the following will also be retrieved (if available): | Label | Value | | :------------------------- | :----- | | TWEI_DESHADETOP | 0x1204 | | TWEI_DESHADELEFT | 0x1205 | | TWEI_DESHADEHEIGHT | 0x1206 | | TWEI_DESHADEWIDTH | 0x1207 | | TWEI_DESHADESIZE | 0x1208 | | TWEI_SPECKLESREMOVED | 0x1209 | | TWEI_HORZLINEXCOORD | 0x120A | | TWEI_HORZLINEYCOORD | 0x120B | | TWEI_HORZLINELENGTH | 0x120C | | TWEI_HORZLINETHICKNESS | 0x120D | | TWEI_VERTLINEXCOORD | 0x120E | | TWEI_VERTLINEYCOORD | 0x120F | | TWEI_VERTLINELENGTH | 0x1210 | | TWEI_VERTLINETHICKNESS | 0x1211 | | TWEI_PATCHCODE | 0x1212 | | TWEI_FORMCONFIDENCE | 0x1214 | | TWEI_FORMTEMPLATEMATCH | 0x1215 | | TWEI_FORMTEMPLATEPAGEMATCH | 0x1216 | | TWEI_FORMHORZDOCOFFSET | 0x1217 | | TWEI_FORMVERTDOCOFFSET | 0x1218 | | TWEI_BARCODECOUNT | 0x1219 | | TWEI_DESHADECOUNT | 0x121D | | TWEI_DESHADEBLACKCOUNTOLD | 0x121E | | TWEI_DESHADEBLACKCOUNTNEW | 0x121F | | TWEI_DESHADEBLACKRLMIN | 0x1220 | | TWEI_DESHADEBLACKRLMAX | 0x1221 | | TWEI_DESHADEWHITECOUNTOLD | 0x1222 | | TWEI_DESHADEWHITECOUNTNEW | 0x1223 | | TWEI_DESHADEWHITERLMIN | 0x1224 | | TWEI_DESHADEWHITERLAVE | 0x1225 | | TWEI_DESHADEWHITERLMAX | 0x1226 | | TWEI_BLACKSPECKLESREMOVED | 0x1227 | | TWEI_WHITESPECKLESREMOVED | 0x1228 | | TWEI_HORZLINECOUNT | 0x1229 | | TWEI_VERTLINECOUNT | 0x122A | | TWEI_DESKEWSTATUS | 0x122B | | TWEI_SKEWORIGINALANGLE | 0x122C | | TWEI_SKEWFINALANGLE | 0x122D | | TWEI_SKEWCONFIDENCE | 0x122E | | TWEI_SKEWWINDOWX1 | 0x122F | | TWEI_SKEWWINDOWY1 | 0x1230 | | TWEI_SKEWWINDOWX2 | 0x1231 | | TWEI_SKEWWINDOWY2 | 0x1232 | | TWEI_SKEWWINDOWX3 | 0x1233 | | TWEI_SKEWWINDOWY3 | 0x1234 | | TWEI_SKEWWINDOWX4 | 0x1235 | | TWEI_SKEWWINDOWY4 | 0x1236 | | TWEI_ICCPROFILE | 0x1240 | | TWEI_LASTSEGMENT | 0x1241 | | TWEI_SEGMENTNUMBER | 0x1242 | | TWEI_FILESYSTEMSOURCE | 0x1246 | | TWEI_IMAGEMERGED | 0x1247 | | TWEI_MAGDATALENGTH | 0x1248 | | TWEI_PAPERCOUNT | 0x1249 | | TWEI_PRINTERTEXT | 0x124A | If it's set to 2 (`supported`), then besides what's mentioned in the two tables above, the Dynamic Web TWAIN library will also try to query the scanner for its own custom extended image info. ### SourceDetails **Syntax** ```typescript interface SourceDetails { /** * The driver type which can be "TWAIN" | "ICA" | "SANE" */ DriverType?: string; /** * Information about the driver if it's DriverType is "ICA" */ DeviceInfo?: any; /** * The name of the data source. E.g. "TWAIN2 FreeImage Software Scanner". */ ProductName?: string; /** * Whether it is the default source. */ IsDefaultSource?: boolean; /** * Whether it is the current source. */ IsCurrentSource?: boolean; /** * The family name of the data source. E.g. "Software Scan". */ ProductFamily?: string; /** * The manufacturer of the data source. E.g. "TWAIN Working Group". */ Manufacturer?: string; /** * Supported Groups */ SupportedGroups?: number /** * The version of the protocol based on which the data source is developed. */ ProtocolMajor?: number; ProtocolMinor?: number; /** * Detailed version of the data source. */ Version?: Version; } ``` - [`Version`](/_articles/info/api/interfaces.md#version) ### Version **Syntax** ```typescript interface Version { MajorNum?: number; MinorNum?: number; Language?: number; Country?: number; Info?: string; } ``` ### ScanSetup **Syntax** ```typescript interface ScanSetup { /** * An id that specifies this specific setup. */ setupId?: string; /** * Whether to ignore or fail the acquisition when an exception is raised. Set "ignore" or "fail". */ exception?: string; /** * The name of the data source (the scanner) or Device object. If not set, the default data source is used. */ scanner?: string | Device; ui?: { /** * Whether to show the UI of the device. */ bShowUI?: boolean; /** * Whether to show the indicator of the device. */ bShowIndicator?: boolean; }; /** * The TWAIN transfer mode. */ transferMode?: Dynamsoft.DWT.EnumDWT_TransferMode | number; /** * Set how the transfer is done. */ fileXfer?: { /** * Specify the file name (or pattern) for file transfer. * Example: "C:\\WebTWAIN<%06d>.bmp" */ fileName?: string; /** * Specify the file format. */ fileFormat?: Dynamsoft.DWT.EnumDWT_FileFormat | number; /** * Specify the quality of JPEG files. */ jpegQuality?: number; /** * Specify the compression type of the file. */ compressionType?: Dynamsoft.DWT.EnumDWT_CompressionType | number; }; /** * Set where the scanned images are inserted. */ insertingIndex?: number; /** * The profile is a base64 string, if present, it overrides settings and more settings. */ profile?: string; /** * Basic settings. */ settings?: { /** * "ignore" (default) or "fail". */ exception?: string; /** * Specify the pixel type. */ pixelType?: Dynamsoft.DWT.EnumDWT_PixelType | number; /** * Specify the resolution. */ resolution?: number; /** * Whether to enable document feeder. */ bFeeder?: boolean; /** * Whether to enable duplex scan. */ bDuplex?: boolean; }; moreSettings?: { /** * "ignore" (default) or "fail". */ exception?: string; /** * Specify the bit depth. */ bitDepth?: number; /** * Specify the page size. */ pageSize?: Dynamsoft.DWT.EnumDWT_CapSupportedSizes | number; /** * Specify the unit. */ unit?: Dynamsoft.DWT.EnumDWT_UnitType | number; /** * Specify a layout to scan, if present, it'll override pageSize. */ layout?: { left?: number; top?: number; right?: number; bottom?: number; }; /** * Specify the pixel flavor. */ pixelFlavor?: Dynamsoft.DWT.EnumDWT_CapPixelFlavor | number; /** * Specify Brightness. */ brightness?: number; /** * Specify contrast. */ contrast?: number; /** * Specify how many images are transferred per session. */ nXferCount?: number; /** * Whether to enable automatic blank image detection and removal. */ autoDiscardBlankPages?: boolean; /** * Whether to enable automatic border detection. */ autoBorderDetection?: boolean; /** * Whether to enable automatic skew correction. */ autoDeskew?: boolean; /** * Whether to enable automatic brightness adjustment. */ autoBright?: boolean; }; /** * A callback triggered before the scan, after the scan and after each page has been transferred. * Returned status * {event: 'beforeAcquire', result: {…}} //Equivalent to OnPreAllTransfers event * {event: 'postTransfer', bScanCompleted: false, result: {…}} //Equivalent to OnPostTransfer event * {event: 'postTransfer', bScanCompleted: true, result: {…}} //Equivalent to OnPostAllTransfers event */ funcScanStatus?: (status: Status) => void; /** * Set up how the scanned images are outputted. */ outputSetup?: { /** * Output type. "http" is the only supported type for now. */ type?: string; /** * Set the output format. */ format?: Dynamsoft.DWT.EnumDWT_ImageType | number; /** * Specify how many times the library will try the output. */ reTries?: number; /** * Whether to use the FileUploader. */ useUploader?: boolean; /** * Whether to upload all images in one HTTP post. */ singlePost?: boolean; /** * Whether to show a progress bar when outputting. */ showProgressBar?: boolean; /** * Whether to remove the images after outputting. */ removeAfterOutput?: boolean; /** * A callback triggered during the outputting. * @argument fileInfo A JSON object that contains the fileName, percentage, statusCode, responseString, etc. */ funcHttpUploadStatus?: (fileInfo: any) => void; /** * Setup for PDF output. */ pdfSetup?: { author?: string; compression?: Dynamsoft.DWT.EnumDWT_PDFCompressionType | number; creator?: string; /** * Example: 'D:20181231' */ creationDate?: string; keyWords?: string; /** * Example: 'D:20181231' */ modifiedDate?: string; producer?: string; subject?: string; title?: string; version?: number; quality?: number; }; /** * Setup for TIFF output. */ tiffSetup?: { quality?: number; compression?: Dynamsoft.DWT.EnumDWT_TIFFCompressionType | number; /** * Specify Tiff custom tags. */ tiffTags?: TiffTag[]; }; /** * Setup for HTTP upload via Post. */ httpParams?: { /** * Target of the request. * Example: "http://dynamsoft.com/receivepost.aspx" */ url?: string; /** * Custom headers in the form. * Example: {md5: ""} */ headers?: any; /** * Custom form fields. * Example: {"UploadedBy": "Dynamsoft"} */ formFields?: any; /** * The maximum size of a file to be uploaded (in bytes). */ maxSizeLimit?: number; /** * Specify how many threads (<=4) are to be used. Only valid when {useUploader} is true. */ threads?: number; /** * Specify the names for the files in the form. * Example: "RemoteName<%06d>" */ remoteName?: string; /** * Specify the name(s) (pattern) of the uploaded files. * Example: "uploadedFile<%06d>.jpg" */ fileName?: string; }; }; } ``` - [`Device`](/_articles/info/api/interfaces.md#device) - [`EnumDWT_TransferMode`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_transfermode) - [`EnumDWT_FileFormat`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_fileformat) - [`EnumDWT_CompressionType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_compressiontype) - [`EnumDWT_PixelType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_pixeltype) - [`EnumDWT_CapSupportedSizes`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_capsupportedsizes) - [`EnumDWT_UnitType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_unittype) - [`EnumDWT_CapPixelFlavor`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_cappixelflavor) - [`EnumDWT_ImageType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype) - [`EnumDWT_PDFCompressionType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_pdfcompressiontype) - [`EnumDWT_TIFFCompressionType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_tiffcompressiontype) - [`Status`](/_articles/info/api/interfaces.md#status) - [`TiffTag`](/_articles/info/api/interfaces.md#tifftag) ### Status **Syntax** ```typescript interface Status { bScanCompleted?: boolean; event?: string; result?: { currentPageNum?: number; outputInfo?:OutputInfo;  }; } ``` [`OutputInfo`](/_articles/info/api/interfaces.md#outputinfo) is only returned for `postTransfer` event. ### TiffTag **Syntax** ```typescript interface TiffTag { tagIdentifier?: number; content?: string; useBase64Encoding?: boolean; } ``` ### OutputInfo **Syntax** ```typescript interface OutputInfo { /** * Id of the image if it's transferred to the buffer. */ imageId?: string; /** * Path of the image if it's transferred to the disk. */ path?: string; /** * Information about the image. */ imageInfo?: object; /** * Extended information about the image. */ extendedImageInfo?: object; } ``` ### CapabilityDetails **Syntax** ```typescript /** * Detailed information about a specific capability */ interface CapabilityDetails { /** * The Capability. */ capability: ValueAndLabel; /** * The container type of the Capability */ conType?: ValueAndLabel; /** * The index for the current value of the Capability */ curIndex?: number; /** * The current value of the Capability * Except TWON_ARRAY type whose current values return via the attribute values */ curValue?: ValueAndLabel | string | number | Frame; /** * The default value of the Capability */ defaultValue?: ValueAndLabel | string | number | Frame; /** * The maximum value of the Capability */ maxValue?: number; /** * The minimum value of the Capability */ minValue?: number; /** * The step size of the Capability */ stepSize?: number; /** * The index for the default value of the Capability */ defIndex?: number; /** * The operation types that are supported by the Capability. Types include {"get", "set", "reset" "getdefault", "getcurrent"} */ query?: string[]; /** * The value type of the Capability. Value types include TWTY_BOOL: 6 TWTY_FIX32: 7 TWTY_FRAME: 8 TWTY_INT8: 0 TWTY_INT16: 1 TWTY_INT32: 2 TWTY_STR32: 9 TWTY_STR64: 10 TWTY_STR128: 11 TWTY_STR255: 12 TWTY_UINT8: 3 TWTY_UINT16: 4 TWTY_int: 5 */ valueType?: ValueAndLabel; /** * The current values of the Capability when conType's label is TWON_ARRAY. */ values?: ValueAndLabel[] | any[]; /** * The available values of the Capability when conType's label is TWON_ENUMERATION. */ enums?: ValueAndLabel[] | any[]; } ``` - [`ValueAndLabel`](/_articles/info/api/interfaces.md#valueandlabel) - [`Frame`](/_articles/info/api/interfaces.md#frame) ### ValueAndLabel **Syntax** ```typescript interface ValueAndLabel { /** * Numeric representation of the item */ value?: Dynamsoft.DWT.EnumDWT_Cap | Dynamsoft.DWT.EnumDWT_CapType | Dynamsoft.DWT.EnumDWT_CapValueType | number; /** * Label or name of the item */ label?: string; } ``` - [`EnumDWT_Cap`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_cap) - [`EnumDWT_CapType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_captype) - [`EnumDWT_CapValueType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_capvaluetype) ### Frame **Syntax** ```typescript interface Frame{ left:number, top:number, right:number, bottom:number, } ``` ### Capabilities **Syntax** ```typescript interface Capabilities { /** * Whether to "ignore" or "fail" the request if an exception occurs. This is an overall setting that is inherited by all capabilities. */ exception: string; /** * Specifies how to set capabilities */ capabilities: CapabilitySetup[]; } ``` - [`CapabilitySetup`](/_articles/info/api/interfaces.md#capabilitysetup) ### CapabilitySetup **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; } ``` - [`EnumDWT_Cap`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_cap) ## Viewer ### CustomElement **Syntax** ```typescript interface CustomElement { /** * Show the custom element. */ show(): boolean; /** * Hide the custom element. */ hide(): boolean; /** * Remove the custom element. */ dispose(): boolean; /** * Return the created element. */ element?: any; }; ``` ### ImageEditor **Syntax**
>- v18.4+ >- v18.3 >- v18.2 > > ```typescript interface ImageEditor { /** * Show the ImageEditor object. */ show(): boolean; /** * Keeps the image data in the browser editor in sync with the buffer. **/ save(): Promise; /** * Hide the ImageEditor object. */ hide(): boolean; /** * Remove the ImageEditor object. */ dispose(): boolean; /** * Set the selection box styling */ updateSelectionBoxStyle(selectionBoxStyleSettings?: SelectionBoxStyleSettings): boolean; /**      * Set the zoom origin.      */ zoomOrigin?: { x: string; //x-coordinate. Default is "center", values: "left", "right", "center" y: string; //y-coordinate. Default is "center", values: "top", "bottom", "center" } }; ``` ```typescript interface ImageEditor { /** * Show the ImageEditor object. */ show(): boolean; /** * Keeps the image data in the browser editor in sync with the buffer. **/ save(): Promise; /** * Hide the ImageEditor object. */ hide(): boolean; /** * Remove the ImageEditor object. */ dispose(): boolean; /**      * Set the zoom origin.      */ zoomOrigin?: { x: string; //x-coordinate. Default is "center", values: "left", "right", "center". y: string; //y-coordinate. Default is "center", values: "top", "bottom", "center" } }; ``` ```typescript interface ImageEditor { /** * Show the ImageEditor object. */ show(): boolean; /** * Keeps the image data in the browser editor in sync with the buffer. **/ save(): Promise; /** * Hide the ImageEditor object. */ hide(): boolean; /** * Remove the ImageEditor object. */ dispose(): boolean; }; ``` - [`SelectionBoxStyleSettings`](/_articles/info/api/interfaces.md#selectionboxstylesettings) ### EditorSettings **Syntax**
>- v18.3+ >- v18.2 > > ```typescript interface EditorSettings { /**      * Specify an HTML Element.      */ element?: HTMLDivElement | HTMLElement; /**      * The width of the image editor viewer. The default value is "100%".      * 'Invalid property value' will be reported when the set value is not string or number.      */ width?: number | string; /**      * The height of the image editor viewer. The default value is "100%".      * 'Invalid property value' will be reported when the set value is not string or number.      */ height?: number | string; /** * The border of the ImageEditor viewer.      * 'Invalid property value' is reported when the set value does not meet the CSS standard.      */ border?: string; /**      * Set the border of the top toolbar.      * 'Invalid property value' is reported when the set value does not meet the CSS standard.      */ topMenuBorder?: string; /**      * The inner border of the image area.      */ innerBorder?: string; /**      * The background color/image of the ImageEditor viewer.      * 'Invalid property value' is reported when the set value does not meet the CSS standard.      */ background?: string; /**      * Whether to pop up a window prompting to save the changes. The default value is true.      * 'Invalid property value' will be reported when the specified value type is wrong or the parameter name is spelled incorrectly.      */ promptToSaveChange?: boolean; /**      * Modify button titles and whether to hide specific buttons in the image editor viewer.      * 'Invalid property value' will be reported when the specified value type is wrong or the parameter name is spelled incorrectly.      */ buttons?: any; /**      * Define the dialog text      * 'Invalid property value' will be reported when the specified value type is wrong or the parameter name is spelled incorrectly.      */ dialogText?: any; /**      * Default is normal, values: normal=0, balance=1.      */ workMode?: number | Dynamsoft.DWT.EnumDWT_WorkMode; /**      * Set the zoom origin.      */ zoomOrigin?: { x: string; //x-coordinate. Default is "center", values: "left", "right", "center". y: string; //y-coordinate. Default is "center", values: "top", "bottom", "center". }; } ``` ```typescript interface EditorSettings { /**      * Specify an HTML Element.      */ element?: HTMLDivElement | HTMLElement; /**      * The width of the image editor viewer. The default value is "100%".      * 'Invalid property value' will be reported when the set value is not string or number.      */ width?: number | string; /**      * The height of the image editor viewer. The default value is "100%".      * 'Invalid property value' will be reported when the set value is not string or number.      */ height?: number | string; /** * The border of the ImageEditor viewer.      * 'Invalid property value' is reported when the set value does not meet the CSS standard.      */ border?: string; /**      * Set the border of the top toolbar.      * 'Invalid property value' is reported when the set value does not meet the CSS standard.      */ topMenuBorder?: string; /**      * The inner border of the image area.      */ innerBorder?: string; /**      * The background color/image of the ImageEditor viewer.      * 'Invalid property value' is reported when the set value does not meet the CSS standard.      */ background?: string; /**      * Whether to pop up a window prompting to save the changes. The default value is true.      * 'Invalid property value' will be reported when the specified value type is wrong or the parameter name is spelled incorrectly.      */ promptToSaveChange?: boolean; /**      * Modify button titles and whether to hide specific buttons in the image editor viewer.      * 'Invalid property value' will be reported when the specified value type is wrong or the parameter name is spelled incorrectly.      */ buttons?: any; /**      * Define the dialog text      * 'Invalid property value' will be reported when the specified value type is wrong or the parameter name is spelled incorrectly.      */ dialogText?: any; /**      * Default is normal, value: normal=0, balance=1.      */ workMode?: number | Dynamsoft.DWT.EnumDWT_WorkMode; } ``` - [EnumDWT_WorkMode](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_workmode). ### ThumbnailViewer **Syntax** ```typescript interface ThumbnailViewer { /** * Show the ThumbnailViewer object. */ show(): boolean; /** * Hide the ThumbnailViewer object. */ hide(): boolean; /** * Remove the ThumbnailViewer object. */ dispose(): boolean; /** * Change the view mode of the thumbnail viewer. * @param viewMode Specify the new mode. */ updateViewMode(viewMode: ViewMode): void; /** * Change the checkbox style. Available in v17.3+. * @param checkboxSettings Specify the checkbox settings. */ updateCheckboxStyle(checkboxSettings?: CheckboxSettings): void; /** * Change the page number style. Available in v17.3+. * @param pageNumberSettings Specify the page number settings. */ updatePageNumberStyle(pageNumberSettings?: PageNumberSettings): void; /** * Return the information of visible pages. It is useful to add elements to document page images in the viewer. */ getVisiblePagesInfo(): VisiblePageInfo[]; /** * Bind a listener to the specified event. You can bind one or multiple listeners to the same event. * @param eventName Specify the event name. * @param callback Specify the listener. */ on(eventName: string, callback: (event: ThumbnailViewerEvent | KeyboardEvent, domEvent?: MouseEvent) => void): void; /** * Unbind event listener(s) from the specified viewer event. * @param eventName Specify the event. * @param callback Specify the listener to remove */ off(eventName: string, callback?: () => void): void; /** * Where to put the thumbnail view. The allowed values are left, top, right, bottom. The default value is left. * 'Invalid property value' will be reported when the specified value type is wrong or the parameter name is spelled incorrectly. */ location: string; /** * Specify the size of width or height in pixels or percentage. The default value is 30%. * 'Invalid property value' will be reported when the specified value type is wrong or the parameter name is spelled incorrectly. * number in pixels, string in percentage */ size: number | string; /** * * Specify scroll direction. Allowed values are 'vertical' and 'horizontal'. * 'Invalid property value' will be reported when the specified value type is wrong or the parameter name is spelled incorrectly. */ scrollDirection: string; /** * Set the margin between images & the margin between image and the viewer border). The default value is 10. * Invalid property value' will be reported when the specified value type is wrong or the parameter name is spelled incorrectly. * number in pixels, string in percentage */ pageMargin: number | string; /** * Set the background of the entire thumbnail viewer. The default value is white. * 'Invalid property value' will be reported when the specified value type is wrong or the parameter name is spelled incorrectly. * Allow any CSS rules */ background: string; /** * Set the border of the thumbnail viewer. * 'Invalid property value' will be reported when the specified value type is wrong or the parameter name is spelled incorrectly. * Allow any CSS rules */ border: string; /** * Whether to allow keyboard control. */ allowKeyboardControl: boolean; /** * Whether to allow image dragging. The default value is true. * 'Invalid property value' will be reported when the specified value type is wrong or the parameter name is spelled incorrectly. */ allowPageDragging: boolean; /** * Whether to allow the mouse to resize the thumbnail viewer. The default value is false. * 'Invalid property value' will be reported when the specified value type is wrong or the parameter name is spelled incorrectly. */ allowResizing: boolean; /** * When set to true, will make sure the first image in the viewer is always selected when scrolling through multiple images. */ autoChangeIndex: boolean; /** * Return or set the background color/image of the thumbnail viewer. The default value is white. * 'Invalid property value' will be reported when the specified value type is wrong or the parameter name is spelled incorrectly. * Allow any CSS rules */ pageBackground: string; /** * Set the border of the thumbnail viewer. * 'Invalid property value' will be reported when the specified value type is wrong or the parameter name is spelled incorrectly. * Allow any CSS rules */ pageBorder: string; /** * Set the image background when the mouse is hovered. * 'Invalid property value' will be reported when the specified value type is wrong or the parameter name is spelled incorrectly. * Allow any CSS rules */ hoverPageBackground: string; /** * Set the image border when the mouse is hovered. * 'Invalid property value' will be reported when the specified value type is wrong or the parameter name is spelled incorrectly. * Allow any CSS rules */ hoverPageBorder: string; /** * Set the background when dragging the image. The default value is yellow. * 'Invalid property value' will be reported when the specified value type is wrong or the parameter name is spelled incorrectly. * Allow any CSS rules */ placeholderBackground: string; /** * Set the border of the selected image. * 'Invalid property value' will be reported when the specified value type is wrong or the parameter name is spelled incorrectly. * Allow any CSS rules */ selectedPageBorder: string; /** * Set the background of the selected image. * 'Invalid property value' will be reported when the specified value type is wrong or the parameter name is spelled incorrectly. * Allow any CSS rules */ selectedPageBackground: string; } ``` - [`ViewMode`](/_articles/info/api/interfaces.md#viewmode) - [`VisiblePageInfo`](/_articles/info/api/interfaces.md#visiblepageinfo) - [`CheckboxSettings`](/_articles/info/api/interfaces.md#checkboxsettings) - [`PageNumberSettings`](/_articles/info/api/interfaces.md#pagenumbersettings) - [`ThumbnailViewerEvent`](/_articles/info/api/interfaces.md#thumbnailviewerevent) - [`KeyboardEvent`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent) - [`MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent) ### ThumbnailViewerSettings **Syntax** ```typescript interface ThumbnailViewerSettings { /** * Specify how many images to display per row. */ columns?: number; /** * Specify how many images to display per column. */ rows?: number; /** * Whether to allow keyboard control. Default: true. */ allowKeyboardControl?: boolean; /** * Whether to allow page dragging to reorder the pages. * Default: true. */ allowPageDragging?: boolean; /** * Whether to allow resizing of the thumbnail viewer. * Default: false. */ allowResizing?: boolean; /** * Set or return the CSS rule for the background of the thumbnail viewer. * Default: "rgb(255, 255, 255)". */ background?: string; /** * Set or return the CSS rule for the border of the thumbnail viewer. * Default: "". */ border?: string; /** * Set or return the CSS rule for the background of the page the mouse hovers over in the thumbnail viewer. * Default: "rgb(239, 246, 253)". */ hoverPageBackground?: string; /** * Set or return the CSS rule for the border of the page the mouse hovers over in the thumbnail viewer. * Default: "1px solid rgb(238, 238, 238)". */ hoverPageBorder?: string; /** * Set or return the location of the thumbnail viewer. Allowed values are "left", "right", "top", "bottom". * Default: "left". */ location?: string; /** * Set or return the CSS rule for the background of a normal page in the thumbnail viewer. * Default: "transparent". */ pageBackground?: string; /** * Set or return the CSS rule for the border of a normal page in the thumbnail viewer. * Default: "1px solid rgb(238, 238, 238)". */ pageBorder?: string; /** * Set or return the margin between two adjacent images and the margin between an image and the border of the thumbnail viewer. The value can either be in pixels or percentage. * Default: 10. */ pageMargin?: number | string; /** * Set or return the CSS rule for the background of the placeholder which appears when you drag page(s) to reorder them in the thumbnail viewer. * Default: "rgb(251, 236, 136)". */ placeholderBackground?: string; /** * Set or return whether the pages are arranged vertically or horizontally. * Default: "vertical". Allowed values are "vertical" and "horizontal". */ scrollDirection?: string; /** * Set or return the CSS rule for the background of the selected page(s) in the thumbnail viewer. * Default: "rgb(199, 222, 252)". */ selectedPageBackground?: string; /** * Set or return the CSS rule for the border of the selected page(s) in the thumbnail viewer. * Default: "1px solid rgb(125,162,206)". */ selectedPageBorder?: string; /** * Set or return the size of the thumbnail viewer. The value can either be in pixels or percentage (based on the width or height of the entire viewer). * Default: "30%". */ size?: number | string; /** * Set whether to select the index in the upper left corner of the viewer when scrolling. * Default: false. */ autoChangeIndex?: boolean; checkbox?: { visibility?: string; //"visible":hidden", default: "hidden" width?: number | string; //default: "24px",number unit: px, string value: "24px"/"10%", relative to parent container height?: number | string; //default: "24px",number unit: px, string value: "24px"/"10%", relative to parent container background?: string; //default: "#ffffff" borderWidth?: number | string; //default: "2px", unit: px, percentage value not supported borderColor?: string; //default: "#000000" checkMarkColor?: string; //default: "#000000" checkMarkLineWidth?: number | string; //default: "2px", unit: px, percentage value not supported borderRadius?: number | string; //default: 0, number unit: px, string value: "10px"/"10%",relative to itself opacity?: number; //default:0.5, value range [0-1], value greater 1 defaults to 1 left?: number | string; //default: 0, number unit: px, string value: "10px"/"10%", relative to parent container top?: number | string; //default: 0, number unit: px, string value: "10px"/"10%", relative to parent container right?: number | string; //default: "", number unit: px, string value: "10px"/"10%", relative to parent container bottom?: number | string; //default: "", number unit: px, string value: "10px"/"10%", relative to parent container translateX?: number | string; //default: "", number unit: px, string value: "10px"/"10%", relative to itself translateY?: number | string; //default: "", number unit: px, string value: "10px"/"10%", relative to itself }; pageNumber?: { visibility?: string; //"visible": hidden", default: "hidden" width?: number | string; //default: "24px", number unit: px, string value: "24px"/"10%", relative to parent container height?: number | string; //default: "24px", number unit: px, string value: "24px"/"10%", relative to parent container background?: string; //default: "#ffffff" borderWidth?: number | string; //default: "1px", unit: px, percentage value not supported borderColor?: string; //default: "#a79898" borderRadius?: number | string; //default: "50%", number unit: px, string value: "10px"/"10%", relative to itself opacity?:number; //default: 0.5, value range [0-1], value greater 1 defaults to 1 color?: string; //default: "#000000", supports #16 hexadecimal only fontFamily?: string; //default: "sans-serif" fontSize?: number | string; //default: 12, unit: px, percentage value not supported left?: number | string; //default: "", number unit: px, string value: "10px"/"10%", relative to parent container top?: number | string; //default: "", number unit: px, string value: "10px"/"10%", relative to parent container right?: number | string; //default: 0, number unit: px, string value: "10px"/"10%", relative to parent container bottom?: number | string; //default: 0, number unit: px, string value: "10px"/"10%", relative to parent container translateX?: number | string; //default: "", number unit: px, string value: "10px"/"10%", relative to itself translateY?: number | string; //default: "", number unit: px, string value: "10px"/"10%", relative to itself }; } ``` ### ThumbnailViewerEvent **Syntax** ```typescript interface ThumbnailViewerEvent { // The index of the current document page. index: number; // The mouse's x coordinate in the thumbnail image container relative to the top-left of the web page. pageX: number; // The mouse's y coordinate in the thumbnail image container relative to the top-left of the web page. pageY: number; // The width of the thumbnail image container. pageWidth: number; // The height of the thumbnail image container. pageHeight: number; // The corresponding x coordinate in the original image. imageX: number; // The corresponding y coordinate in the original image. imageY: number; // The thumbnail image container's relative position. position: { // The x coordinate relative to the container of the viewer. containerOffsetX: number; // The y coordinate relative to the container of the viewer. containerOffsetY: number; // The x coordinate relative to the canvas. canvasOffsetX: number; // The y coordinate relative to the canvas. canvasOffsetY: number; } }; ``` You can check out the following image for better understanding. ![thumbnail viewer event](/assets/imgs/thumbnail-viewer-event.jpg) ### ViewMode **Syntax** ```typescript interface ViewMode { /** * Specify the number of images per row. */ columns?: number; /** * Specify the number of images per column. */ rows?: number; /** * Set or return whether the pages are arranged vertically or horizontally. * Default: "vertical". Allowed values are "vertical" and "horizontal". */ scrollDirection?: string; } ``` ### VisiblePageInfo **Syntax** ```typescript /** * Info of a visible page. */ export interface VisiblePageInfo { /** * The index of the document page. */ pageIndex: number; /** * Whether the mouse is hovering over the document page. */ isHovered: boolean; /** * Whether the document page is selected. */ isSelected: boolean; /** * The width of the document page image container. */ pageWidth: number; /** * The height of the document page image container. */ pageHeight: number; /** * The x coordinate relative to the canvas. */ canvasOffsetX: number; /** * The y coordinate relative to the canvas. */ canvasOffsetY: number; /** * The x coordinate relative to the container of the viewer. */ containerOffsetX: number; /** * The y coordinate relative to the container of the viewer. */ containerOffsetY: number; } ``` ### Area **Syntax** ```typescript interface Area { left: number; top: number; right: number; bottom: number; }; ``` ### CheckboxSettings **Syntax** ```typescript interface CheckboxSettings { visibility?: string; //"visible": hidden", default: "hidden" width?: number | string; //default: "24px", number unit: px, string value: "24px"/"10%", relative to parent container height?: number | string; //default: "24px", number unit: px, string value: "24px"/"10%", relative to parent container background?: string; //default: "#ffffff" borderWidth?: number | string; //default: "2px", unit: px, percentage value not supported borderColor?: string; //default: "#000000" checkMarkColor?: string; //default: "#000000" checkMarkLineWidth?: number | string; //default: "2px", unit: px, percentage value not supported borderRadius?: number | string; //default: 0, number unit: px, string value: "10px"/"10%", relative to itself opacity?: number; //default:0.5, value range [0-1], value greater 1 defaults to 1 left?: number | string; //default: 0, number unit: px, string value: "10px"/"10%", relative to parent container top?: number | string; //default: 0, number unit: px, string value: "10px"/"10%", relative to parent container right?: number | string; //default: "", number unit: px, string value: "10px"/"10%", relative to parent container bottom?: number | string; //default: "", number unit: px, string value: "10px"/"10%", relative to parent container translateX?: number | string; //default: "", number unit: px, string value: "10px"/"10%", relative to itself translateY?: number | string; //default: "", number unit: px, string value: "10px"/"10%", relative to itself } ``` ### PageNumberSettings **Syntax** ```typescript interface PageNumberSettings { visibility?: string; //"visible": hidden", default: "hidden" width?: number | string; //default: "24px", number unit: px, string value: "24px"/"10%", relative to parent container height?: number | string; //default: "24px", number unit: px, string value: "24px"/"10%", relative to parent container background?: string; //default:"#ffffff" borderWidth?: number | string; //default: "1px", unit: px, percentage value not supported borderColor?: string; //default: "#a79898" borderRadius?: number | string; //default: "50%", number unit: px, string value: "10px"/"10%", relative to itself opacity?:number; //default: 0.5, value range [0-1], value greater 1 defaults to 1 color?: string; //default: "#000000", supports #16 hexadecimal only fontFamily?: string; //default: "sans-serif" fontSize?: number | string; //default: 12, unit: px, percentage value not supported left?: number | string; //default: "", number unit: px, string value: "10px"/"10%", relative to parent container top?: number | string; //default: "", number unit: px, string value: "10px"/"10%", relative to parent container right?: number | string; //default: 0, number unit: px, string value: "10px"/"10%", relative to parent container bottom?: number | string; //default: 0, number unit: px, string value: "10px"/"10%", relative to parent container translateX?: number | string; //default: "", number unit: px, string value: "10px"/"10%", relative to itself translateY?: number | string; //default: "", number unit: px, string value: "10px"/"10%", relative to itself } ``` ### SelectionBoxStyleSettings ```typescript interface SelectionBoxStyleSettings { borderColor?: string; //Default: rgba(0,0,0,1). Selection box line segment color in "rgba(r, g, b, a)" borderWidth?: number; //Default: 1. Unit: pixels. Width of individual pattern segments. lineDash?: [number,number]; //Default: [5,2]. Unit: pixels. Line spacing where x is shaded pixels and y is gap in pixels. handleWidth?: number; //Default: 9. Unit: pixels. Width of the selection box control handle. handleHeight?: number; //Default: 9. Unit: pixels. Height of the selection box control handle. handleColor?: string; //Default: rgba(0,0,0,1). Selection box control handle color in "rgba(r, g, b, a)" } ``` ### ViewerEvent **Syntax** ```typescript interface ViewerEvent { // The index of the current page. index: number; //The x-coordinate of the upper-left corner of the page. imageX: number; //The y-coordinate of the upper-left corner of the page. imageY: number; // The x-coordinate of the browser page. pageX: number; // The y-coordinate of the browser page. pageY: number; }; ``` ### rect **Syntax** ```typescript interface rect{ // The index of the selected area. The index is 0-based. This is useful when you have multiple selected areas on one page. areaIndex: number; // The x-coordinate of the upper-left corner of the area. x: number; // The y-coordinate of the upper-left corner of the area. y: number; // The width of the selected area. width: number; // The height of the selected area. height: number; }; ``` ## Buffer ### TagInfo **Syntax** ```typescript interface TagInfo { name: string; imageIds: string[]; } ``` ### BufferChangeInfo **Syntax** ```typescript interface BufferChangeInfo { /** * Action type includes 'add', 'remove', 'modify', 'shift' and 'filter' */ action: string; /** * The image id (not the index) of the current page. */ currentId: string; /** * All image ids. */ imageIds: string[]; /** * All selected image ids. */ selectedIds: string[]; /** * The modified imageId, only available when action type is 'modify'. */ modifiedId?: string; } ``` ### DocumentInfo **Syntax** ```typescript interface DocumentInfo { name: string; imageIds: string[]; } ``` ## Output ### Base64Result **Syntax** ```typescript interface Base64Result { /** * Return the length of the result string. */ getLength(): number; /** * Return part of the string. * @param offset The starting position. * @param length The length of the expected string. */ getData(offset: number, length: number): string; /** * Return the MD5 value of the result. */ getMD5(): string; } ``` ### PrintSettings ```ts interface PrintSettings { mode?: string; // "os" or "browser" osPrintOptions?: { showPrintDialog?: boolean; } } ``` Usage note: Set the `mode` parameter to choose the printing API: * `os`: Uses the operating system's API. Currently, only Windows is supported. * `browser`: Uses the browser's API. There are extra options for the `os` mode. You can set whether to show the print dialog to update the print setting. If the print dialog is not shown, it will use previous settings. ## OCR ### OCRInfo The info of the installed OCR add-on. **Syntax** ```ts interface OCRInfo { version: string; } ``` ### OCRResult The OCR result of one page. If the page is rotated, the geometry will be based on the orientation-corrected version. **Syntax** ```ts interface OCRResult { imageID: string; dimensions: {width: number; height: number}; orientation: {value: number; confidence: number}; blocks:{ geometry: {left: number; top: number; right: number; bottom: number}; lines: { geometry: {left: number; top: number; right: number; bottom: number}; words?:{ value: string; confidence: number; geometry: {left: number; top: number; right: number; bottom: number}; }[]; }[]; }[]; } ``` ## PDF ### ReaderOptions Sets the PDF Rasterizer parameters. **Syntax** ```typescript interface ReaderOptions { /** * Default value: CM_AUTO */ convertMode: Dynamsoft.DWT.EnumDWT_ConvertMode | number; /** * If a password is required to open the PDF, set it here. Default value: "". */ password?: string; renderOptions?: { /** * Controls whether or not annotations will be rendered. Only valid if convertMode is set to CM_RENDERALL or CM_AUTO with a valid PDF Rasterizer license. Default value: false. */ renderAnnotations?: boolean; /** * DPI. Only affects text being rasterized. Does not affect images extracted from the PDF file. Default value: 200. */ resolution?: number; /** * Pixels. 0 is no limit. Default value: 0. */ maxWidth?: number; /** * Pixels. 0 is no limit. Default value: 0. */ maxHeight?: number; /** * Whether or not to render in grayscale. Default value: false. */ renderGrayscale?: boolean; } /** * Set whether to preserve original file size when saving an unedited PDF whose pages were not modified under any raster operations. Default value: false. */ preserveUnmodifiedOnSave?: boolean; } ``` - [`EnumDWT_ConvertMode`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_convertmode) > Note: Rendering Logic When Two or More of the Following Properties Are Specified - maxWidth, maxHeight, and resolution: - Calculates the target image dimensions based on the original PDF page size and the specified resolution (DPI). - When both maxWidth and maxHeight are set, the more restrictive constraint is applied to ensure the final image does not exceed either maximum. - If the calculated dimensions exceed the specified maxWidth or maxHeight, the page is scaled down proportionally to fit within those constraints while preserving the original aspect ratio. This results in a lower effective resolution. ### PDFWSettings Specify the pdf writing settings. **Syntax** ```typescript interface PDFWSettings { /** * Specify the author. */ author?: string; /** * Specify the compression type. */ compression?: Dynamsoft.DWT.EnumDWT_PDFCompressionType | number; /** * Specify the page type. */ pageType?: Dynamsoft.DWT.EnumPDF_Page | number; /** * Specify the creator. */ creator?: string; /** * Specify the creation date. * Note that the argument should start with 'D:' like 'D:20181231'. */ creationDate?: string; /** * Specify the key words. */ keyWords?: string; /** * Specify the modified date. * Note that the argument should start with 'D:' like 'D:20181231'. */ modifiedDate?: string; /** * Specify the producer. */ producer?: string; /** * Specify the subject. */ subject?: string; /** * Specify the title. */ title?: string; /** * Specify the PDF version. For example, 1.5. The allowed values are 1.1 ~ 1.7. * NOTE: If the compression type is PDF_JBig2, the lowest allowed version is 1.4 * If the compression type is PDF_JP2000, the lowest allowed version is 1.5 */ version?: string; /** * Specify the quality of the images in the file. * The value ranges from 0 to 100. * Only valid when the {compression} is 'JPEG' or 'JPEG2000'. */ quality?: number; /** * From version 18.5 * Specify the password. * Default value: '' * Up to 32 characters. */ password?: string; /** * From version 19.3 * Specify PDF/A version to save as PDF/A. * Supported values: "pdf/a-1b", "pdf/a-2b", "pdf/a-3b" */ pdfaVersion?: string; } ``` - [`EnumDWT_PDFCompressionType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_pdfcompressiontype) - [`EnumPDF_Page`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumpdf_page) ## Webcam ### CameraControlProperty The information about the specified camera property. **Syntax** ```typescript interface CameraControlProperty { /** * Return the value of the property. */ GetValue(): number; /** * Return whether the property is set automatically or not. */ GetIfAuto(): boolean; } ``` ### CameraControlPropertyExtra The detailed information about the specified camera property. **Syntax** ```typescript interface CameraControlPropertyExtra { /** * Return the minimum value of the property. */ GetMinValue(): number; /** * Return the maximum value of the property. */ GetMaxValue(): number; /** * Return the default value of the property. */ GetDefaultValue(): number; /** * Return the smallest increment by which the property can change. */ GetSteppingDelta(): number; /** * Return whether the property is set automatically or not. */ GetIfAuto(): boolean; } ``` ### VideoControlProperty The information about the specified video property. **Syntax** ```typescript interface VideoControlProperty { /** * Return the value of the property. */ GetValue(): number; /** * Return whether the property is set automatically or not. */ GetIfAuto(): boolean; } ``` ### VideoControlPropertyExtra The detailed information about the specified video property. **Syntax** ```typescript interface VideoControlPropertyExtra { /** * Return the minimum value of the property. */ GetMinValue(): number; /** * Return the maximum value of the property. */ GetMaxValue(): number; /** * Return the default value of the property. */ GetDefaultValue(): number; /** * Return the smallest increment by which the property can change. */ GetSteppingDelta(): number; /** * Return whether the property is set automatically or not. */ GetIfAuto(): boolean; } ``` ### FrameRate The frame rates. **Syntax** ```typescript interface FrameRate { /** * Return the number of available frame rates. */ GetCount(): number; /** * Return the specified frame rate. */ Get(index: number): number; /** * Return the current frame rate. */ GetCurrent(): number; } ``` ### MediaType The media types. **Syntax** ```typescript interface MediaType { /** * Return the number of available media types. */ GetCount(): number; /** * Return the specified media type. */ Get(index: number): string; /** * Return the current media type. */ GetCurrent(): string; } ``` ### Resolution The resolutions. **Syntax** ```typescript interface Resolution { /** * Return the number of available resolutions. */ GetCount(): number; /** * Return the specified resolution. */ Get(index: number): string; /** * Return the current resolution. */ GetCurrent(): string; } ``` ## BarcodeReader ### TextResult **Syntax** ```typescript interface TextResult { /** * Barcode result content in a byte array. */ barcodeBytes: number[]; /** * The barcode format. */ barcodeFormat: Dynamsoft.DBR.EnumBarcodeFormat | number; /** * Extra barcode formats. */ barcodeFormat_2: Dynamsoft.DBR.EnumBarcodeFormat_2 | number; /** * Barcode formats as a string. */ barcodeFormatString: string; /** * Extra barcode formats as a string. */ barcodeFormatString_2: string; /** * The barcode result text. */ barcodeText: string; /** * Detailed result information. */ detailedResult: any; /** * The corresponding localization result. */ localizationResult: LocalizationResult; /** * Other information */ results: Result[]; } ``` - [`EnumBarcodeFormat`](https://www.dynamsoft.com/barcode-reader/docs/v9/web/programming/javascript/api-reference/enum/EnumBarcodeFormat.html?ver=9.6.42) - [`EnumBarcodeFormat_2`](https://www.dynamsoft.com/barcode-reader/docs/v9/web/programming/javascript/api-reference/enum/EnumBarcodeFormat_2.html?ver=9.6.42) - [`LocalizationResult`](/_articles/info/api/interfaces.md#localizationresult) - [`Result`](/_articles/info/api/interfaces.md#result) ### LocalizationResult **Syntax** ```typescript interface LocalizationResult { /** * The angle of a barcode. Values range from 0 to 360. */ angle: number; /** * The X coordinate of the left-most point. */ x1: number; /** * The X coordinate of the second point in a clockwise direction. */ x2: number; /** * The X coordinate of the third point in a clockwise direction. */ x3: number; /** * The X coordinate of the fourth point in a clockwise direction. */ x4: number; /** * The Y coordinate of the left-most point. */ y1: number; /** * The Y coordinate of the second point in a clockwise direction. */ y2: number; /** * The Y coordinate of the third point in a clockwise direction. */ y3: number; /** * The Y coordinate of the fourth point in a clockwise direction. */ y4: number; moduleSize: number; pageNumber: number; regionName: number; resultCoordinateType: number; terminatePhase: number; } ``` ### Result **Syntax** ```typescript interface Result { accompanyingTextBytes: number[]; clarity: number; confidence: number; deformation: number; resultType: number; } ``` ### RuntimeSettings **Syntax** ```typescript interface RuntimeSettings { barcodeFormatIds: number; barcodeFormatIds_2: number; binarizationModes: number[]; deblurLevel: number; expectedBarcodesCount: number; furtherModes: FurtherModes; intermediateResultSavingMode: number; intermediateResultTypes: number; localizationModes: number[]; maxAlgorithmThreadCount: number; minBarcodeTextLength: number; minResultConfidence: number; pdfRasterDPI: number; pdfReadingMode: number; region: Region; resultCoordinateType: number; returnBarcodeZoneClarity: number; scaleDownThreshold: number; scaleUpModes: number[]; terminatePhase: number; textResultOrderModes: number[]; timeout: number; } ``` - [`FurtherModes`](/_articles/info/api/interfaces.md#furthermodes) - [`Region`](/_articles/info/api/interfaces.md#region) - For more detailed information, please [click the link](https://www.dynamsoft.com/barcode-reader/docs/v9/web/programming/javascript/api-reference/interface/RuntimeSettings.html?ver=9.6.42) to view. ### FurtherModes **Syntax** ```typescript interface FurtherModes { accompanyingTextRecognitionModes: number[]; barcodeColourModes: number[]; barcodeComplementModes: number[]; colourClusteringModes: number[]; colourConversionModes: number[]; deformationResistingModes: number[]; dpmCodeReadingModes: number[]; grayscaleTransformationModes: number[]; imagePreprocessingModes: number[]; regionPredetectionModes: number[]; textAssistedCorrectionMode: number; textFilterModes: number[]; textureDetectionModes: number[]; } ``` - For more detailed information, please [click the link](https://www.dynamsoft.com/barcode-reader/docs/v9/web/programming/javascript/api-reference/interface/furthermodes.html?ver=9.6.42) to view. ### Region **Syntax** ```typescript interface Region { regionBottom: number; regionLeft: number; regionMeasuredByPercentage: number; regionRight: number; regionTop: number; } ``` - For more detailed information, please [click the link](https://www.dynamsoft.com/barcode-reader/docs/v9/web/programming/javascript/api-reference/interface/Region.html?ver=9.6.42) to view. ## FileUploader ### FormField ```typescript interface FormField { /** * Specify the block size. By default, it's 10240. * @param key Specify the key of the field. * @param value Sepcify the value of the field. */ Add: ( key: string; value: string; ) => boolean; } ``` ### SourceValue ```typescript interface SourceValue { /** * Specify the block size. By default, it's 10240. * @param source A URL to specify the content of the file. * Normally it's generated by {GenerateURLForUploadData()} * @param name Specify the name of the file. * @param key Specify the key of the file in the request. This key can be used to retrieve the file content in server-side scripts. */ Add: ( source: string; name: string; key?: string; ) => void; } ```
--- title: Dynamic Web TWAIN API Reference - RESTful API description: Dynamic Web TWAIN SDK Documentation API Reference RESTful API source_url: html: https://www.dynamsoft.com/web-twain/docs/info/api/restful.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/api/restful.md --- # RESTful API This is the comprehensive reference for the Dynamic Web TWAIN RESTful API. By default, all APIs use the root URL [`https://127.0.0.1:18623/api`](https://127.0.0.1:18623/api) set by the Dynamic Web TWAIN Service. (can also use [`http://127.0.0.1:18622/api`](http://127.0.0.1:18622/api)) Read about how to alter the address along with a developer walkthrough in our [user guide](/_articles/extended-usage/restful-api.md). [**Server Control**](#server-control) | Endpoint | Method | Description | | --------------------------------------- | ------- | -------------------------------- | | [`/server`](#get-server) | `GET` | Get server settings | | [`/server`](#patch-server) | `PATCH` | Update specified server settings | | [`/server/version`](#get-serverversion) | `GET` | Get server API version | [**Scanner Control**](#scanner-control) | Endpoint | Method | Description | | ---------------------------------------------------------------------------------------------------------- | -------- | ---------------------------------------------- | | [`/device/scanners`](#get-devicescanners) | `GET` | Get list of scanners | | [`/device/scanners/jobs`](#post-devicescannersjobs) | `POST` | Create a scan job | | [`/device/scanners/jobs/{jobuid}`](#get-devicescannersjobsjobuid) | `GET` | Get status of a scan job | | [`/device/scanners/jobs/{jobuid}`](#patch-devicescannersjobsjobuid) | `PATCH` | Update status of a scan job | | [`/device/scanners/jobs/{jobuid}`](#delete-devicescannersjobsjobuid) | `DELETE` | Delete a scan job | | [`/device/scanners/jobs/{jobuid}/scanner/capabilities`](#get-devicescannersjobsjobuidscannercapabilities) | `GET` | Retrieve scanner capabilities specified in a scan job | | [`/device/scanners/jobs/{jobuid}/scanner/settings`](#get-devicescannersjobsjobuidscannersettings) | `GET` | Retrieve settings of scanner specified in a scan job. | | [`/device/scanners/jobs/{jobuid}/next-page-info`](#get-devicescannersjobsjobuidnext-page-info) | `GET` | Get information of the next page in a scan job | | [`/device/scanners/jobs/{jobuid}/next-page`](#get-devicescannersjobsjobuidnext-page) | `GET` | Get the page in a scan job | | [`/device/scanners/jobs/{jobuid}/content`](#get-devicescannersjobsjobuidcontent) | `GET` | Get scanned image content by page index | [**Document Management**](#document-management) | Endpoint | Method | Description | | ----------------------------------------------------------------------------------------------------- | -------- | ----------------------------------- | | [`/storage/documents`](#post-storagedocuments) | `POST` | Create a new document for storage | | [`/storage/documents/{documentuid}`](#get-storagedocumentsdocumentuid) | `GET` | Get info of a stored document | | [`/storage/documents/{documentuid}`](#patch-storagedocumentsdocumentuid) | `PATCH` | Update customData of a stored document | | [`/storage/documents/{documentuid}`](#delete-storagedocumentsdocumentuid) | `DELETE` | Delete a stored document | | [`/storage/documents/{documentuid}/content`](#get-storagedocumentsdocumentuidcontent) | `GET` | Get content of a stored document | | [`/storage/documents/{documentuid}/pages`](#post-storagedocumentsdocumentuidpages) | `POST` | Insert pages into a stored document | | [`/storage/documents/{documentuid}/pages/{param}`](#delete-storagedocumentsdocumentuidpagesparam) | `DELETE` | Delete a page in a stored document | [**Document Processing**](#document-processing) | Endpoint | Method | Description | | ------------------------------------------------- | ------ | ---------------------------------------------------- | | [`/process/read-barcode`](#post-processread-barcode) | `POST` | Read a barcode on a page scanned from a specified source | | [`/process/check-blank`](#post-processcheck-blank) | `POST` | Check if a page scanned from a specified source is blank | ## Server Control ### `GET /server` Get the server settings. Some settings require administrator privileges to retrieve. #### Parameters None #### Request Example Only valid request: ```js const url = new URL("https://127.0.0.1:18623/api"); const pathSegments = ['server']; 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)); ``` #### Responses | HTTP Status Code | Meaning | Description | Data Schema | | ---------------- | ----------------------------------------------------------------------- | -------------------- | --------------------------------------- | | 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | Successful operation. | [`ServerSettings`](#serversettings) | | 405 | [Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5) | Method not allowed. | [`Error`](#error) | #### Response Examples ##### 200 Response ```json { "logLevel": 1 } ``` ##### 405 Response ```json { "code": -2112, "message": "This endpoint only supports GET, PATCH.", "statusCode": 405 } ``` ### `PATCH /server` Update specified server settings. Some settings require administrator privileges to modify. #### Parameters | Name | Location | Type | Required | Restrictions | Description | | -------- | -------- | ------------- | -------- | ----------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | |logLevel|body|[`ServerSettingsInput`](#serversettingsinput)| no |none| #### Request Example Set DWT Service log verbosity to maximum: ```js const url = new URL("https://127.0.0.1:18623/api"); const pathSegments = ['server']; url.pathname = `${url.pathname}/${pathSegments.join('/')}`; let myHeaders = new Headers(); myHeaders.append("Content-Type", "application/json"); let raw = JSON.stringify({ logLevel: 30 }); let requestOptions = { method: 'PATCH', headers: myHeaders, body: raw, redirect: 'follow' }; fetch(url, requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` #### Responses |HTTP Status Code |Meaning|Description|Data Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Successful operation.| [`ServerSettings`](#serversettings)| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Bad request, e.g. parameter is invalid.|[`Error`](#error)| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Method not allowed.|[`Error`](#error)| #### Response Examples 200 Response: ```json { "logLevel": 1 } ``` 400 Response: ```json { "code": -2113, "message": "The parameter is not valid.", "statusCode": 400 } ``` > 405 Response ```json { "code": -2112, "message": "This endpoint only supports GET, PATCH.", "statusCode": 405 } ``` ### `GET /server/version` Get the API version of the server. #### Parameters None #### Request Example Only valid request to get the server API version: ```js const url = new URL("https://127.0.0.1:18623/api"); const pathSegments = ['server', 'version']; 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)); ``` #### Responses |HTTP Status Code |Meaning|Description|Data Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Successful operation.|[`VersionInfo`](#versioninfo)| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Method not allowed.|[`Error`](#error)| #### Response Examples 200 Response: ```json { "version": "20240719", "compatible": true, "moduleVersions": { "core": ["18.5.5.0416", "19.4.0.0410"] } } ``` 405 Response: ```json { "code": -2112, "message": "This endpoint only supports GET.", "statusCode": 405 } ``` ## Scanner Control ### GET /device/scanners Get a list of scanners from the host. By default this returns all scanners, but you can optionally request scanners specified by protocols. Scanner protocols are enumerated with the [`Dynamsoft.DWT.EnumDWT_DeviceType`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_devicetype). #### Parameters |Name|Location|Type|Required|Restrictions|Description| |---|---|---|---|---|---| |`type`|query|[`ScannerType`](#scannertype) | no | One or a combination of:
- `0x10`: `TWAINSCANNER`
- `0x20`: `WIASCANNER`
- `0x40`: `TWAINX64SCANNER`
- `0x80`: `ICASCANNER`
- `0x100`: `SANESCANNER`
- `0x200`: `ESCLSCANNER`
- `0x400`: `WIFIDIRECTSCANNER`
- `0x800`: `WIATWAINSCANNER` |Device type(s), can be one or a combination, specifies TWAIN/TWAIN64/WIA/ICA/SANE by default.| #### Request Example Get the list of all TWAIN/TWAIN64/WIA/ICA/SANE scanners: ```js const url = new URL("https://127.0.0.1:18623/api"); const pathSegments = ['device', 'scanners']; 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)); ``` #### Responses |HTTP Status Code |Meaning|Description|Data Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Successful operation.|[`Scanner[]`](#scanner)| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Bad request, e.g. parameter is invalid.|[`Error`](#error)| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Method not allowed.|[`Error`](#error)| #### Response Examples 200 Response: ```json [ { "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\"}" } ] ``` 400 Response: ```json { "code": -2113, "message": "The parameter is not valid.", "statusCode": 400 } ``` 405 Response: ```json { "code": -2112, "message": "This endpoint only supports GET.", "statusCode": 405 } ``` ### `POST /device/scanners/jobs` Create a scan job. You can scan with a specified scanner, or use the latest scanner by default. This API provides an extensive set of parameters to: - Set scanner capabilities - Show the scanner UI when the client is on the same machine that the Dynamic Web TWAIN Service is running on. - Get the scanned image with the `jobuid` once the scan job completes, or save to a specified document - Create a pending job with the specified scanner. (every scanner can only have one pending job) We recommend creating pending jobs for **shared scanners**. By default, requests for the job are bound to the domain of the client that created the scan job. The `config`, `settings`, and `capability` all provide **different ways** to specify the **same scan settings** for the scan job. These settings override each other in predicable ways as outlined in [`CreateScanJobOptions`](#createscanjoboptions), but we recommend only using **one of the three parameters** for clarity, whichever is most convenient to you. After creating a scan job, the job either: 1. completes successfully, 2. hangs indefinitely, 3. times out once it hits the `jobTimeout` value **if set**, 4. or gets deleted if you send a [delete request](#delete-devicescannersjobsjobuid). #### Parameters | Name | Location | Type | Required | Description | | ----------------------- | -------- | -------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `DWT-PRODUCT-KEY` | header | `string` | yes | DWT license key with the RESTful API module - contact our [sales team](https://www.dynamsoft.com/company/contact/) for a full license, or get a [30-day free trial](https://www.dynamsoft.com/web-twain/downloads/). | |`CreateScanJobOptions`|body|[`CreateScanJobOptions`](#createscanjoboptions)| no |none| #### Request Example Start a scan job as pending and check the feeder. The `device` and `settings` values were obtained from earlier `/device/scanners/twain/settings` and `/device/scanners` calls. Various scanning configurations are set with the `config` parameter: ```js const url = new URL("https://127.0.0.1:18623/api"); const pathSegments = ['device', 'scanners', 'jobs']; url.pathname = `${url.pathname}/${pathSegments.join('/')}`; let myHeaders = new Headers(); myHeaders.append("DWT-PRODUCT-KEY", "YOUR_LICENSE_KEY_HERE"); myHeaders.append("Content-Type", "application/json"); let raw = JSON.stringify({ "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==" }); let requestOptions = { method: 'POST', headers: myHeaders, body: raw, redirect: 'follow' }; fetch(url, requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` #### Responses |HTTP Status Code |Meaning|Description|Data Schema| |---|---|---|---| |201|[Created](https://tools.ietf.org/html/rfc7231#section-6.3.2)|Successful operation.|[`ScannerJob`](#scannerjob)| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Bad request, e.g. parameter is invalid.|[`Error`](#error)| |403|[Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3)|License is invalid.|[`Error`](#error)| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Method not allowed.|[`Error`](#error)| |423|[Locked](https://tools.ietf.org/html/rfc2518#section-10.4)|Source is connected to maximum supported number of applications.|[`Error`](#error)| #### Response Examples 201 Response: ```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\"}" } } ``` 400 Response: ```json { "code": -2113, "message": "The parameter is not valid.", "statusCode": 400 } ``` 403 Response: ```json { "code": -2800, "message": "The current product key is empty or invalid. Please contact the site administrator.", "statusCode": 403 } ``` 405 Response: ```json { "code": -2112, "message": "This endpoint only supports POST.", "statusCode": 405 } ``` 423 Response: ```json { "code": -1004, "message": "Source is connected to maximum supported number of applications.", "statusCode": 423 } ``` ### `GET /device/scanners/jobs/{jobuid}` Get the status of a scan job provided its `jobuid`. Obtain the `jobuid` from the response of the [`POST /device/scanners/jobs`](#post-devicescannersjobs) scan job creation request. #### Parameters |Name|Location|Type|Required|Restrictions|Description| |---|---|---|---|---|---| |`jobuid`|path|`string`| yes | none |Unique identifier for the scan job, obtained from the [`POST /device/scanners/jobs`](#post-devicescannersjobs) scan job creation request. | #### Request Example Request the status of a previously-requested scan job: ```js const url = new URL("https://127.0.0.1:18623/api"); const jobuid = `B3701DC5-86D3-44B6-A8A1-FF0B5D43FD86`; const pathSegments = ['device', 'scanners', 'jobs', jobuid]; url.pathname = `${url.pathname}/${pathSegments.join('/')}`; let myHeaders = new Headers(); myHeaders.append("Content-Type", "application/json"); let requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch(url, requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` #### Responses |HTTP Status Code |Meaning|Description|Data Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Successful operation.|[`ScannerJobInfo`](#scannerjobinfo)| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|The provided job UID is invalid.|[`Error`](#error)| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Method not allowed.|[`Error`](#error)| |410|[Gone](https://tools.ietf.org/html/rfc7231#section-6.5.9)|Job was deleted. Return 404 instead upon restart of the Dynamic Web TWAIN Service as that clears all job info.|[`Error`](#error)| #### Response Examples > 200 Response ```json { "status": "pending", "code": "0", "message": "Successful" } ``` > 404 Response ```json { "code": -1034, "message": "The provided job UID is invalid.", "statusCode": 404 } ``` > 405 Response ```json { "code": -2112, "message": "This endpoint only supports GET, PATCH, DELETE.", "statusCode": 405 } ``` > 410 Response ```json { "code": -1034, "message": "Job was deleted.", "statusCode": 410 } ``` ### `PATCH /device/scanners/jobs/{jobuid}` Update status of a scan job given its `jobuid`. Update the status of the job while the job is in the `pending` state. This request is ignored if the job is in any other state. Obtain the `jobuid` from the response of the [`POST /device/scanners/jobs`](#post-devicescannersjobs) scan job creation request. #### Parameters |Name|Location|Type|Required|Restrictions|Description| |---|---|---|---|---|---| |`jobuid`|path|`string`| yes | none |Unique identifier for the scan job, obtained from the [`POST /device/scanners/jobs`](#post-devicescannersjobs) scan job creation request. | |`status`|body|`string`| yes | - `running`: running
- `canceled`: canceled |Default value `running` - update the job status. When the job is running, the only acceptable value is `canceled` to cancel the job. When the job is pending, the only acceptable value is `running` to start the job.| #### Request Example Start a pending job: ```js const url = new URL("https://127.0.0.1:18623/api"); const jobuid = `B3701DC5-86D3-44B6-A8A1-FF0B5D43FD86`; const pathSegments = ['device', 'scanners', 'jobs', jobuid]; url.pathname = `${url.pathname}/${pathSegments.join('/')}`; let myHeaders = new Headers(); myHeaders.append("Content-Type", "application/json"); let raw = JSON.stringify({ status: 'running' }) let requestOptions = { method: 'PATCH', headers: myHeaders, body: raw, redirect: 'follow' }; fetch(url, requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` #### Responses |HTTP Status Code |Meaning|Description|Data Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Successful operation.|[`ScannerJobStatus`](#scannerjobstatus)| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Bad request, e.g. parameter is invalid.|[`Error`](#error)| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|The provided job UID is invalid.|[`Error`](#error)| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Method not allowed.|[`Error`](#error)| |409|[Conflict](https://tools.ietf.org/html/rfc7231#section-6.5.8)|Attempted to cancel non-pending or non-running job, or update a non-pending job to running.|[`Error`](#error)| |410|[Gone](https://tools.ietf.org/html/rfc7231#section-6.5.9)|Job was deleted. Return 404 instead upon restart of the Dynamic Web TWAIN Service as that clears all job info.|[`Error`](#error)| #### Response Examples > 200 Response ```json { "status": "running" } ``` > 400 Response ```json { "code": -2113, "message": "The parameter is not valid.", "statusCode": 400 } ``` > 404 Response ```json { "code": -1034, "message": "The provided job UID is invalid.", "statusCode": 404 } ``` > 405 Response ```json { "code": -2112, "message": "This endpoint only supports GET, PATCH, DELETE.", "statusCode": 405 } ``` > 409 Response ```json { "code": -1011, "message": "Cannot cancel non-pending or non-running job, or update a non-pending job to running.", "statusCode": 409 } ``` > 410 Response ```json { "code": -1034, "message": "Job was deleted.", "statusCode": 410 } ``` ### `DELETE /device/scanners/jobs/{jobuid}` Delete a scan job, provided its `jobuid`. if the job is running, cancel then delete the scan job, including all scanned documents. Obtain the `jobuid` from the response of the [`POST /device/scanners/jobs`](#post-devicescannersjobs) scan job creation request. #### Parameters |Name|Location|Type|Required|Restrictions|Description| |---|---|---|---|---|---| |`jobuid`|path|`string`| yes | none |Unique identifier for the scan job, obtained from the [`POST /device/scanners/jobs`](#post-devicescannersjobs) scan job creation request. | #### Request Example Only valid request syntax (to cancel a scan job): ```js const url = new URL("https://127.0.0.1:18623/api"); const jobuid = `B3701DC5-86D3-44B6-A8A1-FF0B5D43FD86`; const pathSegments = ['device', 'scanners', 'jobs', jobuid]; url.pathname = `${url.pathname}/${pathSegments.join('/')}`; let requestOptions = { method: 'DELETE', redirect: 'follow' }; fetch(url, requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` #### Responses |HTTP Status Code |Meaning|Description|Data Schema| |---|---|---|---| |204|[No Content](https://tools.ietf.org/html/rfc7231#section-6.3.5)|Successful operation.|None| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|The provided job UID is invalid.|[`Error`](#error)| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Method not allowed.|[`Error`](#error)| |410|[Gone](https://tools.ietf.org/html/rfc7231#section-6.5.9)|Job already deleted.|[`Error`](#error)| #### Response Examples > 404 Response ```json { "code": -1034, "message": "The provided job UID is invalid.", "statusCode": 404 } ``` > 405 Response ```json { "code": -2112, "message": "This endpoint only supports GET, PATCH, DELETE.", "statusCode": 405 } ``` > 410 Response ```json { "code": -1034, "message": "Job already deleted.", "statusCode": 410 } ``` ### `GET /device/scanners/jobs/{jobuid}/scanner/capabilities` Retrieve the capabilities of the scanner specified in the scan job, provided its `jobuid`. This API can only be called when the job is in a `pending` state, hence you must [create the job](#post-devicescannersjobs) with `autoRun` set to `false` for a valid response. By default this API returns all capabilities, but you can select specific capabilities with comma separated values using `caps`. See the [capability enumerations](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_cap) for more information. Obtain the `jobuid` from the response of the [`POST /device/scanners/jobs`](#post-devicescannersjobs) scan job creation request. #### Parameters |Name|Location|Type|Required|Restrictions|Description| |---|---|---|---|---|---| |`jobuid`|path|`string`| yes | none |Unique identifier for the scan job, obtained from the [`POST /device/scanners/jobs`](#post-devicescannersjobs) scan job creation request. | |`caps`|query|`string`| no | See list of all capabilities [here](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_cap). | Comma-separated list of enumerated capabilities to request - leave empty to request all capabilities. | #### Request Example Query duplex scanning (value `4114`) and auto-feed (value `4103`) capabilities of the specified job: ```js const url = new URL("https://127.0.0.1:18623/api"); const jobuid = `B3701DC5-86D3-44B6-A8A1-FF0B5D43FD86`; const pathSegments = ['device', 'scanners', 'jobs', jobuid, 'scanner', 'capabilities']; url.pathname = `${url.pathname}/${pathSegments.join('/')}`; url.searchParams.append('caps', '4114,4103'); let requestOptions = { method: 'GET', redirect: 'follow' }; fetch(url, requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` #### Responses |HTTP Status Code |Meaning|Description|Data Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Successful operation.|[`CapabilityDetails`](/_articles/info/api/interfaces.md#capabilitydetails)| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Bad request, e.g. parameter is invalid.|[`Error`](#error)| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|The provided job UID is invalid.|[`Error`](#error)| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Method not allowed.|[`Error`](#error)| |409|[Conflict](https://tools.ietf.org/html/rfc7231#section-6.5.8)|Cannot be called when job is not pending.|[`Error`](#error)| |410|[Gone](https://tools.ietf.org/html/rfc7231#section-6.5.9)|Job was deleted. Return 404 instead upon restart of the Dynamic Web TWAIN Service as that clears all job info.|[`Error`](#error)| #### Response Examples > 200 Response ```json [ {} ] ``` > 400 Response ```json { "code": -2113, "message": "The parameter is not valid.", "statusCode": 400 } ``` > 404 Response ```json { "code": -1034, "message": "The provided job UID is invalid.", "statusCode": 404 } ``` > 405 Response ```json { "code": -2112, "message": "This endpoint only supports GET.", "statusCode": 405 } ``` > 409 Response ```json { "code": -1011, "message": "Cannot be called when job is not pending.", "statusCode": 409 } ``` > 410 Response ```json { "code": -1034, "message": "Job was deleted.", "statusCode": 410 } ``` ### `GET /device/scanners/jobs/{jobuid}/scanner/settings` Retrieve the `settings` of the scanner specified in the scan job, provided the `jobuid`. This request only supports TWAIN scanners, and is only valid when the job is pending. This API relies on `EnableSourceUI` to show the scanner UI if enabled by the `showui` parameter. Obtain the `jobuid` from the response of the [`POST /device/scanners/jobs`](#post-devicescannersjobs) scan job creation request. #### Parameters |Name|Location|Type|Required|Restrictions|Description| |---|---|---|---|---|---| |`jobuid`|path|`string`| yes | none |Unique identifier for the scan job, obtained from the [`POST /device/scanners/jobs`](#post-devicescannersjobs) scan job creation request. | |`showui`|query|`boolean`| no | none |Default value `true` - shows the scanner UI.| #### Request Example Get the `settings` of the scanner performing a scan job and show the UI ```js const url = new URL("https://127.0.0.1:18623/api"); const jobuid = `B3701DC5-86D3-44B6-A8A1-FF0B5D43FD86`; const pathSegments = ['device', 'scanners', 'jobs', jobuid, 'scanner', 'settings']; url.pathname = `${url.pathname}/${pathSegments.join('/')}`; const params = new URLSearchParams(); params.append(`showui`, 'true'); let requestOptions = { method: 'GET', redirect: 'follow' }; fetch(url, requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` #### Responses |HTTP Status Code |Meaning|Description|Data Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Successful operation.|base64 encoded string| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Bad request, e.g. parameter is invalid.|[`Error`](#error)| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|The provided job UID is invalid.|[`Error`](#error)| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Method not allowed.|[`Error`](#error)| |409|[Conflict](https://tools.ietf.org/html/rfc7231#section-6.5.8)|The job is not pending.|[`Error`](#error)| |410|[Gone](https://tools.ietf.org/html/rfc7231#section-6.5.9)|The job was deleted.|[`Error`](#error)| #### Response Examples > 200 Response ```json { "settings": "Rfj6pIMTNkCu3BfDloGItBAAAAACEAAABgAFAAEAAAAQAAAAExAAAAYABQAAAAAAEAAAAAcQAAAGAAUAAQAAABAAAAArEQAABAAFABgAAAAQAAAAHBEAAAQABQAAAAAAEAAAAAABAAAEAAUAAAAAABwAAAAUEQAACAAFAPgqAAAAAAAANCEAAAAAAAAQAAAADBEAAAQABQACAAAAEAAAAB8RAAAEAAUAAAAAABAAAAABAQAABAAFAAIAAAAQAAAAIBEAAAQABQAAAAAAEAAAACIRAAAEAAUAAwAAABAAAAAQEQAABAAFAAAAAAAQAAAAAgEAAAQABQAAAAAAEAAAABgRAAAHAAUAAABIQxAAAAAZEQAABwAFAAAASEMQAAAAIxEAAAcABQAAAABDEAAAAAMRAAAHAAUAAAAAABAAAAABEQAABwAFAAAAAAAQAAAACBEAAAcABQAAAIA/EAAAAAGAAAAGAAUAAAAAAA==" } ``` > 400 Response ```json { "code": -2113, "message": "The parameter is not valid.", "statusCode": 400 } ``` > 404 Response ```json { "code": -1034, "message": "The provided job UID is invalid.", "statusCode": 404 } ``` > 405 Response ```json { "code": -2112, "message": "This endpoint only supports GET.", "statusCode": 405 } ``` > 409 Response ```json { "code": -1011, "message": "The job is not pending.", "statusCode": 409 } ``` > 410 Response ```json { "code": -1034, "message": "Invalid Value.", "statusCode": 410 } ``` ### `GET /device/scanners/jobs/{jobuid}/next-page-info` Get information of the next page in a scan job, provided its `jobuid`. This will not return until the scanned page is ready. If the response code is `200`, you can keep calling this API until a code `204` response. Obtain the `jobuid` from the response of the [`POST /device/scanners/jobs`](#post-devicescannersjobs) scan job creation request. #### Parameters |Name|Location|Type|Required|Restrictions|Description| |---|---|---|---|---|---| |`jobuid`|path|`string`| yes |none |Unique identifier for the scan job, obtained from the [`POST /device/scanners/jobs`](#post-devicescannersjobs) scan job creation request. | #### Request Example ```js 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)); ``` #### Responses |HTTP Status Code |Meaning|Description|Data Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|successful operation. Also returns the image url; if scanning to a document, also return document UID and page UID.|[`OutputInfo`](/_articles/info/api/interfaces.md#outputinfo)| |204|[No Content](https://tools.ietf.org/html/rfc7231#section-6.3.5)|No more pages, scan done.|None| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|The provided job UID is invalid.|[`Error`](#error)| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Method not allowed.|[`Error`](#error)| |410|[Gone](https://tools.ietf.org/html/rfc7231#section-6.5.9)|Job was deleted. Return 404 instead upon restart of the Dynamic Web TWAIN Service as that clears all job info.|Inline| #### Response Examples > 200 Response ```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" } ] ``` > 404 Response ```json { "code": -1034, "message": "The provided job UID is invalid.", "statusCode": 404 } ``` > 405 Response ```json { "code": -2112, "message": "This endpoint only supports GET.", "statusCode": 405 } ``` > 410 Response ```json { "code": -1034, "message": "Job was deleted.", "statusCode": 410 } ``` ### `GET /device/scanners/jobs/{jobuid}/content` Get the scanned image content by page index from a scan job, provided its `jobuid`. Use the `type` parameter to set the format of the image as either `image/jpeg` or `image/png`, and `page` (0-based index) to specify which page to retrieve. Obtain the `jobuid` from the response of the [`POST /device/scanners/jobs`](#post-devicescannersjobs) scan job creation request. #### Parameters |Name|Location|Type|Required|Restrictions|Description| |---|---|---|---|---|---| |`jobuid`|path|`string`| yes | none |Unique identifier for the scan job, obtained from the [`POST /device/scanners/jobs`](#post-devicescannersjobs) scan job creation request. | |`type`|query|`string`| yes | - `image/png`: PNG
- `image/jpeg`: JPEG |The image format of the page, either `image/png` or `image/jpeg`.| |`page`|query|`number`| yes | 0-based page index |The index of the page to retrieve, starting from 0.| #### Request Example Get page index 0 from a scan job as a `jpeg`: ```js const url = new URL("https://127.0.0.1:18623/api"); const jobuid = `B3701DC5-86D3-44B6-A8A1-FF0B5D43FD86`; const pathSegments = ['device', 'scanners', 'jobs', jobuid, 'content']; url.pathname = `${url.pathname}/${pathSegments.join('/')}`; const params = new URLSearchParams(); params.append(`type`, 'image/jpeg'); params.append(`page`, '0'); 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)); ``` #### Responses |HTTP Status Code |Meaning|Description|Data Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Successful operation. Return `image/png` or `image/jpeg` stream.|binary data stream| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Bad request, e.g. parameter is invalid.|[`Error`](#error)| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|The provided job UID is invalid.|[`Error`](#error)| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Method not allowed.|[`Error`](#error)| |409|[Conflict](https://tools.ietf.org/html/rfc7231#section-6.5.8)|The job is in pending.|[`Error`](#error)| |410|[Gone](https://tools.ietf.org/html/rfc7231#section-6.5.9)|Job was deleted. Return 404 instead upon restart of the Dynamic Web TWAIN Service as that clears all job info.|[`Error`](#error)| #### Response Examples > 200 Response > 400 Response ```json { "code": -2113, "message": "The parameter is not valid.", "statusCode": 400 } ``` > 404 Response ```json { "code": -1034, "message": "The provided job UID is invalid.", "statusCode": 404 } ``` > 405 Response ```json { "code": -2112, "message": "This endpoint only supports GET.", "statusCode": 405 } ``` > 409 Response ```json { "code": -1011, "message": "Operation out of expected sequence.", "statusCode": 409 } ``` > 410 Response ```json { "code": -1034, "message": "Invalid value.", "statusCode": 410 } ``` ### `GET /device/scanners/jobs/{jobuid}/next-page` Get the page in a scan job, provided its `jobuid`. Use the `type` parameter to set the format of the image as either `jpeg` or `png`. This API will not return until the scanned page is ready. If the response code is `200`, you can keep calling this API until a code `204` response. Obtain the `jobuid` from the response of the [`POST /device/scanners/jobs`](#post-devicescannersjobs) scan job creation request. #### Parameters |Name|Location|Type|Required|Restrictions|Description| |---|---|---|---|---|---| |`jobuid`|path|`string`| yes | none |Unique identifier for the scan job, obtained from the [`POST /device/scanners/jobs`](#post-devicescannersjobs) scan job creation request. | |`type`|query|`string`| no | - `image/png`: PNG
- `image/jpeg`: JPEG |Default value `image/png` - the image format of the page, either `image/png` or `image/jpeg`.| #### Request Example Get the next page from a scan job as a `png`: ```js 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)); ``` #### Responses |HTTP Status Code |Meaning|Description|Data Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Successful operation. Return `image/png` or `image/jpeg` stream.|binary data stream| |204|[No Content](https://tools.ietf.org/html/rfc7231#section-6.3.5)|No more pages, scan done.|None| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Bad request, e.g. parameter is invalid.|[`Error`](#error)| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|The provided job UID is invalid.|[`Error`](#error)| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Method not allowed.|[`Error`](#error)| |410|[Gone](https://tools.ietf.org/html/rfc7231#section-6.5.9)|Job was deleted. Return 404 instead upon restart of the Dynamic Web TWAIN Service as that clears all job info.|[`Error`](#error)| #### Response Examples > 200 Response > 400 Response ```json { "code": -2113, "message": "The parameter is not valid.", "statusCode": 400 } ``` > 404 Response ```json { "code": -1034, "message": "The provided job UID is invalid.", "statusCode": 404 } ``` > 405 Response ```json { "code": -2112, "message": "This endpoint only supports GET.", "statusCode": 405 } ``` > 410 Response ```json { "code": -1034, "message": "Job was deleted.", "statusCode": 410 } ``` ## Document Management ### `POST /storage/documents` Create a new document for storage. The document is stored in the Dynamic Web TWAIN Service working directory, and all content is optionally encrypted with the supplied `password` string. The request returns a document `uid` upon successfully creating the document. #### Parameters |Name|Location|Type|Required|Restrictions|Description| |---|---|---|---|---|---| |`CreateDocumentOptions`|body|[`CreateDocumentOptions`](#createdocumentoptions)| no | none || #### Responses |HTTP Status Code |Meaning|Description|Data Schema| |---|---|---|---| |201|[Created](https://tools.ietf.org/html/rfc7231#section-6.3.2)|Successful operation.|[`DocumentInfo`](#documentinfo)| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Bad request, e.g. parameter is invalid.|[`Error`](#error)| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Method not allowed.|[`Error`](#error)| #### Request Example Create a new document with a password: ```js const url = new URL("https://127.0.0.1:18623/api"); const pathSegments = ['storage', 'documents']; url.pathname = `${url.pathname}/${pathSegments.join('/')}`; let myHeaders = new Headers(); myHeaders.append("Content-Type", "application/json"); let raw = JSON.stringify({ password: 'myPassword' }); let requestOptions = { method: 'POST', headers: myHeaders, body: raw, redirect: 'follow' }; fetch(url, requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` #### Response Examples > 201 Response ```json { "uid": "190807444d76", "pages": [] } ``` > 400 Response ```json { "code": -2113, "message": "The parameter is not valid.", "statusCode": 400 } ``` > 405 Response ```json { "code": -2112, "message": "This endpoint only supports POST.", "statusCode": 405 } ``` ### `GET /storage/documents/{documentuid}` Get info of a document stored in the working directory of the Dynamic Web TWAIN Service, provided the `documentuid`. This information consists of the `documentuid` and an array of page `uid`. If the document is password-encrypted, this request must provide the password for access. Obtain the `document` from the response of the [`POST storage/documents`](#post-storagedocuments) document creation request. #### Parameters |Name|Location|Type|Required|Restrictions|Description| |---|---|---|---|---|---| |`documentuid`|path|`string`| yes | none |The UID of the document.| |`DWT-DOC-PASSWORD`|header|`string`| no | length <= 32 characters |The password of the document (32 characters max).| #### Request Example Get document information for an encrypted document: ```js const url = new URL("https://127.0.0.1:18623/api"); const documentuid = `190807444d76`; const pathSegments = ['storage', 'documents', documentuid]; url.pathname = `${url.pathname}/${pathSegments.join('/')}`; let myHeaders = new Headers(); myHeaders.append("DWT-DOC-PASSWORD", "myPassword"); let requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch(url, requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` #### Responses |HTTP Status Code |Meaning|Description|Data Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Successful operation|[`DocumentInfo`](#documentinfo)| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Bad request, e.g. parameter is invalid.|[`Error`](#error)| |403|[Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3)|none|[`Error`](#error)| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|The provided document UID is invalid.|[`Error`](#error)| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Method not allowed.|[`Error`](#error)| #### Response Examples > 200 Response ```json { "uid": "190807444d76", "pages": [ { "uid": "190817548d70" }, { "uid": "190817648270" } ] } ``` > 400 Response ```json { "code": -2113, "message": "The parameter is not valid.", "statusCode": 400 } ``` > 403 Response ```json { "code": -1043, "message": "The password is not valid.", "statusCode": 403 } ``` > 404 Response ```json { "code": -1040, "message": "The provided UID is invalid.", "statusCode": 404 } ``` > 405 Response ```json { "code": -2112, "message": "This endpoint only supports GET, PATCH, DELETE.", "statusCode": 405 } ``` ### `PATCH /storage/documents/{documentuid}` Update the `customData` of a stored document. Update the metadata of a document stored in the working directory of the Dynamic Web TWAIN Service. The new metadata will completely overwrite the existing one. Only one copy of customData is stored at any time. If the document is password-encrypted, this request must provide the password for access. Obtain the `documentuid` from the response of the [`POST storage/documents`](#post-storagedocuments) document creation request. #### Parameters |Name|Location|Type|Required|Restrictions|Description| |---|---|---|---|---|---| |`documentuid`|path|`string`| yes |none|The UID of the document.| |`DWT-DOC-PASSWORD`|header|`string`| no |length <= 32 characters|The password of the document (32 characters max).| |`metadata`|body|`string` or `object`| yes |none|Custom data to update, will fully overwrite existing data.| #### Request Example Update the customData of a document: ```js const url = new URL("https://127.0.0.1:18623/api"); const documentuid = `190807444d76`; const pathSegments = ['storage', 'documents', documentuid]; url.pathname = `${url.pathname}/${pathSegments.join('/')}`; let myHeaders = new Headers(); myHeaders.append("Content-Type", "application/json"); let raw = JSON.stringify({ metadata: { fileName: 'test.pdf', uploadTime: '2025-01-01' } }); let requestOptions = { method: 'PATCH', headers: myHeaders, body: raw, redirect: 'follow' }; fetch(url, requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` #### Responses |HTTP Status Code |Meaning|Description|Data Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Successful operation.|[`DocumentInfo`](#documentinfo)| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Bad request, e.g. parameter is invalid.|[`Error`](#error)| |403|[Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3)|The password is not valid.|[`Error`](#error)| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|The provided document UID is invalid.|[`Error`](#error)| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Method not allowed.|[`Error`](#error)| #### Response Examples > 200 Response ```json { "uid": "190807444d76", "metadata": { "fileName": "test.pdf", "uploadTime": "2025-01-01" }, "pages": [ { "uid": "190817548d70" }, { "uid": "190817648270" } ] } ``` > 400 Response ```json { "code": -2113, "message": "The parameter is not valid.", "statusCode": 400 } ``` > 403 Response ```json { "code": -1043, "message": "The password is not valid.", "statusCode": 403 } ``` > 404 Response ```json { "code": -1040, "message": "The provided document UID is invalid.", "statusCode": 404 } ``` > 405 Response ```json { "code": -2112, "message": "This endpoint only supports GET, PATCH, DELETE.", "statusCode": 405 } ``` ### `DELETE /storage/documents/{documentuid}` Delete a stored document. Delete a document stored in the working directory of the Dynamic Web TWAIN Service. If the document is password-encrypted, this request must provide the password for access. Obtain the `document` from the response of the [`POST storage/documents`](#post-storagedocuments) document creation request. #### Parameters |Name|Location|Type|Required|Restrictions|Description| |---|---|---|---|---|---| |`documentuid`|path|`string`| yes |none|The UID of the document.| |`DWT-DOC-PASSWORD`|header|`string`| no |length <= 32 characters|The password of the document (32 characters max).| #### Request Example Delete an encrypted document: ```js const url = new URL("https://127.0.0.1:18623/api"); const documentuid = `190807444d76`; const pathSegments = ['storage', 'documents', documentuid]; url.pathname = `${url.pathname}/${pathSegments.join('/')}`; let myHeaders = new Headers(); myHeaders.append("DWT-DOC-PASSWORD", "myPassword"); let requestOptions = { method: 'DELETE', headers: myHeaders, redirect: 'follow' }; fetch(url, requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` #### Responses |HTTP Status Code |Meaning|Description|Data Schema| |---|---|---|---| |204|[No Content](https://tools.ietf.org/html/rfc7231#section-6.3.5)|Successful operation.|None| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Bad request, e.g. parameter is invalid.|[`Error`](#error)| |403|[Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3)|The password is not valid.|[`Error`](#error)| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|The provided document UID is invalid.|[`Error`](#error)| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Method not allowed.|[`Error`](#error)| #### Response Examples > 400 Response ```json { "code": -2113, "message": "The parameter is not valid.", "statusCode": 400 } ``` > 403 Response ```json { "code": -1043, "message": "The password is not valid.", "statusCode": 403 } ``` > 404 Response ```json { "code": -1040, "message": "The provided document UID is invalid.", "statusCode": 404 } ``` > 405 Response ```json { "code": -2112, "message": "This endpoint only supports GET, PATCH, DELETE.", "statusCode": 405 } ``` ### `GET /storage/documents/{documentuid}/content` Get pages of a stored document, provided its `documentuid`. Get pages of a document stored in the working directory of the Dynamic Web TWAIN Service. By default this API retrieves the pages as a single `PDF`, but can also provide a multi-page `TIFF` file, or retrieve pages separately as`JPEG` or `PNG` files. This API can select multiple pages by page `uid` or page index. If no pages are specified and the format is either `PDF` or `TIFF`, it retrieves all pages in the document as one file. The API can also specify file attributes such as file encryption password and compression level, as well as file metadata such as creation date, author name, and key words. If the document is password-encrypted, this request must provide the password for access. Obtain the `document` from the response of the [`POST storage/documents`](#post-storagedocuments) document creation request. #### Parameters |Name|Location|Type|Required|Restrictions|Description| |---|---|---|---|---|---| |`documentuid`|path|`string`| yes |none|The UID of the document.| |`type`|query|`string`| no | - `image/jpeg`: JPEG
- `image/png`: PNG
- `image/tiff`: TIFF
- `application/pdf`: PDF |Default value `application/pdf` - output mime type.| |`quality`|query|`integer(int32)`| no | - 0 <= `quality` <= 100 if `compression` is `6`
- Empty if `compression` is not `6` |Default value `80` - compression from 0 to 100, higher is more compression. This is only valid for the PDF `jpeg/jpeg2000` compression method.| |`pages`|query|`string`| no | - Comma-separated integers: page indices
- Comma-separated UIDs: page UIDs |Default value `''` - comma-separated page identifiers - either indices or `uid`, e.g. `pages=5,2,1` if using indices. If no pages are specified and the output `type` is either `image/png` or `image/jpeg`, only return the first page; if `type` is `image/tiff` or `application/pdf`, return all pages in the document.| |`author`|query|`string`| no | none |Default value `''` - author name.| |`compression`|query|`integer(int32)`| no | - `0`: `PDF_AUTO`
- `2`: `PDF_FAX4`
- `3`: `PDF_LZW`
- `5`: `PDF_JPEG`
- `6`: `PDF_JP2000`
- `7`: `PDF_JBIG2`
- `0`: `TIFF_AUTO`
- `1`: `TIFF_NONE`
- `2`: `TIFF_RLE`
- `3`: `TIFF_FAX3`
- `3`: `TIFF_T4`
- `4`: `TIFF_FAX4`
- `4`: `TIFF_T6`
- `5`: `TIFF_LZW`
- `7`: `TIFF_JPEG`
- `32773`: `TIFF_PACKBITS` |Default value `0` - compression type for `PDF` and `TIFF`. The default value `0` corresponds to auto-compression. See the enumerations for [`TIFF`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_tiffcompressiontype) and [`PDF`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_pdfcompressiontype) for valid compression methods.| |`pageType`|query|`integer(int32)`| no | - `0`: `Page_Default`
- `1`: `Page_Custom`
- `2`: `Page_A4`
- `3`: `Page_A4_Reverse`
- `4`: `Page_A3`
- `5`: `Page_A3_Reverse`
- `6`: `Page_Letter`
- `7`: `Page_Letter_Reverse`
- `8`: `Page_Legal`
- `9`: `Page_Legal_Reverse` |Default value `0` - standard dimensions for the page. See [`EnumDWT_CapSupportedSizes`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_capsupportedsizes) for more details.| |`creator`|query|`string`| no | none |Default value `''` - creator name.| |`creationDate`|query|`string`| no | none |Default value `''` - creation date.| |`keyWords`|query|`string`| no | none |Default value `''` - key words.| |`modifiedDate`|query|`string`| no | none |Default value `''` - modification date.| |`producer`|query|`string`| no | none |Default value `''` - producer name.| |`subject`|query|`string`| no | none |Default value `''` - subject.| |`title`|query|`string`| no | none |Default value `''` - title.| |`version`|query|`string`| no | none |Default value `1.5` - version.| |`password`|query|`string`| no | length <= 32 characters |Default value `''` - PDF file encryption password. The file is unencrypted by default. Note that this is distinct from the document password given by `DWT-DOC-PASSWORD`.| |`DWT-DOC-PASSWORD`|header|`string`| no | length <= 32 characters |The password of the document (32 characters max).| #### Request Example Get two pages (by page `uid`) of a password-protected document as a TIFF file. Set a file password and a compression level of 50%: ```js const url = new URL("https://127.0.0.1:18623/api"); const documentuid = `190807444d76`; const pathSegments = ['storage', 'documents', documentuid]; url.pathname = `${url.pathname}/${pathSegments.join('/')}`; url.searchParams.set('pages', '190817548d70,190817648270'); url.searchParams.set('password', 'myFilePassword'); url.searchParams.set('quality', '50'); let myHeaders = new Headers(); myHeaders.append("DWT-DOC-PASSWORD", "myPassword"); let requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; fetch(url, requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` #### Responses |HTTP Status Code |Meaning|Description|Data Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Successful operation.|binary data stream| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Bad request, e.g. parameter is invalid.|[`Error`](#error)| |403|[Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3)|The password is not valid.|[`Error`](#error)| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|The provided document UID is invalid.|[`Error`](#error)| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Method not allowed.|[`Error`](#error)| #### Response Examples > 200 Response > 400 Response ```json { "code": -2113, "message": "The parameter is not valid.", "statusCode": 400 } ``` > 403 Response ```json { "code": -1043, "message": "The password is not valid.", "statusCode": 403 } ``` > 404 Response ```json { "code": -1040, "message": "The provided document UID is invalid.", "statusCode": 404 } ``` > 405 Response ```json { "code": -2112, "message": "This endpoint only supports GET.", "statusCode": 405 } ``` ### `POST /storage/documents/{documentuid}/pages` Insert pages into a stored document, provided its `documentuid`. This API is used to insert scanned pages from a scan job to a document stored in the working directory of the Dynamic Web TWAIN Service. The API appends pages to the end of the document by default, though it can specify an insertion index. Obtain the `document` from the response of the [`POST storage/documents`](#post-storagedocuments) document creation request. #### Parameters |Name|Location|Type|Required|Restrictions|Description| |---|---|---|---|---|---| |`documentuid`|path|`string`| yes | none |The UID of the document.| |`DWT-DOC-PASSWORD`|header|`string`| no | length <= 32 characters |The password of the document (32 characters max).| |`insertPos`|body|`number`| no | `0` < `insertPos` <= document page count |The insertion index that the new pages will be inserted in front of, hence it must be a positive integer. If this is not set or is invalid, insert the pages at the end of the document.| |`source`|body|`string`| yes | Scan job URL |Image source URL from the scan job, e.g. `https://127.0.0.1:18623/api/device/scanners/jobs/dd40716d-48d1-4d32-89f7-1d53f9665d91/next-page?page=19522d0c5282`.| #### Request Example: Insert scanned pages from a scan job to the beginning of a stored document: ```js const url = new URL("https://127.0.0.1:18623/api"); const documentuid = `190807444d76`; const pathSegments = ['storage', 'documents', documentuid, 'pages']; url.pathname = `${url.pathname}/${pathSegments.join('/')}`; let myHeaders = new Headers(); myHeaders.append("DWT-DOC-PASSWORD", "myPassword"); let raw = JSON.stringify({ insertPos: 1, source: 'https://127.0.0.1:18623/api/device/scanners/jobs/dd40716d-48d1-4d32-89f7-1d53f9665d91/next-page?page=19522d0c5282', }); let requestOptions = { method: 'POST', headers: myHeaders, body: raw, redirect: 'follow' }; fetch(url, requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` #### Responses |HTTP Status Code |Meaning|Description|Data Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Page Inserted successfully.|[`DocumentInfo`](#documentinfo)| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Bad request, e.g. parameter is invalid.|[`Error`](#error)| |403|[Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3)|The password is not valid.|[`Error`](#error)| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|The provided document UID is invalid.|[`Error`](#error)| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Method not allowed.|[`Error`](#error)| #### Response Examples > 200 Response ```json { "uid": "190807444d76", "pages": [ { "uid": "190817548d70" }, { "uid": "190818458d85" } ] } ``` > 400 Response ```json { "code": -2113, "message": "The parameter is not valid.", "statusCode": 400 } ``` > 403 Response ```json { "code": -1043, "message": "The password is not valid.", "statusCode": 403 } ``` > 404 Response ```json { "code": -1040, "message": "The provided document UID is invalid.", "statusCode": 404 } ``` > 405 Response ```json { "code": -2112, "message": "This endpoint only supports POST.", "statusCode": 405 } ``` ### `DELETE /storage/documents/{documentuid}/pages/{param}` Delete a page in a stored document, provided its `documentuid` and page `uid`/index. #### Parameters |Name|Location|Type|Required|Restrictions|Description| |---|---|---|---|---|---| |`documentuid`|path|`string`| yes | none |The UID of the document.| |`param`|path|`string`| yes | - None-negative integer less than page count: page index
- valid page UID: page UID |UID of the page or 0-based page index.| |`DWT-DOC-PASSWORD`|header|`string`| no | length <= 32 characters |The password of the document (32 characters max).| #### Request Example: Delete the third page stored in a password-encrypted document: ```js const url = new URL("https://127.0.0.1:18623/api"); const documentuid = `190807444d76`; const param = '2'; const pathSegments = ['storage', 'documents', documentuid, 'pages', param]; url.pathname = `${url.pathname}/${pathSegments.join('/')}`; let myHeaders = new Headers(); myHeaders.append("DWT-DOC-PASSWORD", "myPassword"); let requestOptions = { method: 'DELETE', headers: myHeaders, redirect: 'follow' }; fetch(url, requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` #### Responses |HTTP Status Code |Meaning|Description|Data Schema| |---|---|---|---| |204|[No Content](https://tools.ietf.org/html/rfc7231#section-6.3.5)|Page removed successfully.|None| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Bad request, e.g. parameter is invalid.|[`Error`](#error)| |403|[Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3)|The password is not valid.|[`Error`](#error)| |404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|The provided page UID is invalid.|[`Error`](#error)| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Method not allowed|[`Error`](#error)| #### Response Examples > 400 Response ```json { "code": -2113, "message": "The parameter is not valid.", "statusCode": 400 } ``` > 403 Response ```json { "code": -1043, "message": "The password is not valid.", "statusCode": 403 } ``` > 404 Response ```json { "code": -1040, "message": "The provided page UID is invalid.", "statusCode": 404 } ``` > 405 Response ```json { "code": -2112, "message": "This endpoint only supports DELETE.", "statusCode": 405 } ``` ## Document Processing ### `POST /process/read-barcode` Create a new document process to read a barcode on a scanned page. Barcode scanning requires a valid Barcode Reader Add-On license. #### Parameters |Name|Location|Type|Required|Restrictions|Description| |---|---|---|---|---|---| |`DWT-PRODUCT-KEY`|header|`string`| yes | none |A DWT license key with the Barcode Reader and RESTful API module. Contact our [sales team](https://www.dynamsoft.com/company/contact/) for a full license, or get a [30-day free trial](https://www.dynamsoft.com/web-twain/downloads/).| |`source`|body|`string`| yes |Scan job URL |Image source URL from the scan job, e.g. `https://127.0.0.1:18623/api/device/scanners/jobs/dd40716d-48d1-4d32-89f7-1d53f9665d91/next-page?page=19522d0c5282`.| |`settings`|body|`string`| Valid barcode reading template JSON - see [`RuntimeSettings`](/_articles/info/api/interfaces.md#runtimesettings) for more details |no| Barcode reader template settings. Defaults to the `BestCoverage` setting by default. The basic settings are `BestCoverage`, `BestSpeed`, and `Balance`. Read the Barcode Reader Add-On guide for details on [basic settings](/_articles/extended-usage/barcode-processing.md#built-in-modes) and advanced [scanning templates](/_articles/extended-usage/barcode-processing.md#set-the-runtime-settings-using-json).| #### Request Example: Read a barcode on a page from a scan job with the "best speed" barcode reader setting: ```js const url = new URL("https://127.0.0.1:18623/api"); const pathSegments = ['process', 'read-barcode']; url.pathname = `${url.pathname}/${pathSegments.join('/')}`; let myHeaders = new Headers(); myHeaders.append("DWT-PRODUCT-KEY", "YOUR_LICENSE_KEY_HERE"); let raw = JSON.stringify({ settings: '{"ImageParameter":{"Name":"BestSpeed","BarcodeFormatIds_2":["BF2_POSTALCODE","BF2_DOTCODE"],"DeblurLevel":3,"ExpectedBarcodesCount":512,"LocalizationModes":[{"Mode":"LM_SCAN_DIRECTLY"}],"TextFilterModes":[{"MinImageDimension":262144,"Mode":"TFM_GENERAL_CONTOUR"}]}}', source: 'https://127.0.0.1:18623/api/device/scanners/jobs/dd40716d-48d1-4d32-89f7-1d53f9665d91/next-page?page=19522d0c5282', }); let requestOptions = { method: 'POST', headers: myHeaders, body: raw, redirect: 'follow' }; fetch(url, requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` #### Responses |HTTP Status Code |Meaning|Description|Data Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Successful operation.|[`BarcodeResult[]`](#barcoderesult)| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Bad request, e.g. parameter is invalid.|[`Error`](#error)| |403|[Forbidden](https://tools.ietf.org/html/rfc7231#section-6.5.3)|License is invalid.|[`Error`](#error)| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Method not allowed.|[`Error`](#error)| #### Response Examples > 200 Response ```json [ { "BarcodeFormat": 2, "BarcodeFormatString": "CODE_128", "LocalizationResult": { "ResultPoints": [ "723, 274", "1021, 275", "1021, 375", "723, 374" ], "accompanyingTextBytes": [], "angle": 0, "barcodeFormat": 3147775, "barcodeFormatString": "OneD", "barcodeFormatString_2": "No Barcode Format in group 2", "barcodeFormat_2": 0, "confidence": 100, "documentName": "{B683937D-B327-4488-A2C0-499760CB6BF0}", "moduleSize": 2, "pageNumber": 1, "regionName": "", "resultCoordinateType": 1, "terminatePhase": 32, "x1": 723, "x2": 1021, "x3": 1021, "x4": 723, "y1": 274, "y2": 275, "y3": 375, "y4": 374 }, "barcodeBytes": [ 67, 79, 68, 69, 49, 50, 56 ], "barcodeFormat": 2, "barcodeFormatString": "CODE_128", "barcodeFormatString_2": "No Barcode Format in group 2", "barcodeFormat_2": 0, "barcodeText": "CODE128", "detailedResult": { "checkDigitBytes": [], "moduleSize": 2, "startCharsBytes": [], "stopCharsBytes": [] }, "localizationResult": { "ResultPoints": [ "723, 274", "1021, 275", "1021, 375", "723, 374" ], "accompanyingTextBytes": [], "angle": 0, "barcodeFormat": 3147775, "barcodeFormatString": "OneD", "barcodeFormatString_2": "No Barcode Format in group 2", "barcodeFormat_2": 0, "confidence": 100, "documentName": "{B683937D-B327-4488-A2C0-499760CB6BF0}", "moduleSize": 2, "pageNumber": 1, "regionName": "", "resultCoordinateType": 1, "terminatePhase": 32, "x1": 723, "x2": 1021, "x3": 1021, "x4": 723, "y1": 274, "y2": 275, "y3": 375, "y4": 374 }, "results": [ { "accompanyingTextBytes": [], "barcodeFormat": 2, "barcodeFormatString": "CODE_128", "barcodeFormatString_2": "No Barcode Format in group 2", "barcodeFormat_2": 0, "bytes": [ 67, 79, 68, 69, 49, 50, 56 ], "clarity": -1, "confidence": 100, "deformation": 0, "resultType": 0 } ] } ] ``` > 400 Response ```json { "code": -2113, "message": "The parameter is not valid.", "statusCode": 400 } ``` > 403 Response ```json { "code": -2800, "message": "The current product key is empty or invalid. Please contact the site administrator.", "statusCode": 403 } ``` > 405 Response ```json { "code": -2112, "message": "This endpoint only supports POST.", "statusCode": 405 } ``` ### `POST /process/check-blank` Create a new document process to check if a scanned page is blank. #### Parameters |Name|Location|Type|Required|Restrictions|Description| |---|---|---|---|---|---| |`source`|body|`string`| yes |Scan job URL |Image source URL from the scan job, e.g. `https://127.0.0.1:18623/api/device/scanners/jobs/dd40716d-48d1-4d32-89f7-1d53f9665d91/next-page?page=19522d0c5282`.| |`settings`|body|[`CheckBlankSettings`](#checkblanksettings)| no |none |Maximum and minimum blemish pixel height detection thresholds.| #### Request Example: Check if a page from a scan job is blank: ```js const url = new URL("https://127.0.0.1:18623/api"); const pathSegments = ['process', `check-blank`]; url.pathname = `${url.pathname}/${pathSegments.join('/')}`; let myHeaders = new Headers(); myHeaders.append("Content-Type", "application/json"); let raw = JSON.stringify({ settings: { "minBlockHeight": 20, "maxBlockHeight": 30 }, source: 'https://127.0.0.1:18623/api/device/scanners/jobs/dd40716d-48d1-4d32-89f7-1d53f9665d91/next-page?page=19522d0c5282', }); let requestOptions = { method: 'POST', headers: myHeaders, body: raw, redirect: 'follow' }; fetch(url, requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); ``` #### Responses |HTTP Status Code |Meaning|Description|Data Schema| |---|---|---|---| |200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Successful operation.|[OperationResult](#operationresult)| |400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Bad request, e.g. parameter is invalid.|[`Error`](#error)| |405|[Method Not Allowed](https://tools.ietf.org/html/rfc7231#section-6.5.5)|Method not allowed.|[`Error`](#error)| #### Response Examples > 200 Response ```json { "result": true } ``` > 400 Response ```json { "code": -2113, "message": "The parameter is not valid.", "statusCode": 400 } ``` > 405 Response ```json { "code": -2112, "message": "This endpoint only supports POST.", "statusCode": 405 } ``` ## Data Schema ### `Error` ```json { "cause": { "code": 3, "message": "The system cannot find the path specified." }, "code": -2113, "message": "The parameter is not valid.", "statusCode": 400 } ``` #### Attributes |Name|Type|Required|Restrictions|Description| |---|---|---|---|---| |`statusCode`|`number`|true|HTTP status code|HTTP status code| |`code`|`number(int32)`|true|none|[Dynamic Web TWAIN Service status code](/_articles/info/api/appendix.md). `0` is the only successful code. All error codes are negative.| |`message`|`string`|true|none|none| |`cause`|`object`|false|none|If cause exists, shows the system error code and message.| |» `code`|`number(int32)`|false|none|System error code.| |» `message`|`string`|false|none|System error string of the code.| ### `ScannerType` ```json 16 ``` One or a combination of: - `0x10`: `TWAINSCANNER` - `0x20`: `WIASCANNER` - `0x40`: `TWAINX64SCANNER` - `0x80`: `ICASCANNER` - `0x100`: `SANESCANNER` - `0x200`: `ESCLSCANNER` - `0x400`: `WIFIDIRECTSCANNER` - `0x800`: `WIATWAINSCANNER` [External documentation](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_devicetype) #### Attributes |Name|Type|Required|Restrictions|Description| |---|---|---|---|---| |`type`|`integer(int32)`|false|none|One or a combination of:
- `0x10`: `TWAINSCANNER`
- `0x20`: `WIASCANNER`
- `0x40`: `TWAINX64SCANNER`
- `0x80`: `ICASCANNER`
- `0x100`: `SANESCANNER`
- `0x200`: `ESCLSCANNER`
- `0x400`: `WIFIDIRECTSCANNER`
- `0x800`: `WIATWAINSCANNER`| ### `Scanner` ```json { "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\"}" } ``` We also return websocket protocol info. but not list. #### Attributes |Name|Type|Required|Restrictions|Description| |---|---|---|---|---| |`name`|`string`|true|none|Scanner name| |`type`|[`ScannerType`](#scannertype)|true|none|one value of `ScannerType`| |`device`|`string`|true|none|A json string of the scanner details.| ### `CreateScanJobOptions` ```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==" } ``` #### Attributes |Name|Type|Required|Restrictions|Description| |---|---|---|---|---| | `autoRun`| body| `boolean` | no | Default value `true` - run the scan job immediately after creation. If false, the job gets created but does not run. Rather, the job status is set to pending, the scanner gets locked (no other RESTful client can use the scanner until this job completes or gets canceled), and the image source opens automatically if the scanner is a twain source. We recommend settings this to `false` to prevent other machines from capturing the scan job.| | `requestFocusForScanningUI`| body| `boolean` | no | Default value `true` - If true, the scanner UI will be brought to the top and get focus.| | `scannerFailureTimeout` | body | `integer(int32)` | no | Default value `15` - communication time-out with scanner for an operation (open source, set capability/settings, acquire image)in seconds, which resets upon successful completion of the operation. The operation fails if it exceeds the time-out without a response, e.g. trying to open a disconnected scanner, a paper jam, the user not interacting with an error dialog, etc. Therefore, we recommend setting a longer time-out if the user is not physically close to the scanner. | | `jobTimeout` | body | `integer(int32)` | no | Time-out for the scan job in seconds. Default value is `0` which never times out. If you create a pending job, the scanner automatically locks. You can release the scanner by deleting the job or allowing the job to time out. The timer begins once the pending job is created, and the timer stops once the job starts running. The timer resets (if set) when the job is done (completed, canceled or fault). | | `device` | body | `string` | no | JSON string of scanner info in `Device.device` returned by [`GET /device/scanners`](#get-devicescanners). | | `config` | body | `object` | no | Further scanner configurations, applied in the following order: `settings` -> `caps` -> `config`. | | `caps` | body | `object` | no | scanner capability setting | | `settings` | body | `string` | no | TWAIN-specific scanner settings, returned by `/device/scanners/twain/settings`. When both `caps` and `settings` exist, DWT applies `settings` first, then applies `caps` second. | | `checkFeederLoaded` | body | `boolean` | no | When `true`, detects if the feeder is loaded on TWAIN scanners with supported drivers. Default value `false`. May not be reliable for unsupported drivers. | ### `ScannerJob` ```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\"}" } } ``` #### Attributes |Name|Type|Required|Restrictions|Description| |---|---|---|---|---| |`jobuid`|`string`|true|none|none| |`status`|`string`|true|- `pending`: pending
- `running`: running
- `completed`: completed
- `faulted`: faulted
- `canceled`: canceled|If the job is completed, the status will be `completed`; If faulted, the status will be `faulted`, e.g. failed to open source, scanner was locked by others. Possible job status transitions:
1. `pending`->`running`->`completed`
2. `pending`->`running`->`faulted`
3. `pending`->`running`->`canceled`| |`scanner`|[`Scanner`](#scanner)|true|none|We also return websocket protocol info. but not list.| ### `ScannerJobInfo` ```json { "status": "pending", "code": "0", "message": "Successful" } ``` #### Attributes *Scanner Job Information* |Name|Type|Required|Restrictions|Description| |---|---|---|---|---| |`status`|`string`|true|- `pending`: pending
- `running`: running
- `completed`: completed
- `faulted`: faulted
- `canceled`: canceled|Scanner job status.| |`code`|`number`|true|none|error code| |`message`|`string`|true|none|error message| ### `PageInfo` ```json { "uid": "190817548d70" } ``` #### Attributes |Name|Type|Required|Restrictions|Description| |---|---|---|---|---| |`uid`|`string`|true|none|page uid| ### `DocumentInfo` ```json { "uid": "190807444d76", "metadata": { "fileName": "test.pdf", "uploadTime": "2025-01-01" }, "pages": [ { "uid": "190817548d70" } ] } ``` #### Attributes |Name|Type|Required|Restrictions|Description| |---|---|---|---|---| |`uid`|`string`|true|none|document uid| |`metadata`|`object`|false|none|custom data attached to the document| |`pages`|[[`PageInfo`](#pageinfo)]|true|none|pages info| ### `ServerSettingsInput` ```json { "logLevel": 1 } ``` some settings only admin can change. can only update any of them. #### Attributes |Name|Type|Required|Restrictions|Description| |---|---|---|---|---| |`logLevel`|`integer(int32)`|false|none|Log level of the DWT Service - `0` is disabled, `1` is debug + info + error, `30` is verbose.| ### `ServerSettings` ```json { "logLevel": 1 } ``` Currently, only return log level. #### Attributes |Name|Type|Required|Restrictions|Description| |---|---|---|---|---| |`logLevel`|`integer(int32)`|true|none|Log level of the DWT Service - `0` is disabled, `1` is debug + info + error, `30` is verbose.| ### `CreateDocumentOptions` ```json { "password": "" } ``` #### Attributes |Name|Type|Required|Restrictions|Description| |---|---|---|---|---| |`password`|`string`|false|none|length <= 32 characters |The password of the document (32 characters max).| ### `VersionInfo` ```json { "version": "20240719", "compatible": true, "moduleVersions": { "core": ["18.5.5.0416", "19.4.0.0410"] } } ``` #### Attributes |Name|Type|Required|Restrictions|Description| |---|---|---|---|---| |`version`|`string`|false|none|server api version.| |`compatible`|`boolean`|false|none|server is compatible with the client.| |`moduleVersions`|`object`|false|none|the versions of different modules of the server. Keys are module names, values are arrays of version strings.| ### `CheckBlankSettings` ```json "settings": { "minBlockHeight": 20, "maxBlockHeight": 30 } ``` #### Attributes |Name|Type|Required|Restrictions|Description| |---|---|---|---|---| |`minBlockHeight`|`number`|true|0 < `minBlockHeight` <= `maxBlockHeight`|Minimum blemish pixel height detection threshold.| |`maxBlockHeight`|`number`|true|`minBlockHeight` <= `maxBlockHeight`|Maximum blemish pixel height detection threshold.| ### `ScannerJobStatus` ```json { "status": "running" } ``` #### Attributes |Name|Type|Required|Restrictions|Description| |---|---|---|---|---| |`status`|`string`|true|none|scanner job status.| ### `OperationResult` ```json { "result": true } ``` #### Attributes |Name|Type|Required|Restrictions|Description| |---|---|---|---|---| |`result`|`boolean`|true|none|is blank image or not| ### `BarcodeResult` ```json { "BarcodeFormat": 2, "BarcodeFormatString": "CODE_128", "LocalizationResult": { "ResultPoints": [ "723, 274", "1021, 275", "1021, 375", "723, 374" ], "accompanyingTextBytes": [], "angle": 0, "barcodeFormat": 3147775, "barcodeFormatString": "OneD", "barcodeFormatString_2": "No Barcode Format in group 2", "barcodeFormat_2": 0, "confidence": 100, "documentName": "{B683937D-B327-4488-A2C0-499760CB6BF0}", "moduleSize": 2, "pageNumber": 1, "regionName": "", "resultCoordinateType": 1, "terminatePhase": 32, "x1": 723, "x2": 1021, "x3": 1021, "x4": 723, "y1": 274, "y2": 275, "y3": 375, "y4": 374 }, "barcodeBytes": [ 67, 79, 68, 69, 49, 50, 56 ], "barcodeFormat": 2, "barcodeFormatString": "CODE_128", "barcodeFormatString_2": "No Barcode Format in group 2", "barcodeFormat_2": 0, "barcodeText": "CODE128", "detailedResult": { "checkDigitBytes": [], "moduleSize": 2, "startCharsBytes": [], "stopCharsBytes": [] }, "localizationResult": { "ResultPoints": [ "723, 274", "1021, 275", "1021, 375", "723, 374" ], "accompanyingTextBytes": [], "angle": 0, "barcodeFormat": 3147775, "barcodeFormatString": "OneD", "barcodeFormatString_2": "No Barcode Format in group 2", "barcodeFormat_2": 0, "confidence": 100, "documentName": "{B683937D-B327-4488-A2C0-499760CB6BF0}", "moduleSize": 2, "pageNumber": 1, "regionName": "", "resultCoordinateType": 1, "terminatePhase": 32, "x1": 723, "x2": 1021, "x3": 1021, "x4": 723, "y1": 274, "y2": 275, "y3": 375, "y4": 374 }, "results": [ { "accompanyingTextBytes": [], "barcodeFormat": 2, "barcodeFormatString": "CODE_128", "barcodeFormatString_2": "No Barcode Format in group 2", "barcodeFormat_2": 0, "bytes": [ 67, 79, 68, 69, 49, 50, 56 ], "clarity": -1, "confidence": 100, "deformation": 0, "resultType": 0 } ] } ```
--- title: TOADD description: TOADD source_url: html: https://www.dynamsoft.com/web-twain/docs/info/governance.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/governance.md --- # Governance How we make sure the product is secure and such. --- title: Dynamic Web TWAIN SDK Schedule - Addon Release description: Dynamic Web TWAIN SDK Documentation Schedule - Addon Release Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/schedule/Addon.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/schedule/Addon.md --- # Dynamic Web TWAIN Core and Addon ## Recent Version Matches | Version | Service | Core | PDFR | Barcode | Camera/Webcam | OCRKit | OCRB | OCRPro | Uploader | |---------|---------|---------|---------|---------|---------|---------|---------|---------|---------| | v19.4| 1.9.4.0410 | 19.4.0.0410 | 12.0.4.0416 | 9.6.60.1202 | N/A /19.4.0.0410 | 11.0.0.1028 | N/A | N/A | 1.9.4.0410 | | v19.3| 1.9.3.1028 | 19.3.0.1028 | 12.0.1.1028 | 9.6.40.220 | N/A /19.2.0.0826 | 11.0.0.1028 | N/A | N/A | 1.9.0.0318 | | v19.2| 1.9.2.826 | 19.2.0.0826 | 12.0.1.0826 | 9.6.40.220 | N/A /19.2.0.0826 | N/A | N/A | N/A | 1.9.0.0318 | | v19.1| 1.9.1.428 | 19.1.0.0428 | 12.0.0.0318 | 9.6.40.220 | N/A /15.0.0.0625 | N/A | N/A | N/A | 1.9.0.0318 | | v19.0| 1.9.0.318 | 19.0.0.0318 | 12.0.0.0318 | 9.6.40.220 | N/A /15.0.0.0625 | N/A | N/A | N/A | 1.9.0.0318 | | v18.5.1| 1.8.5.828 | 18.5.1.0828 | 11.5.3.0828 | 9.6.40.220 | N/A /15.0.0.0625 | N/A | N/A | N/A | 1.8.5.0828 | | v18.5| 1.8.5.312 | 18.5.0.0312 | 11.5.2.0312 | 9.6.40.220 | N/A /15.0.0.0625 | N/A | N/A | N/A | 1.8.5.0312 | | v18.4.2| 1.8.4.1110 | 18.4.2.1110 | 11.5.1.0926 | 9.6.20.307 | N/A /15.0.0.0625 | N/A | N/A | N/A | 1.8.4.0926 | | v18.4.1| 1.8.4.1013 | 18.4.1.1013 | 11.5.1.0926 | 9.6.20.307 | N/A /15.0.0.0625 | N/A | N/A | N/A | 1.8.4.0926 | | v18.4| 1.8.4.0926 | 18.4.0.0926 | 11.5.1.0926 | 9.6.20.307 | N/A /15.0.0.0625 | N/A | N/A | N/A | 1.8.4.0926 | | v18.3| 1.8.3.627 | 18.3.0.0627 | 11.5.0.0627 | 9.6.20.307 | N/A /15.0.0.0625 | N/A | N/A | N/A | 1.8.3.627 | | v18.2| 1.8.2.0328 | 18.2.0.0328| 11.4.2.0328 | 9.6.0.0328 | N/A /15.0.0.0625 | N/A | N/A | N/A | 1.8.2.0328 | | v18.1 | 1.8.0.1025 | 18.1.0.0112 | 11.4.1.1025 | 9.4.0.1025 | N/A /15.0.0.0625 | N/A | N/A | N/A | 1.8.0.1025 | | v18.0 | 1.8.0.1025 | 18.0.0.1025 | 11.4.1.1025 | 9.4.0.1025 | 18.0.0.1025/15.0.0.0625 | N/A | N/A | N/A | 1.8.0.1025| | v17.3 | 1.7.3.0531 | 17.3.0.0531 | 11.4.0.0531 | 8.8.0.0531 | 17.3.0.0531/15.0.0.0625 | N/A | N/A | N/A | 1.7.2.1026 | | v17.2.1 | 1.7.2.0228 | 17.2.1.0228 | 11.3.0.1026 | 8.6.0.1026 | 17.2.1.0228/15.0.0.0625 | N/A | 10.0.0.0618 | 1.2.0.0806 | 1.7.2.1026 | | v17.2 | 1.7.2.1026 | 17.2.0.1026 | 11.3.0.1026 | 8.6.0.1026 | 17.2.0.1026/15.0.0.0625 | N/A | 10.0.0.0618 | 1.2.0.0806 | 1.7.2.1026 | | v17.1 | 1.7.1.0525 | 17.1.0.0525 | 11.2.0.0330 | 8.2.0.0525 | 17.1.0.0525/15.0.0.0625 | N/A | 10.0.0.0618 | 1.2.0.0806 | 1.7.0.0525 | | v17.0 | 1.7.0.0330 | 17.0.0.0330 | 11.0.0.0330 | 8.2.0.0330 | 17.0.0.0330/15.0.0.0625 | N/A | 10.0.0.0618 | 1.2.0.0806 | 1.7.0.0330 | | v16.2 | 1.6.2.0112 | 16.2.0.0112 | 11.1.0.112 | 7.6.0.0112 | 16.2.0.0112/15.0.0.0625 | N/A | 10.0.0.0618 | 1.2.0.0806 | 1.6.0.0428 | | v15.3.1 | 1.5.3.0107 | 15.3.0.0116 | 10.3.3.0924 | 7.3.0.0107 | N/A /15.0.0.0625 | N/A | 10.0.0.0618 | 1.2.0.0806 | 1.4.0.0107 | | v14.3.1 | 1.4.1.0115 | 14.3.1.0115 | 10.3.0.0712 | 6.4.1.0115 | N/A /14.3.1.0115 | N/A | 10.0.0.0618 | 1.2.0.0806 | 1.2.1.0115 | ## PDFR A lightweight PDF library integrated with Dynamic Web TWAIN SDK on the client side to convert text-based PDF files into images and display in the image viewer. ### `12.0.0.0318` (04/01/2025) New APIs: * [`preserveUnmodifiedOnSave`](/_articles/info/api/interfaces.md#readeroptions) * [`IsRasterizationRequired()`](/_articles/info/api/Addon_PDF.md#israsterizationrequired) ### `11.5.2.0312` (05/14/2024) * Updated third party libraries ### `11.5.1.0926` (09/26/2023) * Deprecate the methods: * GetConvertMode() * SetConvertMode() * SetPassword() * SetResolution() Use [`SetReaderOptions()`](/_articles/info/api/Addon_PDF.md#setreaderoptions) and [`GetReaderOptions()`](/_articles/info/api/Addon_PDF.md#getreaderoptions) instead. * Deprecate the enum value CM_RENDERALLWITHANNOTATION from [`Dynamsoft.DWT.EnumDWT_ConvertMode`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_convertmode). ### `11.5.0.0627` (06/20/2023) * Introduced the preview version of Dynamsoft's PDF Compressor ### `11.4.2.0328` (05/09/2023) * Updated underlying third party libraries ### `11.4.1.1025` (12/22/2022) * Added support for the Android service ### `11.4.0.0531` (06/30/2022) * General error message improvements ### `11.3.0.1026` (01/20/2022) * Clarified error message when PDF Rasterizer license is not present. * Added support for rendering annotations. Please note that saving the image after rendering the annotations will flatten the annotations to the image. ### `11.2.0.0330` (06/15/2021) * Added support for ARM64 and MIPs64EL ### `11.0.0.0428` (6/18/2020) #### IMPROVED * This addon now works both in the Local-Service mode and the WASM mode. * This addon now works on iOS, iPadOS & Android too. ### `10.3.1.0124` (06/27/2019) #### IMPROVED * [HTML5 on Windows] Changed the old DLL names to reflect the fact that they only work as the rasterizer. * [HTML5 on Windows] Removed the old PDF. Download method. * [HTML5 on Windows] Removed license limitation on the method IsTextBasedPDF so that it can always be used regardless of whether a license is in place. ### `10.3.0.0712` (9/06/2018) #### IMPROVED * Added the version number of the library to the name of the library so that different versions of the library can co-exist. * Added a method `IsModuleInstalled()` to detect whether the library has been installed on the client machine. * Updated the library to version 10.3.0.0712 which is more stable and uses the memory more efficiently. The new library also has fixed a bug where a loaded PDF may appear tilted. ### `10.2.0.1123` (7/17/2018) #### FIXED * Fixed the typo `EnumDWT_ConverMode` to `EnumDWT_ConvertMode` ### `10.2` (1/16/2018) #### IMPROVED * Upgraded the current PDF Rasterizer engine for Windows client. #### NEW * Added support for macOS client and Linux client. ### `9.6` (03/01/2016) #### NEW * Added PDF Rasterizer Add-on to convert text-based PDF files to images. This way, text PDF files can be successfully displayed in the viewer of the Dynamic Web TWAIN Scanner Core module. Available APIs are: + `Addon.PDF.SetConvertMode()` : to turn on or off the PDF rasterizer feature. + `Addon.PDF.Download()` : to deploy the PDF library from the server side to the client machine. + `Addon.PDF.SetPassword()` : set the password to decrypt the targeted PDF file. + `Addon.PDF.SetResolution()` : to set the output image resolution. + `Addon.PDF.IsTextBasedPDF()` : to detect if a PDF file is text-based or not. ## Barcode Reader A professional linear & 2D barcode reading library for recognizing barcode from any document captured from scanners, cameras or file systems. ### `9.6.40.200` (05/14/2024) Check out the release notes of Dynamsoft Barcode Reader: [9.6.40](https://www.dynamsoft.com/barcode-reader/docs/server/programming/cplusplus/release-notes/cpp-9.html?ver=9.6.40#9640-03142024). ### `9.6.20.307` (06/20/2023) * General algorithm improvements ### `9.6.0.0328` (05/09/2023) * Improved decoding algorithms for EAN8 and QR Code ### `9.4.0.1025` (12/22/2022) * Added support for Pharmacode and Code 11 * Optimized confidence scoring for PDF417 codes * Improved decoding of warped/distorted linear barcodes ### `8.8.0.0531` (17.3 release date) * Added new localization mode `ONED_FAST_SCAN` to improve reading of linear barcodes * Improved confidence scoring algorithm for 2D barcodes ### `8.6.0.1026` (17.2 release date) * Added indicator for mirrored barcodes * Improved detection speed for dense QR Codes * Improved speed of border detection for DataMatrix codes * Improved confidence scoring algorithm for linear barcodes ### `8.2.0.0525` (04/20/2021) * Added support for MSI Code (Modified Plessey). * Improved the recognition accuracy for GS1 Databar. * Improved the localization robustness for QR Code. * Improved the localization for low quality 1D barcodes. * Improved the de-blurring performance and recognition rate for DataMatrix. * Improved the recognition rate for Aztec. * Improved both the localization and decoding algorithms for Postal Codes ### `7.4.0.0428` (06/18/2020) * This addon has been redesigned with brand-new APIs. * This addon now works both in the Local-Service mode and the WASM mode. * This addon now works on iOS, iPadOS & Android too. ### `7.3.0.0107` (01/07/2020) * Updated the library to version 7.3. * Removed independent service checking logic. ### `7.1` (09/19/2019) * Updated the library to version 7.1. ### `7.0` (08/13/2019) * Updated the library to version 7.0. ### `6.5.2.0627` (06/27/2019) * Updated the library to version 6.5.2. ### `6.4.1.0115` (01/15/2019) * Expanded the Barcode Reader feature to the ActiveX. * Updated the Barcode reader libraries to version 6.4.1. ### `6.3` (09/18/2018) (Since Dynamic Web TWAIN 14.1) * Check out DBR news for more info. ### `5.2` (09/18/2017) #### IMPROVED * Improved the localization and recognition algorithms for PDF417 barcodes. * Optimized the de-blur algorithm for 1D barcodes to improve the recognition accuracy. * Optimized the timeout support. Now it is possible to stop barcode recognition by timeout. * Increased QR Code and DataMatrix barcode recognition speed for B&W images. ### `5.1` (06/20/2017) (since Dynamic Web TWAIN 13.0) #### NEW * Reconstructed the barcode reader SDKs to closely working with the Scanner Core module of the Dynamic Web TWAIN SDK. * Added support for reading barcodes from a base64 string image. * New de-blur algorithm for 1D barcodes to improve the accuracy when scanning linear barcodes from out-of-focus, blurred images. * Added new APIs that enable you to specify page numbers, barcode regions and barcode angles for barcode detection. These greatly improve the decoding workflow and barcode reading efficiency. * Added ImageCaptureDevice API to set the capture device (scanner, camera or fax) being used to scan barcode images. When set, it will use a better and more appropriate image processing technique to the images captured from that device. * Added BarcodeColorMode API to set the ink color for barcodes searching. * Added BarcodeTextEncoding API to set barcode text encoding mode so that you can display special characters properly. * Added TimeoutPerPage API to set the maximum amount of time for reading barcodes on one page. * Added Angle property to return the rotation angle of a detected barcode. #### IMPROVED * Updated barcode reader library with improved positioning algorithm that can better identify and locate DataMatrix barcodes. ### `4.3` (10/13/2016) (Dynamic Web TWAIN12.1~12.3.1) #### NEW * New localization algorithm was implemented for 1D barcode scanning to improve barcode reading speed. * New multi-thread processing was implemented for 2D barcode reading to improve decoding accuracy. #### IMPROVED * Improved recognition for perspective QR Codes. * Optimized decoding performance for large size, special angle and multiple 1D barcodes. * Other small fixes and tweaks. ### `4.2` (04/08/2016) (Dynamic Web TWAIN12.0) #### IMPROVED * Changed 1D barcode decoding module to improve recognition accuracy. ### `4.1` (01/21/2016) (11.3~11.3.2) #### IMPROVED * Improved positioning algorithm to better identify and localize DataMatrix barcodes. ### `4.0` (07/23/2015) (11.2) #### NEW * Added CodeBar, Code_93, EAN_8, EAN_13, ITF, UPC_A, UPC_E support to the 1D Barcode Reader module. * Added support for PDF417 and DataMatrix. ### `3.0` (08/13/2015) (Dynamic Web TWAIN11.1) #### NEW * Added support for QR Code and Industrial 2 of 5. ### `2.0` (07/17/2015) (Dynamic Web TWAIN11.0, internal barcode dll version 9.6) #### NEW * Added support for reading CodeBar, Code_93, EAN_8, EAN_13, ITF, UPC_A, UPC_E. #### FIXED * Fixed the bug in the Barcode Reader add-on where barcode location fails for 200 DPI. ### `1.0` (01/20/2015) (since Dynamic Web TWAIN10.1~10.2, internal barcode dll version 9.5) * Updates in this version include 1D barcode improvements in accuracy and performance for Code 39 and Code128 recognition. Also image preprocessing is improved. For Code 128, the recognition ratio and speed have jumped up by as much as 30 percent. ## Desktop Webcam Capture ### `19.2.0` (08/26/2025) Improved the performance by using persistent HTTP connection. ### `15.0` (06/27/2019) #### IMPROVED * Fixed a bug where the video stream may appear distorted if the DIV to put the stream has a different aspect ratio. ### `14.3.1` (01/15/2019) #### IMPROVED * Added a new method `IsModuleInstalled()` to detect whether the webcam module has already been installed on the local system. * The method `GetImageURL()` and `GetImagePartURL()` are renamed to `GetFrameURL()` and `GetFramePartURL()` . * Fixed a bug where the memory may fail to be freed after a frame is captured either by `CaptureImage()` or `GetFramePartURL()` . ### `14.2.0.1022` (11/20/2018) #### IMPROVED * Added Webcam addon back for Windows with a new feature to embed the video stream on the page. ## OCR ### OCR Kit #### `11.0.0.1028` (12/08/2025) A new OCR add-on was added. It is named OCR Kit internally. ### OCR Basic and OCR Pro (Deprecated) #### `1.1.0.0625` (08/13/2019) * [OCRPro] Added a feature to read multiple zones in one OCR operation. #### `1.1.0.0625` (06/27/2019) * [OCRPro] Fixed a bug where the OCR result may not be readable when the target language is Arabic. #### `1.0.0.425` (11/20/2018) * [OCRPro] Added a new feature to allow multiple OCR processes to run concurrently on the server side. #### `1.0.0.425` (09/06/2018) * [OCRPro & OCRB] Added the version number of the library to the name of the library so that different versions of the library can co-exist. * [OCRPro & OCRB] Added a method `IsModuleInstalled()` to detect whether the library has been installed on the client machine. #### `1.0.0.425` (07/17/2018) * [OCRPro] Better mechanism to verify the OCR license. #### `1.0` (07/05/2016) * [OCRPro] Added OCR Professional (OCR Pro) module. The module uses Kofax's OCR engine. It only works on Windows. --- title: Dynamic Web TWAIN SDK Schedule - Developing description: Dynamic Web TWAIN SDK Documentation Schedule - Developing Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/schedule/Developing.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/schedule/Developing.md --- # Features Under Development --- title: Dynamic Web TWAIN SDK Schedule - Stable Release description: Dynamic Web TWAIN SDK Documentation Schedule Stable Release Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/schedule/Stable.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/schedule/Stable.md --- # Stable Releases ## 19.4 (06/11/2026) ### New Features * Added support for writing PDF as PDF/A-3b. * Added `maxThreads` param for [`loadFromLocalStorage()`](/_articles/info/api/WebTwain_IO.md#loadfromlocalstorage) and [`saveToLocalStorage()`](/_articles/info/api/WebTwain_IO.md#savetolocalstorage) to improve performance. * Added [`outputInfo`](/_articles/info/api/interfaces.md#outputinfo) for [`startScan()`](/_articles/info/api/WebTwain_Acquire.md#startscan). ### Improvements * Improved Dynamic Web TWAIN Service to make it compatible with the previous major version's JavaScript. * Added native Apple Silicon support by packaging the macOS version of Dynamic Web TWAIN Service as a universal binary. * Removed the major version restriction using annual full licenses. * Added mechanism to infer [`ResourcesPath`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#resourcespath) from the script path when not specified. * Improved the triggering of [`OnTopImageInTheViewChanged`](/_articles/info/api/WebTwain_Buffer.md#ontopimageintheviewchanged). * Improved the error message if the JavaScript version does not match the service version. * Improved the REST API: * Added service version info for [`GET /server/version`](/_articles/info/api/restful.md#get-serverversion). * Added [`PATCH /storage/documents/{documentuid}`](/_articles/info/api/restful.md#patch-storagedocumentsdocumentuid) to modify document metadata. * Added [`GET /device/scanners/jobs/{jobuid}/content`](/_articles/info/api/restful.md#get-devicescannersjobsjobuidcontent) to retrieve page data concurrently. * Added an error code for failure to load password-protected PDFs. * Updated third-party libraries to enhance security. ### Bug Fixes * Fixed loading of interlaced PNGs. * Fixed an issue where the HTTP form fields are lost using segmented upload with large files. ## 19.3.3 (04/16/2026) * Updated third-party libraries to enhance security. * Fixed a `COMMONJS_VARIABLE_IN_ESM` warning using Vite 8+. ## 19.3.2 (03/05/2026) Updated third-party libraries to enhance security. ## 19.3.1 (02/11/2026) * Improved the local network access check. Screenshots have been moved to a separate web page (which lists UI differences across browsers/versions) instead of being embedded directly in the dialogs. * Updated third-party libraries to enhance security. * Fixed an issue with local network request parameters that caused connection failures after installation (affecting only Safari 26.2+). ## 19.3 (12/11/2025) ### New Features * Added a new [OCR add-on](/_articles/extended-usage/ocr.md), which uses latest AI technology. * Added support for writing [PDF/A](/_articles/extended-usage/pdf-processing.md#pdfa) files. ### Other Changes * Added checking of the [local network access permission](/_articles/faq/chromium-142-local-network-access-issue.md) introduced in Chrome 142. * Added extra settings for [`PrintEx()`](/_articles/info/api/WebTwain_IO.md#printex). * Added prevention of service installation on macOS versions lower than 10.15. * Added support for service installation for multiple users (Windows only). * Added an [`EnableLocalNetworkMixedContent`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#enablelocalnetworkmixedcontent) property. ### Improvements * Improved the performance of [`RemoveAllSelectedImages()`](/_articles/info/api/WebTwain_Buffer.md#removeallselectedimages) by triggering [`OnBufferChanged`](/_articles/info/api/WebTwain_Buffer.md#onbufferchanged) and [`OnBitmapChanged`](/_articles/info/api/WebTwain_Buffer.md#onbitmapchanged) events only once. * Improved performance for the viewer loading documents with thousands of pages. * Improved image clarity for the viewer. * Updated third-party libraries to enhance security. ### Bug Fixes * Fixed a license issue of RemoteScan. * Fixed the auto start of the service on Linux not using GUI. * Fixed the `areaIndex` of `rects` returned in the [`pageAreaSelected`](/_articles/info/api/WebTwain_Viewer.md#pageareaselected) event. ## 19.2 (08/26/2025) ### Highlights * Redesigned the service configuration page ([guide](/_articles/extended-usage/dynamsoft-service-configuration.md#web-setup)). * Moved settings of host, firewall and Bonjour service to the new external access tab. * Added domain binding for the service. * For security reasons, the settings cannot be modified through the web page unless `EnableWebSetup` is set to true in `DSConfiguration.ini` (requires admin privileges). * Improved the performance of the webcam add-on. ### Other Changes * Added back support for [Remote Scan](https://www.dynamsoft.com/remote-scan/docs/introduction/){:target="_blank"} with the following methods renamed: * `getDynamsoftService()` -> `getServices()` * `setDefaultDynamsoftService()` -> `setDefaultService()` * `getDefaultDynamsoftService()` -> `getDefaultService()` * Added support for [`IsBlankImageAsync()`](/_articles/info/api/WebTwain_Buffer.md#isblankimageasync) on Linux/Mac. * Added [`requestFocusForScanningUI`](/_articles/info/api/restful.md#:~:text=requestFocusForScanningUI){:target="_blank"} parameter for RESTful API. * Added file name and type for drag-and-dropped files in the [`OnPostLoad`](/_articles/info/api/WebTwain_IO.md#onpostload) event. * Renamed `disableFocusOutline` to [`focusOutlineEnabled`](/_articles/info/api/WebTwain_Viewer.md#focusoutlineenabled). * Improved PDF image extraction to take the transformation info (mainly mirroring) into consideration. * Opening links in the service installation dialog will no longer open a blank window. ### Bug Fixes * Fixed the spelling of [`ChangeContrastAsync()`](/_articles/info/api/WebTwain_Edit.md#changecontrastasync). * Fixed a bug where [`GetSelectedImagesSize()`](/_articles/info/api/WebTwain_Buffer.md#getselectedimagessize) returned 0 for images imported from PDFs. This issue occurred when loading a PDF with [`preserveUnmodifiedOnSave`](/_articles/info/api/interfaces.md#:~:text=preserveUnmodifiedOnSave){:target="_blank"} enabled and executing [`SelectAllImages()`](/_articles/info/api/WebTwain_Buffer.md#selectallimages). ## 19.1 (05/07/2025) ### New Features Added a new method [`getVisiblePagesInfo()`](/_articles/info/api/WebTwain_Viewer.md#getvisiblepagesinfo) to return the information of visible pages in a viewer. It is useful to add custom elements. ### Improvements - Added support for reading special TIFFs (e.g. 4-bit RGB interleaved, old-style JPEG compression) on Windows. - Added support for keeping the PDF forms when saving. - Updated the way of checking CSS file integrity from fetching to examining the effectiveness of CSS rules. - Updated the format of license expiry date to avoid misunderstanding. ### Bug Fixes - Fixed a bug that when `preserveUnmodifiedOnSave` is set to `true`, `CopyToDocumentAsync()` will fail. - Fixed a bug that the width and height set in percentage using the Web TWAIN object is not effective after resizing. ### Other Changes Updated the names of headers for the REST API. - X-DICS-LICENSE-KEY -> DWT-PRODUCT-KEY - X-DICS-DOC-PASSWORD -> DWT-DOC-PASSWORD ## 19.0 (04/01/2025) ### New Features - **Greatly expanded support for the [RESTful Dynamic Web TWAIN Service](/_articles/extended-usage/restful-api.md).** - **PDF Handling**: - Added new PDF Rasterizer Add-On API [`preserveUnmodifiedOnSave`](/_articles/info/api/interfaces.md#:~:text=preserveUnmodifiedOnSave){:target="_blank"} to preserve the size of unmodified PDF pages when saving. - Added new PDF Rasterizer Add-On API [`IsRasterizationRequired()`](/_articles/info/api/Addon_PDF.md#israsterizationrequired). This API returns true if the PDF file contains content other than one image per page. Please note that while invoking this API does not require a license for the PDF Rasterizer Add-On, a license is required to perform actual rasterization of the PDF for viewing purposes. - **Cross-platform support**: Added macOS and Linux platform support for DWT Barcode Reader Add-On. - **Error messages**: Added more informative error messages with the new [`ErrorCause`](/_articles/info/api/WebTwain_Util.md#errorcause) API. - **Keyboard accessibility**: Added Tab key keyboard navigation in the DWT `Viewer`. The browser now shows a focus outline on the `Viewer` upon tabbing into the `Viewer`, which can be disabled with the new `{WebTwainObject}.Viewer.disableFocusOutline` API. (this property is `true` by default, i.e. disables the outline) ### Improvements - **Security enhancements**: updated third-party libraries to enhance security. - **Image rasterization logic**: The logic is optimized when two or all of the following properties are specified in [`ReaderOptions.RenderOptions`: `maxWidth`, `maxHeight`, and `resolution`](/_articles/info/api/interfaces.md#readeroptions). - **Renamed the Dynamsoft Service to Dynamic Web TWAIN Service**. - **New Dynamic Web TWAIN Service installation path for Windows**: moved installation out of `SysWOW64` and `System32` on Windows to prevent rare false positive antivirus scans. - New 64-bit system-wide installation location: `C:\Program Files (x86)\Dynamsoft\Dynamic Web TWAIN Service 19` - New 32-bit system-wide installation location: `C:\Program Files\Dynamsoft\Dynamic Web TWAIN Service 19` - Changed `ErrorString` messages associated with `ErrorCode -2003` for `HTTPUpload`-related APIs to include HTTP codes in the form of `HTTP process: {message}({HTTP status code})`, e.g. `HTTP process: OK(200)`. This change applies to `ErrorString` for the following APIs: - [`{WebTwainObject}.HTTPUpload()`](/_articles/info/api/WebTwain_IO.md#httpupload) - [`{WebTwainObject}.HTTPUploadThroughPost()`](/_articles/info/api/WebTwain_IO.md#httpuploadthroughpost) - [`{WebTwainObject}.HTTPUploadThroughPostEx()`](/_articles/info/api/WebTwain_IO.md#httpuploadthroughpostex) - [`{WebTwainObject}.HTTPUploadAllThroughPostAsMultiPageTIFF()`](/_articles/info/api/WebTwain_IO.md#httpuploadallthroughpostasmultipagetiff) - [`{WebTwainObject}.HTTPUploadAllThroughPostAsPDF()`](/_articles/info/api/WebTwain_IO.md#httpuploadallthroughpostaspdf) - [`{WebTwainObject}.HTTPUploadThroughPostAsMultiPagePDF()`](/_articles/info/api/WebTwain_IO.md#httpuploadthroughpostasmultipagepdf) - [`{WebTwainObject}.HTTPUploadThroughPostAsMultiPageTIFF()`](/_articles/info/api/WebTwain_IO.md#httpuploadthroughpostasmultipagetiff) - **Thumbnail Viewer customization**: added a `position` property to the [`ThumbnailViewerEvent`](/_articles/info/api/interfaces.md#thumbnailviewerevent) to facilitate further customizations, for example, displaying a delete icon when the mouse is hovering over a thumbnail. ![thumbnail viewer event](/assets/imgs/thumbnail-viewer-event-demo.jpg) ### Removed Features - **Discontinued support for the PDF Compressor Add-On.** - **Discontinued out-of-the-box support for ActiveX.** - **Discontinued support for 32-bit macOS**: now only supporting macOS versions 10.15 and higher. - **Discontinued support for Android**: use [Mobile Document Scanner](https://www.dynamsoft.com/use-cases/mobile-document-scanner/) instead. ### Bug Fixes - Fixed a CORS request blocked error which also triggers a prompt to install the Dynamic Web TWAIN Service. - Fixed Vite runtime errors caused by polyfills and resource path misconfiguration. ## 18.5.5 (04/16/2026) Updated third-party libraries to enhance security. ## 18.5.4 (03/05/2026) Updated third-party libraries to enhance security. ## 18.5.3 (01/14/2026) Updated third-party libraries to enhance security. ## 18.5.1 (10/22/2024) ### Improvements - Enhanced product security. - Updated third-party libraries to enhance security. - Enhanced compatibility with the HTTP Content-Security-Policy style-src directive. - Improved scanner compatibility. - Improved the internal algorithms of the IsBlankImageAsync API. - Added a configuration to file-saving APIs that allows specifying whether to automatically create directories when the provided path does not exist. This option is enabled by default, and preserves existing behavior. ### Bug fixes - Fixed an issue where removing localStorage causes additional unexpected deletions under certain conditions. - Fixed an issue where FTP upload APIs fail to respond for large file uploads. - Fixed an issue where HTTP upload APIs do not return a response to server errors. - Fixed a sequence issue when saving TIFF files under certain conditions. - Reverted to the previous version of the ChangeBitDepth API algorithm when converting images to black and white. - Fixed an issue where save-related APIs do not enter their failure callbacks upon failing to save under certain conditions. - Fixed an issue where the file selection dialog fails to load files from manually entered file names - Fixed an issue where right clicking on a selection of multiple images in the viewer de-selects all but one image. - Fixed an issue where the print API prints two images on the same page under certain conditions. - Fixed the order of selected files using [`SelectedImageIndices`](/_articles/info/api/WebTwain_Buffer.md#selectedimagesindices). ## 18.5 (05/14/2024) ### New features - [Save the encrypted image caches in local Dynamsoft Service folder](https://www.dynamsoft.com/web-twain/docs-archive/v18.5.1/extended-usage/buffer-caching.html#save-the-encrypted-image-caches-in-local-dynamsoft-service-folder) In certain scenarios, there may be requirements to store encrypted image caches on a local disk for temporary data storage or backup purposes. Dynamic Web TWAIN introduces a new feature that facilitates developers in securely storing image caches in encrypted form within the Dynamsoft Service folder. - [Access-Control-Allow-Origin for Dynamsoft Service](/_articles/extended-usage/dynamsoft-service-configuration.md#access-control-allow-origin) A new security feature configures Dynamsoft Service to respond only to requests from specified origins. - [Generate the encrypted PDF files](/_articles/extended-usage/pdf-processing.md#pdf-save-settings) Supports the generation of encrypted PDF files with password protection. ### New APIs - Global | APIs | Description | | ------------------------------------------------------------ | ------------------------------------------------------------ | | [`IfCheckCORS`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#ifcheckcors) | Whether to check CORS issue in detail. | - Buffer | APIs | Description | | ------------------------------------------------------------ | ------------------------------------------------------------ | | [`updateImage()`](/_articles/info/api/WebTwain_Buffer.md#updateimage) | Update the specified image with a new image. | | [`OnDiskExceedLimit`](/_articles/info/api/WebTwain_Buffer.md#ondiskexceedlimit) | A built-in callback triggered when disk cache exceeds the limit. | - Input/Output | APIs | Description | | ------------------------------------------------------------ | ------------------------------------------------------------ | | [`createLocalStorage()`](/_articles/info/api/WebTwain_IO.md#createlocalstorage) | Create a storage folder locally to save the cache of encrypted images. | | [`localStorageExist()`](/_articles/info/api/WebTwain_IO.md#localstorageexist) | Determine whether the storage folder exists or not. | | [`saveToLocalStorage()`](/_articles/info/api/WebTwain_IO.md#savetolocalstorage) | Save encrypted image caches to the specified storage folder. | | [`loadFromLocalStorage()`](/_articles/info/api/WebTwain_IO.md#loadfromlocalstorage) | Load image from the specified storage folder. | | [`removeLocalStorage()`](/_articles/info/api/WebTwain_IO.md#removelocalstorage) | Remove the specified storage folder. | | [`httpUploadBlob()`](/_articles/info/api/WebTwain_IO.md#httpuploadblob) | Upload images which are in blob format. | | [`saveBlob()`](/_articles/info/api/WebTwain_IO.md#saveblob) | Save image which are in blob format. | | [`IfSortBySelectionOrder`](/_articles/info/api/WebTwain_IO.md#ifsortbyselectionorder) | Whether to load the files by the selection order when load files by open file dialog. | ### Improvements - Updated third-party libraries to enhance security. - Added an optional parameter `capabilities` to the method [`getCapabilities()`](/_articles/info/api/WebTwain_Acquire.md#getcapabilities) for getting specified capabilities. - Added `modifyId` to the interface [`BufferChangeInfo`](/_articles/info/api/interfaces.md#bufferchangeinfo) for returning the `imageId` of the modified image when [`OnBufferChanged`](/_articles/info/api/WebTwain_Buffer.md#onbufferchanged) is triggered. - Added `password` to the interface [`PDFWSettings`](/_articles/info/api/interfaces.md#pdfwsettings) for configuring the password of the PDF file to save when [`Write.Setup()`](/_articles/info/api/Addon_PDF.md#writesetup) is called. - Added data type `Device` to the parameter `scanner` in the interface [`ScanSetup`](/_articles/info/api/interfaces.md#scansetup) for supporting the device object when [`startScan()`](/_articles/info/api/WebTwain_Acquire.md#startscan) is used. - Optimized the quality of the de-skewed image in the built-in ImageEditor. ### Changes - Changed the design of the default Dynamsoft Service installation pop-up. ![Installation changes](/assets/imgs/installation-changes.png) - Changed the data type of `imageId` from `number` to `string`. The affected APIs are as follows: - Methods: [`ImageIDToIndex()`](/_articles/info/api/WebTwain_Buffer.md#imageidtoindex), [`IndexToImageID()`](/_articles/info/api/WebTwain_Buffer.md#indextoimageid) - Interfaces: | Interfaces | Related Methods or Events | | ------------------------------------------------------------ | ------------------------------------------------------------ | | [`TagInfo`](/_articles/info/api/interfaces.md#taginfo) | [`GetTagList()`](/_articles/info/api/WebTwain_Buffer.md#gettaglist) | | [`DocumentInfo`](/_articles/info/api/interfaces.md#documentinfo) | [`GetDocumentInfoList()`](/_articles/info/api/WebTwain_Buffer.md#getdocumentinfolist) | | [`OutputInfo`](/_articles/info/api/interfaces.md#outputinfo) | [`OnPostTransferAsync`](/_articles/info/api/WebTwain_Acquire.md#onposttransferasync) | | [`BufferChangeInfo`](/_articles/info/api/interfaces.md#bufferchangeinfo) | [`OnBufferChanged`](/_articles/info/api/WebTwain_Buffer.md#onbufferchanged) | ### Bug fixes - Resolved a bug where a predominantly white image turned black when changing its bit depth to 1 or converting it to B&W by fixing a threshold issue in the methods [`ChangeBitDepth()`](/_articles/info/api/WebTwain_Edit.md#changebitdepth) and [`ConvertToBW()`](/_articles/info/api/WebTwain_Edit.md#converttobw). - Resolved the file compatibility issue when loading PDF files via drag and drop. - Resolved a bug where [`Dynamsoft.DWT.Unload()`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#unload) was still called even when the web page reload was cancelled. ### Barcode Reader Addon - Updated to version 9.6.40. ## 18.4.2 (12/05/2023) - Security update for Dynamsoft Service. ## 18.4.1 (10/24/2023) ### MacOS Service Hotfix - Due to changes introduced with ICA drivers, Dynamic Web TWAIN may exhibit strange behavior while scanning. This release updates the Dynamsoft Service for MacOS to address these issues. See [this article](/_articles/faq/macos-sonoma-distorted-scans.md) for more details. ### DWTObject process optimization - Fixed an issue where if the Web TWAIN object was deleted from context mid scan, the scanning queue would not terminate, leaving any future requests being left pending in queue. ## 18.4 (09/26/2023) ### This Version's Highlights - Enhanced the encryption algorithm to strengthen local cache security. - Added the ability to stylize the selection box in the Viewer and Image Editor. - Added a new function that allows you to export the selected image area to either a blob or base64 format. - Added a property to relocate the server-side folder that hosts the Dynamsoft Service installers. - Added a new blank page detection method. - Added a RESTful API (See [this article](https://www.dynamsoft.com/blog/announcement/dynamsoft-service-restful-api/) for more details) ### New APIs and Properties #### Viewer and Image Editor Improvements - Added [`updateSelectionBoxStyle()`](/_articles/info/api/WebTwain_Viewer.md#updateselectionboxstyle) to both the Viewer and the Image Editor to allow for custom styling of the rectangular selection box used when selecting a portion of an image in the Viewer and Image Editor. #### Editor Functionality - Added [`OutputSelectedAreaAsync()`](/_articles/info/api/WebTwain_IO.md#outputselectedareaasync) to export the selected image area to blob or base64. #### Resource Optimization - Added `Dynamsoft.DWT.ServiceInstallerLocation` to allow moving the dist folder to a different location than the Resources folder. #### Buffer - Added [`MoveToDocumentAsync()`](/_articles/info/api/WebTwain_Buffer.md#movetodocumentasync) and [`CopyToDocumentAsync()`](/_articles/info/api/WebTwain_Buffer.md#copytodocumentasync) to allow for more multi-document handling. - Added [`IsBlankImageAsync()`](/_articles/info/api/WebTwain_Buffer.md#isblankimageasync) as an additional blank page detection method using a different algorithm than the existing `IsBlankImage()` and `IsBlankImageExpress()` functions. This method allows for sensitivity customization, enabling users to overlook minor marks and disregard background patterns. This API currently is Windows only. ### Improvements #### PDF Rasterizer - Added new [`ReaderOptions`](/_articles/info/api/interfaces.md#readeroptions) interface. - Added functions [`SetReaderOptions()`](/_articles/info/api/Addon_PDF.md#setreaderoptions) and [`GetReaderOptions()`](/_articles/info/api/Addon_PDF.md#getreaderoptions) to utilize the new `ReaderOptions` interface. #### File Saving - Saving a Black and White JPG will now automatically convert the image to grayscale prior to saving. This is due to the limitation that JPGs do not allow black and white images. Previously, Black and White images were not able to be saved to JPG without manually converting the color space prior. ### Bug Fixes - Fixed a bug where the Content-Type of ConvertToBlob was sometimes incorrectly reported in the response back from the Dynamsoft Service. - Fixed a bug where setting the container size by percentage caused incorrect viewer sizing. ### Deprecations #### PDF Rasterizer > [Alternative] Use the [`SetReaderOptions()`](/_articles/info/api/Addon_PDF.md#setreaderoptions) and [`GetReaderOptions()`](/_articles/info/api/Addon_PDF.md#getreaderoptions) functions instead. * GetConvertMode() * SetConvertMode() * SetPassword() * SetResolution() #### Viewer * selectedAreaBorderColor has been deprecated. Please use the [`updateSelectionBoxStyle()`](/_articles/info/api/WebTwain_Viewer.md#updateselectionboxstyle) function. ## 18.3 (06/20/2023) ### New Features #### Image Viewer - Add a new property zoomOrigin to determine the zoom origin as well as adding to ImageEditor and EditorSettings. ### Preview Feature #### PDF Compressor (Beta) - PDF Compressor is a compression technology based on color clustering which can help to reduce the file size when saving images as a PDF file. To preview this feature, please see this demo. Please contact us if you have any feedback or suggestions. ### Improvements #### Image Viewer - Optimized display speed of images in the viewer when view is set to n*n ViewMode. #### Android Service - When the remaining valid date of the local.dynamsoft.com certificate is less than or equal to 21 days, the certificate will be automatically renewed in the network environment. #### Remote Scan - Optimize the configuration pages of Bonjour Service and Proxy Service to make the process clearer and easier to proceed. #### General Improvements - Update third-party libraries to the latest version. - Remove redundant 32-bit dlls from Dynamsoft Service 64-bit installation directory. ## 18.2 (05/09/2023) ### New Features #### WIA 2.0 Scanner Support - Added support for direct control of WIA 2.0 drivers in [EnumDWT_DeviceType](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_devicetype). #### Optimized Android Service for document scanning from Android devices - The Android service is available on Google Play Store. - Expanded the capabilities of the Android platform. See the APIs supported on Android service. #### Remote Scan - The Remote Scan solution powered by Dynamic Web TWAIN is now officially available. Using Remote Scan, you can turn any of your traditional document scanners into a network accessible scanner and allow your end users to use it without any client side installs. Read this documentation to learn how the Remote Scan solution works. ### Improvements #### Image Viewer - The Viewer component has been migrated to a dedicated resource file. This will allow for viewerless implementations of Dynamic Web TWAIN, as well as reducing the load on the browser by removing the necessity of loading the Viewer resources into memory when the Viewer is not being used. See the property [Dynamsoft.DWT.UseDefaultViewer](/_articles/info/api/Dynamsoft_WebTwainEnv.md#usedefaultviewer). - Added the enum [EnumDWT_WorkMode](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_workmode) with a new option for image editor setting. Please refer to [createImageEditor](/_articles/info/api/WebTwain_Viewer.md#createimageeditor). - Added new method `save()` to the ImageEditor object, please refer to [createImageEditor](/_articles/info/api/WebTwain_Viewer.md#createimageeditor). #### Optimized error handling during web twain initialization - Added the [OnWebTwainError](/_articles/info/api/Dynamsoft_WebTwainEnv.md#onwebtwainerror) event for better capturing errors during the Web Twain object initialization. #### General Improvements - Updated the barcode reader library to v9.6.20 - Improved progress bar accuracy during the encoding and decoding operations ### Bug fixes Fixed bug where ShowFileDialog might not work properly on MacOS. ## 18.1 (01/12/2023) Dynamic Web TWAIN v18.1 is restructured into two editions. While the standard Service Edition focuses on interactions with scanners, the Plus Edition offers support for mobile cameras as well. The goal is to make sure the Service Edition is small-sized, easy-to-use, and stable. The Plus Edition, on the other hand, is more comprehensive and offers flexibility in platforms and devices. The following table gives a quick comparison between the two editions. | | Service Edition | Plus Edition | |-------------------------------------------------------------------|----------------------------------------------------------------------|----------------------------------------------------| | Interact with scanners from browsers on Windows, macOS and Linux | Yes | Yes | | Interact with scanners from browsers on Android | This will be supported in the next release. | Yes | | Interact with mobile cameras on iOS and Android devices | No | Yes | | Barcode Reader addon | Windows platform for now | Cross-platform support on all desktops and mobile | | Remote Scan | Windows/macOS/Linux support | Cross-platform support | NOTE (2025 Update): The Plus Edition was a temporary offering, as its enhanced features were integrated into a separate SDK product by the end of 2023. As a result, the Plus Edition is no longer available for public download. If you still require access to the Plus Edition for legacy purposes, please contact [support@dynamsoft.com](mailto:support@dynamsoft.com). ## 18.0 (12/22/2022) ### Localhost Scan #### New Features ##### Service Edition for Android - Enable document scanning from eSCL-compatible scanners or Wi-Fi Direct scanners directly to your Android mobile device. Please refer to this blog for more details. [Get Dynamsoft Service in Google Play](https://play.google.com/store/apps/details?id=com.dynamsoft.mobilescan) ##### Scanner - Added new method [GetDevicesAsync](/_articles/info/api/WebTwain_Acquire.md#getdevicesasync){:target="_blank"}. - Added new method [SelectDeviceAsync](/_articles/info/api/WebTwain_Acquire.md#selectdeviceasync){:target="_blank"}. - Added new method [AcquireImageAsync](/_articles/info/api/WebTwain_Acquire.md#acquireimageasync){:target="_blank"}. - Added new optional parameter `deviceType` to the method [SelectSourceAsync](/_articles/info/api/WebTwain_Acquire.md#selectsourceasync){:target="_blank"}. ##### Mobile Web Capture - Support turning on/off torch - Added new method [turnOnTorch](https://www.dynamsoft.com/web-twain/docs-archive/v18.0/info/api/Addon_Camera.html#turnontorch){:target="_blank"} and [turnOffTorch](https://www.dynamsoft.com/web-twain/docs-archive/v18.0/info/api/Addon_Camera.html#turnofftorch){:target="_blank"}. - Added new method [getCapabilities](https://www.dynamsoft.com/web-twain/docs-archive/v18.0/info/api/Addon_Camera.html#getcapabilities){:target="_blank"}. - Added new property `torch` to `ScannerViewer`. Refer to [scanDocument](https://www.dynamsoft.com/web-twain/docs-archive/v18.0/info/api/Addon_Camera.html#scandocument){:target="_blank"}. #### Improved Features - All license key types can now be specified with the API Dynamsoft.DWT.ProductKey. - Added new property [Dynamsoft.DWT.DeviceFriendlyName](/_articles/info/api/Dynamsoft_WebTwainEnv.md){:target="_blank"} which defines the specific device that consumes the license quota - Added new enumeration [Dynamsoft.DWT.EnumDWT_ExtImageInfo](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_extimageinfo){:target="_blank"} - Updated Barcode Reader add-on library to version 9.4. Check out the release notes for Barcode Reader JavaScript SDK - 9.x #### Bug Fixes - Base64 string returning null on load - Scanner source name not showing on source list - OnPreExecute not removing loading bar - ConvertToBase64 not working in v17.3 #### Deprecations - Check out the [Deprecations](/_articles/info/schedule/deprecated.md#180) page for v18.0 deprecations. #### Changes to ActiveX Edition - Added the following API supports for better compatibility with HTML5 Edition: [HTTPUpload](/_articles/info/api/WebTwain_IO.md#httpupload){:target="_blank"}, [ConvertToBase64](/_articles/info/api/WebTwain_IO.md#converttobase64){:target="_blank"}, [OnBufferChanged](/_articles/info/api/WebTwain_Buffer.md#onbufferchanged){:target="_blank"}, [CloseSourceAsync](/_articles/info/api/WebTwain_Acquire.md#closesourceasync){:target="_blank"}, [OpenSourceAsync](/_articles/info/api/WebTwain_Acquire.md#opensourceasync){:target="_blank"}, [GetSourceNamesAsync](/_articles/info/api/WebTwain_Acquire.md#getsourcenamesasync){:target="_blank"}, [CloseSourceManagerAsync](/_articles/info/api/WebTwain_Acquire.md#closesourcemanagerasync){:target="_blank"}, [OpenSourceManagerAsync](/_articles/info/api/WebTwain_Acquire.md#opensourcemanagerasync){:target="_blank"} ### Remote Scan Remote Document Scanning enables document scanning from all available Dynamsoft Services and eSCL scanners on the intranet through one proxy service, via any supported devices and browsers, without any software installation. Please refer to this documentation for more details. ### Breaking Changes In 18.0+, if you call Dynamsoft.DWT.GetWebTwain against a non-existent ContainerID, you will get a null return. Previously, if you made the same call in the same situation, the WebTWAIN object would still initialize. To initiate the WebTWAIN object against a ContainerID, please use `GetWebTwain`. To utilize a viewer-less WebTWAIN object, please use [`CreateDWTObjectEx`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#createdwtobjectex) ## 17.3 (06/30/2022) ### New and Improved Features #### Mobile Web Capture - Improved performance and user experience with re-designed mobile document capture workflow. Some highlights: - The original copy of an image is kept in the new document editor object so you can always go back to the original image to make any edit. - Building your custom workflow to trigger actions in your desired sequence is made easy. - Interface elements in the viewer/editor are now customizable. You can easily add/remove icons or change their style. #### Buffer - Added new method [RenameDocument](/_articles/info/api/WebTwain_Buffer.md#renamedocument){:target="_blank"}. - Renamed methods - CreateFile -> [CreateDocument](/_articles/info/api/WebTwain_Buffer.md#createdocument){:target="_blank"} - OpenFile -> [OpenDocument](/_articles/info/api/WebTwain_Buffer.md#opendocument){:target="_blank"} - GetCurrentFileName -> [GetCurrentDocumentName](/_articles/info/api/WebTwain_Buffer.md#getcurrentdocumentname){:target="_blank"} - RemoveFile -> [RemoveDocument](/_articles/info/api/WebTwain_Buffer.md#removedocument){:target="_blank"} - GetFileInfoList -> [GetDocumentInfoList](/_articles/info/api/WebTwain_Buffer.md#getdocumentinfolist){:target="_blank"} - Added new method [GetRawDataAsync](/_articles/info/api/WebTwain_Buffer.md#getrawdataasync){:target="_blank"}. #### Viewer - Added new method [updateCheckboxStyle](/_articles/info/api/WebTwain_Viewer.md#updatecheckboxstyle){:target="_blank"} to customize checkboxes. This method is also added to `ThumbnailViewer`. Refer to [createThumbnailViewer](/_articles/info/api/WebTwain_Viewer.md#createthumbnailviewer){:target="_blank"}. - Added new method [updatePageNumberStyle](/_articles/info/api/WebTwain_Viewer.md#updatepagenumberstyle){:target="_blank"} to customize page numbers. This method is also added to `ThumbnailViewer`. Refer to [createThumbnailViewer](/_articles/info/api/WebTwain_Viewer.md#createthumbnailviewer){:target="_blank"}. - Added new properties `checkbox` and `pageNumber` to `ThumbnailViewerSettings`. Refer to [createThumbnailViewer](/_articles/info/api/WebTwain_Viewer.md#createthumbnailviewer){:target="_blank"}. - Added a new parameter `documentConfiguration` to the method [createTemplate](/_articles/info/api/WebTwain_Viewer.md#createtemplate){:target="_blank"}. - Added new method [createDocumentEditor](/_articles/info/api/WebTwain_Viewer.md#createdocumenteditor){:target="_blank"}. - Added new property [selectionMode](/_articles/info/api/WebTwain_Viewer.md#selectionmode){:target="_blank"}. - Added new property [allowPageDragging](/_articles/info/api/WebTwain_Viewer.md#allowpagedragging){:target="_blank"}. ### Minor Improvements - Modified [Dynamsoft.DWT.EnumDWT_PDFCompressionType](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_pdfcompressiontype){:target="_blank"} from `PDF_JBig2` to `PDF_JBIG2`. - Made changes to support organizationID value for Dynamsoft.DWT.ProductKey. - Enabled license key validation for the correct version during initialization. ### Bug Fixes - On MacOS, images in the viewer were sometimes lost when waking up from sleep mode. - Incorrect error message displayed when using camera function with UseLocalService set to true. - Unchecking checkboxes did not trigger the OnBufferChanged event. - Failed to load dll for PDF decoding or encoding when using v17.x SDK with an older version image dll file. - Images failed to display in print window. - Edited images not showing correctly in Image Editor. - Images not displaying correctly in landscape mode when printing from Image Editor. - Iframe not working in Edge due to Content Security Policy. ### Deprecations * Check out the [Deprecations](/_articles/info/schedule/deprecated.md#173) page for v17.3 deprecations. ## 17.2.5 (03/29/2022) ### Improved Features - Updated the files *dynamsoft.webtwain.initiate.js* and *dynamsoft.webtwain.addon.camera.js* for better performance of mobile document capturing when using Safari on iOS/iPadOS 13+ ### Bug Fixes - Updated the file *dynamsoft.webtwain.initiate.js* to resolve a memory leak issue in v17.2.1 on Chrome 98+ when the [view mode](/_articles/info/api/WebTwain_Viewer.md#setviewmode){:target="_blank"} is set to (-1, -1) or if a [thumbnail viewer](/_articles/info/api/WebTwain_Viewer.md#createthumbnailviewer){:target="_blank"} is used. ## 17.2.1 (02/24/2022) ### Improved Features - Made changes to handle CORS preflight requests sent by Chrome from V98. Learn more [here](/_articles/faq/private-network-access-in-chrome101.md){:target="_blank"}. - For Chromium V84+, use userAgentData instead of userAgent in response to UserAgent String phasing out issue. ### Bug Fixes - Fixed a bug where Dynamsoft Service installation/uninstallation failed due to the current user account does not match the user account under C:\Users{account}. Learn more [here](/_articles/faq/service-installation-issue.md){:target="_blank"}. - [HTML5 on MacOS] Fixed a bug where the short key (set by [organizationID](/_articles/info/api/Dynamsoft_WebTwainEnv.md#organizationid){:target="_blank"}) did not work on macOS 12+. - Fixed a bug where the mouse wheel did not work when the mouse was over the viewer. - [HTML5 on MacOS] Fixed a bug where buttons were not visible during Dynamic Web TWAIN/Dynamsoft Service installation when using dark mode. ## 17.2 (01/20/2022) ### New Features #### Buffer - Organize images in a set - [HTML5 & WASM] Added new method [`CreateFile()`](/_articles/info/api/WebTwain_Buffer.md#createfile){:target="_blank"}. - [HTML5 & WASM] Added new method [`OpenFile()`](/_articles/info/api/WebTwain_Buffer.md#openfile){:target="_blank"}. - [HTML5 & WASM] Added new method [`RemoveFile()`](/_articles/info/api/WebTwain_Buffer.md#removefile){:target="_blank"}. - [HTML5 & WASM] Added new method [`GetCurrentFileName()`](/_articles/info/api/WebTwain_Buffer.md#getcurrentfilename){:target="_blank"}. - [HTML5 & WASM] Added new method [`GetFileInfoList()`](/_articles/info/api/WebTwain_Buffer.md#getfileinfolist){:target="_blank"}. - [HTML5 & WASM] Added new method [`GetTagListByIndex()`](/_articles/info/api/WebTwain_Buffer.md#gettaglistbyindex){:target="_blank"}. #### Editor - [HTML5 & WASM] Added new method [`ChangeBrightnessAsync()`](/_articles/info/api/WebTwain_Edit.md#changebrightnessasync){:target="_blank"}. - [HTML5 & WASM] Added new method `ChangeContrastAsync()`](/_articles/info/api/WebTwain_Edit.md#changecontrastasync){:target="_blank"}. #### Camera - [WASM] Added new method [`scanDocument()`](https://www.dynamsoft.com/web-twain/docs-archive/v17.2.1/info/api/Addon_Camera.html#scandocument){:target="_blank"} to capture document(s). #### Viewer - [HTML5 & WASM] Added new property [`showCheckbox`](/_articles/info/api/WebTwain_Viewer.md#showcheckbox){:target="_blank"}. - [HTML5 & WASM] Added new method [`createTemplate()`](/_articles/info/api/WebTwain_Viewer.md#createtemplate){:target="_blank"} to create document scanner template. ### Improved Features * Improved the mobile document capture in WASM mode. See more here. * Added `CM_RENDERALLWITHANNOTATION` convert mode to [EnumDWT_ConvertMode](/_articles/info/api/Addon_PDF.md#setconvertmode){:target="_blank"} to support loading PDFs with annotations. * Modified DynamicImage.dll(DynamicImagex64.dll) to improve encoding and decoding mode of TIFF files. * Updated Barcode Reader library to version 8.6. Check out the release notes for Barcode Reader JavaScript SDK - 8.6 ### Bug Fixes * Fixed a bug where the image displayed in the thumbnail may be inconsistent with that on the canvas when switching tags through `FilterImageByTag`. * Fixed a bug that Dynamic Web TWAIN object could not be initialized when using iframe in Edge. * [HTML5 on macOS] Fixed a bug where `IfDuplexEnabled` may not work for some scanners. * [HTML5 on macOS & Linux] Fixed a bug where calling `LoadDibFromClipboard` does not work after calling `CropToClipboard`. ## 17.1.1 (08/19/2021) ### Improved Features * Updated DSSCN2.exe and DSSCN2x64.exe to optimize scanner compatibility. * Improved the performance for the Dynamsoft Service connection. * Improved [LoadDibFromClipboard](/_articles/info/api/WebTwain_IO.md#loaddibfromclipboard){:target="_blank"} to make it more stable. ### Bug Fixes * Fixed a bug where operating system incorrectly judged when using Dynamic Web TWAIN with Electron. * Fixed a bug that drag and drop does not work when loading multiple files. ## 17.1 (06/15/2021) ### New Features * Added support for ChromeOS. See more here * Added property [organizationID](/_articles/info/api/Dynamsoft_WebTwainEnv.md#organizationid){:target="_blank"} which can be used to fetch license(s) belonging to the specified organization from the License Tracking Server. With this property, the licensing of the library is smoother from trial to full and it is much easier to manage a license change without code updates. ### Improved Features * The built-in viewer can now display thumbnails faster. * Installers for ARM x64 and MIPS x64 are now included in the package by default. * Separated the library into two distinctive modes: Desktop Service and WebAssembly for easier understanding and usage. ### Major Bug Fixes * Fixed a bug where the image fails to be displayed after it gets cropped and saved in the built-in ImageEditor. * Fixed a bug where images meant to be saved on the hard disk end up in the image buffer on macOS. * Fixed a bug where erasing part of an image will change its original display mode to be 'centered'. ### Changes to ActiveX Edition * Fixed a bug where the barcode reader addon fails to initiate on IE 10. ## 17.0 (04/20/2021) ### New Features * Added support for 64-bit ARM based computers. [Video](https://www.youtube.com/watch?v=mBnaseU2xtc) * Added support for 64-bit MIPS based computers. * Added support for trackable license types such as "Per Browser Client". This new license mechanism is incompatible with the traditional product key. The related APIs are licenseServer, handshakeCode, sessionPassword, licenseException. * Added method [`RemoveTag()`](/_articles/info/api/WebTwain_Buffer.md#removetag) to remove a specified tag from one or multiple images. * Added method [`GetTagList()`](/_articles/info/api/WebTwain_Buffer.md#gettaglist) to return the status of all current tags. * Added method [`PrintEx()`](/_articles/info/api/WebTwain_IO.md#printex) to support selective printing. * Added property [`autoChangeIndex`](/_articles/info/api/WebTwain_Viewer.md#autochangeindex) which, when set to true, will make sure the first image in the viewer is always selected when scrolling through multiple images. ### Improved Features * The built-in viewer now consumes less memory than before. * Scanning via ICA now supports the transfer modes File and Memory. * Upgraded the encryption algorithm for locally cached images from 64-bit Blowfish to AES-256-GCM encryption. * [`DefaultSourceName`](/_articles/info/api/WebTwain_Acquire.md#defaultsourcename) now refers to the last used source. * Updated Barcode Reader library to version 8.2.1. Check out release notes for [Barcode Reader JavaScript SDK - 8.2.1.](https://www.dynamsoft.com/barcode-reader/programming/javascript/release-notes/js-8.html#821-03292021) ### Changed Behaviors * The property Viewer.selectedAreaBorderColor now also applies to the selection box on the video opened by the method [`showVideo`](https://www.dynamsoft.com/web-twain/docs-archive/v17.2.1/info/api/Addon_Camera-v17.1.1.html#showvideo). ### Breaking changes #### Moved * The original namespace `Dynamsoft.WebTwainEnv` is renamed to `Dynamsoft.DWT`. * All enumerations are moved under `Dynamsoft.DWT`. For example, `Dynamsoft.EnumDWT_PixelType` and `EnumDWT_PixelType` work in version 16.2 and lower but now it must be written as `Dynamsoft.DWT.EnumDWT_PixelType`. #### Others * Server-side OCR pro is no longer supported in this version. * When OCR Pro is used on the client side, it requires a trackable license. The traditional product key no longer works. ### Bug Fixes * Fixed a bug where the method [`CloseSourceManager()`](/_articles/info/api/WebTwain_Acquire.md#closesourcemanager) gets called too many times and slows down scanning when you use SelectSourceByIndex() for source selection. * Fixed a bug where you get an incorrect name with the API [`CurrentSourceName`](/_articles/info/api/WebTwain_Acquire.md#currentsourcename) or [`DefaultSourceName`](/_articles/info/api/WebTwain_Acquire.md#defaultsourcename) . ### Notice * The package @types/dwt is no longer maintained, the type definitions are included by default in the dwt package since version 16.2. #### [NPM related](https://www.npmjs.com/package/dwt) * Add changes to Types + Added definition for [`UseLocalService`](/_articles/info/api/WebTwain_Util.md#uselocalservice), [`RemoveTag()`](/_articles/info/api/WebTwain_Buffer.md#removetag)and [`GetTagList()`](/_articles/info/api/WebTwain_Buffer.md#gettaglist). + Removed old definitions based on version 12, 13 and 14. + Renamed namespace WebTwainEnv to DWT. + Moved enumerations under Dynamsoft.WebTwainEnv. ## `16.2` (01/18/2021) ### New Features * Connection with the Dynamsoft Service is now maintained after the computer awake from sleep or hibernation. + Only on Windows or macOS. * Added a new event [`OnBufferChanged`](/_articles/info/api/WebTwain_Buffer.md#onbufferchanged) which is triggered when the buffer changes like + New pages enter the buffer. + Existing pages are removed. + Existing pages are modified. + Existing pages are shifted. + Existing pages are filtered by a specified tag. + Page selection changes. * Added a configuration page to update the host or ports of the Dynamsoft Service. By default, this page can be accessed by the URL http://127.0.0.1:18625/admin/. * The default loader bar can now be customized with the API [`Dynamsoft.WebTwainEnv.CustomizableDisplayInfo.loaderBarSource`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#loaderbarsource). + Only effective when set before the page finishes loading (i.e. before [DOMContentLoaded](https://developer.mozilla.org/en-US/docs/Web/API/Window/DOMContentLoaded_event)). * Added a new global property [`Dynamsoft.WebTwainEnv.IfAlwaysFocusOnPopupWindow`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#ifalwaysfocusonpopupwindow) to control whether to set focus on scanner-related windows opened by the Dynamsoft Service when the browser tab on which the SDK is running is active. In the past, these windows will be on top no matter which browser tab is active. * [Shadow DOM](https://www.dynamsoft.com/codepool/polymer-shadow-dom-web-document-scan.html) is officially supported. * Added support for ARM-based macOS. * Added support for 64-bit Raspberry Pi. ### Improved Features * Made the viewer more independent and robust. Related APIs are redesigned. + Added a new global property [`Dynamsoft.WebTwainEnv.UseDefaultViewer`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#usedefaultviewer) to control whether the built-in viewer is used. * Scanning remotely now supports showing the Manufacturer's User Interface. + Only when the remote machine is Windows. + To show the UI, use [`AcquireImage()`](/_articles/info/api/WebTwain_Acquire.md#acquireimage) with the parameter `deviceConfiguration` instead of the API [`IfShowUI`](/_articles/info/api/WebTwain_Acquire.md#ifshowui). + Check out [how to enable remote scan](/_articles/general-usage/scanner-image-acquisition.md#how-to-enable-remote-scan). * Improved the tagging mechanism + Added a new method [`RenameTag()`](/_articles/info/api/WebTwain_Buffer.md#renametag) to rename an existing tag. + Added a new method [`ClearFilter()`](/_articles/info/api/WebTwain_Buffer.md#clearfilter) to stop filtering images by tag. + The method [`FilterImagesByTag()`](/_articles/info/api/WebTwain_Buffer.md#filterimagesbytag) shows all images if no parameter is passed or shows no image at all if the tag value passed doesn't exist or there is no images under that tag. * Updated the signatures for the files on macOS so that TWAIN drivers can be populated correctly. * Added global configuration options for the WASM-mode which includes [`maxHeapSize`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#maxheapsize) and [`fetchOptions`](/_articles/info/api/Dynamsoft_WebTwainEnv.md#fetchoptions). * Improved the methods [getCapabilities](/_articles/info/api/WebTwain_Acquire.md#getcapabilities) and [setCapabilities](/_articles/info/api/WebTwain_Acquire.md#setcapabilities) so that they work for ICA drivers on macOS too. * The Barcode Reader add-on is upgraded from 7.4.0.0428 to 7.6.0.0112. * Improved the display quality of the viewer in single-image mode (-1 * -1). ### Changed Behaviors * When the view changes from single-image mode to multi-image mode, the cursor used to be changed to "hand" which means you can drag and drop images, in v16.2, the cursor will stay unchanged. In other words, if the cursor was "crosshair" in single-image mode, it'll continue to be "crosshair" in multi-image mode which means you can continue to draw rectangles on these images (NOTE that you can only draw on the *current* image). You can use the property [Viewer.cursor](/_articles/info/api/WebTwain_Viewer.md#cursor) to change the cursor in this case. * The properties [`Width`](/_articles/info/api/WebTwain_Viewer.md#width) and [`Height`](/_articles/info/api/WebTwain_Viewer.md#height) will always return the actual number of pixels even if you set them with a percentage like "50%". * The properties `BackgroundColor` and `SelectionImageBorderColor` will always return a string that represents the style (color, border, etc.) even if you set them with numbers. For example, `BackgroundColor` returns "#000032" if you set it to "50" and `SelectionImageBorderColor` returns "1px solid #000032" when you set it to "50". Also, these two properties are deprecated and should be replaced by [`Viewer.background`](/_articles/info/api/WebTwain_Viewer.md#background) and [`Viewer.selectedPageBorder`](/_articles/info/api/WebTwain_Viewer.md#selectedpageborder). * The properties `IfFitWindow` and `FitWindowType` are now write-only as their actual values may not be correct when you read them. As these properties are deprecated, use [`fitWindow()`](/_articles/info/api/WebTwain_Viewer.md#fitwindow) instead. * Added a 3rd parameter `fill` to the method [`play()`](https://www.dynamsoft.com/web-twain/docs-archive/v17.2.1/info/api/Addon_Camera-v17.1.1.html?ver=16.2&&cVer=true#play) which determines whether the video should fill the whole viewer and have a part of the video hidden. In v16.1.1-, the default behavior is to fill the whole viewer and in v16.2, it'll put the video within the viewer and possibly leave some margin. * On macOS, the default transfer mode for TWAIN drivers is changed from "native" to "memory". * The "Cut" ("Erase") button in the image editor now cuts the selected area to the clipboard instead of just erasing the area. * The "Stretch" button is deleted from the image editor. * The type declaration files are now included in the [`Dynamic Web TWAIN` package](https://www.npmjs.com/package/dwt). From version 16.2 on, these files are no longer maintained on [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped). ### Breaking changes #### Moved * The methods `showVideo()` and `closeVideo()` are moved from the interface `Viewer` to `Addon.Camera`. * The method [`showVideo()`](https://www.dynamsoft.com/web-twain/docs-archive/v17.2.1/info/api/Addon_Camera-v17.1.1.html?ver=16.2&&cVer=true#showvideo) has added two more parameters `mode` and `fill` and the video starts in the new default `picture` mode. To get the old behavior, use the `document` mode. #### Deleted * The property `SelectedImagesCount` and the method `GetSelectedImageIndex()` are deleted. Use [`SelectedImagesIndices`](/_articles/info/api/WebTwain_Buffer.md#selectedimagesindices) instead. * The method `SetSelectedImageIndex()` is deleted. Use [`SelectImages()`](/_articles/info/api/WebTwain_Buffer.md#selectimages) instead. * The method `UpdateViewer()` is deleted. There is no alternative method. * The second parameter for the method `BindViewer()` is deleted and it has only one parameter to specify the HTML element now. Therefore, you cannot use this method to create a thumbnail viewer anymore. Use the new method [`createThumbnailViewer()`](/_articles/info/api/WebTwain_Viewer.md#createthumbnailviewer) instead. #### Others * Check out [Viewer related API changes in version 16.2](/_articles/info/api/appendix.md#viewer-related-api-changes-in-version-162). ### Bug Fixes * Fixed a bug where if you create a `WebTwain` instance under WASM-mode and then destroy it and create another `WebTwain` instance under Service-mode, you will be prompted to install the Dynamsoft Service even if it is already installed. * Fixed a bug with the scanner model "Canon DR-M260" (200 series) where the manufacturer's UI hangs or disappears once it is shown. * Fixed a bug on macOS where 1-bit TIFF files become inverted once they are transferred via the system clipboard. * Fixed a bug where changing the UI of the image editor will affect the main viewer. * Fixed a bug where the method [`updateRuntimeSettings`](/_articles/info/api/Addon_BarcodeReader.md#updateruntimesettings) will overwrite all settings you set with the method [`initRuntimeSettingsWithString`](/_articles/info/api/Addon_BarcodeReader.md#initruntimesettingswithstring). * Fixed a bug where the wrong PDF library is referenced when the SDK switches to the Service-mode from WASM-mode. * Fixed a bug on mobile devices where once an image is cut, its metadata is lost and can no longer be printed (it appears blank when being printed). * Fixed a bug where if the Dynamsoft Service is not installed and a `WebTwain` instance is created using the method `CreateDWTObject()` or `CreateDWTObjectEx()`, the connection to the service is not attempted automatically as expected (a page refreshing is required). * Fixed a bug with the API `Dynamsoft.WebTwainEnv.CustomizableDisplayInfo` so that it now works again. * Fixed a bug where removed images remain in the viewer. * Fixed a bug where if you set the `display` attribute of the viewer to `none`, it becomes black. * Fixed a bug where global keyboard or mouse events registered to the Dynamsoft Viewer were not released correctly. ### Deprecations * Check out the [Deprecations](/_articles/info/schedule/deprecated.md#162) page for v16.2. ### Changes to ActiveX Edition * Internet Explorer 8 is no longer supported. * Fixed a bug where when saving an image as TIFF, the same image gets duplicated in the buffer. ## `16.1.1` (08/13/2020) ### Changed Behaviors * Whether to load the `WASM` for the Camera module is now optional (used to be mandatory in `16.1` ) and is disabled by default. * The webcam/camera license is now considered a core license and can be used without a scan license. ## `16.1` (08/04/2020) ### New Features * Added method `SetProductKeyAsync()` which sets the product key asynchronously. Previously, the property ProductKey was used for both setting and reading the key. The same behavior is kept in 16.1 but the recommendation now is to use the method `SetProductKeyAsync()` to set it and use the property `ProductKey` to read it. * Added methods `GetSourceNamesAsync()`, `SelectSourceAsync()`, `SelectSourceByIndexAsync()`, `OpenSourceAsync()`, `CloseSourceAsync()`, `OpenSourceManagerAsync()`, `CloseSourceManagerAsync()` , as asynchronous complements to their existing synchronous methods. * Support showing both 64-bit TWAIN drivers and 32-bit TWAIN drivers at the same time. > NOTE: This driver type does not work if we call `SelectSource()` synchronously (without callbacks). * Added APIs under `Addon.Camera` as a complement to the existing APIs under `Addon.Webcam` . These APIs include `getSourceList()` , `selectSource()` , `getCurrentSource()` , `closeSource()` , `getResolution()` , `setResolution()` , `getCurrentResolution()` , `play()` , `pause()` , `resume()` , `stop()` , `getStatus()` and `capture()` . Unlike the old APIs under `Addon.Webcam` which are good only on Windows, the new APIs are good on Windows, macOS, Linux as well as iOS & Android. * Added a property `UseLocalService` to return whether a `WebTwain` instance is running in the Local-Service mode or WASM mode. * Added built-in video processing feature which enables video streaming, edge detection, perspective adjustment, capturing, etc. Related APIs include `showVideo()`, `closeVideo()` and two callbacks `video-closed` and `video-error` . > NOTE: on desktop, this feature requires a webcam/camera addon license. ### Extra Features * Added a feature to run Dynamsoft Service with the account "Local Service". By default, it is still "Local System". Contact Dynamsoft to learn more. ### Beta Feature * 16.1 now supports acquiring images from a remote scanner which is connected to a machine which is connected via HTTP. This feature is designed to enable document scanning on mobile devices. ### Better Performance * Improved the speed to initialize the library under WASM mode by splitting one WebAssembly file into multiple files and loading them in the background. * Improved memory usage by sharing the same heap among multiple WebAssembly workers. * Improved image decoding by removing unnecessary image processing operations as well as lowering the memory usage. * Improved data transferring efficiency by using pointers instead of strings. * Improved performance by saving compiled WebAssembly code into the working process for later use. ### Changed Behaviors * This version is backward compatible with version 16.0. This means once you have installed the Dynamsoft Service for version 16.1, an application running version 16.0 also works without the need to install the Service for version 16.0. * The method `LoadImageEx()` now supports mobile platforms as well. * Dynamsoft Service directory is now named with its major version in it. For example, `/DynamsoftServicex64/` is now `/DynamsoftServicex64_16/`. Also ActiveX related files are put into a different directory called `/WebTWAINActiveX/` . ### Bug Fixes * Fixed a bug where images fail to show in the viewer in IE 10. * Fixed a bug in Chrome where the print UI invoked by the API `Print()` disappears immediately after showing up. * Fixed a bug with the API `Dynamsoft.WebTwainEnv.Host` which is now effective. * Fixed a bug with consecutive cropping operations with the API `Crop()`. * Fixed a bug with `WebTwain` instances created by the API `Dynamsoft.WebTwainEnv.CreateDWTObjectEx()` so that their UI binding works correctly. ### Deprecations No deprecation in version 16.1. ### Changes to ActiveX Edition No changes in version 16.1. ## `16.0` (06/16/2020) ### Features to the Core Module * Added a new mobile edition that enables document capturing via mobile cameras and other document manipulation functionalities. Most of the existing methods and properties are made compliant with this new edition. * Added WASM based document manipulation functionalities which enable the use of all features of Dynamic Web TWAIN except for document scanning without installing the Dynamsoft Service. * Added setting `Dynamsoft.WebTwainEnv.UseLocalService` to switch the working mode of the library between Local-Service mode and WASM mode. Only valid on desktop operating systems. * Replaced the built-in image viewer including the built-in image editor with the Dynamsoft Viewer. * The creation of a `WebTwain` instance is now independent from the UI. In version 16.0, you can create a `WebTwain` instance in 4 ways + Specify a `Container` that has a `ContainerId` and assign it to `Dynamsoft.WebTwainEnv.Containers` . A `ContainerId` is essentially the id of an `HTMLDivElement` element which is required for generating a built-in Dynamsoft Viewer. Then call the method `Dynamsoft.WebTwainEnv.GetWebTwain()` with `ContainerId` as the argument to get the instance. + Call the method `Dynamsoft.WebTwainEnv.CreateDWTObject()` to create an instance with built-in Dynamsoft Viewer. + Specify a `Container` that has a `WebTwainId` but no `ContainerId` and assign it to `Dynamsoft.WebTwainEnv.Containers` . A `WebTwainId` is just a string to uniquely specify the instance. Then call the new method `Dynamsoft.WebTwainEnv.GetWebTwainEx()` with `WebTwainId` as the argument to get the instance. + Call the method `Dynamsoft.WebTwainEnv.CreateDWTObjectEx()` to create an instance without a built-in Dynamsoft Viewer. > Note > > If a `WebTwain` instance is created without a built-in Dynamsoft Viewer, you can create a Viewer later and bind it to the existing `WebTwain` instance using the new method `BindViewer()` . The Viewer can also be updated or unbound with the new methods `UpdateViewer()` and `UnbindViewer()` . * Added method `LoadImageFromBinary()` to enable importing data from binary (an object of the type Blob or ArrayBuffer). * Added methods `getCapabilities()` and `setCapabilities()` which enables fast capability negotiation. * Added method `EnableSourceUI()` to enable TWAIN configuration without scanning. * Added method `SelectImages()` to select one or multiple images programmatically. This method replaces the old APIs `SetSelectedImageIndex()` and `SelectedImagesCount` . * Added property `SelectedImagesIndices` to return the indices of selected images. This property replaces the old API `GetSelectedImageIndex()` . * Added Viewer-specific APIs: `setViewMode()` , `updateUISettings()` , `setButtonClass()` , `setSelectedImageArea()` , `zoomIn()` , `zoomOut()` , `bindCustomElement()` , `showCustomElement()` , `hideCustomElement()` , `toggleCustomElement()` . These methods should be called like this: `DWTObject.Viewer.zoomIn()` . ### Updated Add-on Features * Added PDF Rasterizer mobile edition. * Extended the PDF Rasterizer on desktop to the WASM mode. * Replaced the old barcode reader add-on with a new add-on which now supports both Local-Service mode and WASM mode of the desktop editions as well as the mobile edition. ### Better Performance * In favor of the WASM mode, image transferring now uses JPEG more often than PNG. Previously, there was only the Local-Service mode and only PNG was used. * The following methods are made asynchronous (while still synchronous-compliant): `ChangeImageSize()` , `ConvertToBW()` , `ConvertToGrayScale()` , `Crop()` , `Erase()` , `FilterImageByTag()` , `Flip()` , `GetSelectedImagesSize()` , `GetSkewAngle()` , `Invert()` , `Mirror()` , `Rotate()` , `RotateEx()` , `RotateLeft()` , `RotateRight()` , `SetDPI()` , `SetImageWidth()` > NOTE > > These APIs must be called asynchronously in the WASM mode. ### Changed Behaviors * The methods `HTTPDownload()` and `HTTPDownloadEx()` no longer has the "Content-Type" header in their HTTP Get requests. * The method `GetSourceNames(true)` now returns more information which includes "DriverType" and "DeviceInfo". ### Deprecations * Deprecated `SetSelectedImageIndex()`, `GetSelectedImageIndex()` and `SelectedImagesCount` in favor of the new method `SelectImages()` . * Deprecated `IfOpenImageWithGDIPlus` in favor of the built-in imaging decoder. * Deprecated the following APIs in favor of the new methods `getCapabilities()` and `setCapabilities()` : `CapGet()` , `CapGetHelp()` , `CapGetCurrent()` , `CapGetDefault()` , `CapGetFrameBottom()` , `CapGetFrameLeft()` , `CapGetFrameRight()` , `CapGetFrameTop()` , `CapGetLabel()` , `CapGetLabels()` , `CapSet()` , `CapReset()` , `CapSetFrame()` , `CapIfSupported()` , `GetCapItems()` , `GetCapItemsString()` , `SetCapItems()` , `SetCapItemsString()` , `Capability` , `CapNumItems` , `CapMaxValue` , `CapMinValue` , `CapCurrentValue` , `CapCurrentIndex` , `CapDefaultValue` , `CapDefaultIndex` , `CapType` , `CapValueType` , `CapDescription` , `CapStepSize` , `CapValue` , `CapValueString` ### Changes to ActiveX Edition * Added method `SelectImages()` . * Added property `SelectedImagesIndices` . ## `15.3.1` (03/05/2020) ### Improved * [HTML5] When reinstalling the Dynamsoft service, the service configuration file `DSConfiguration.ini` will now be replaced directly. ### Fixed * [HTML5] Fixed a bug where the scanner stops responding when you cancel the scan multiple times. * [HTML5] Fixed a bug where the scanner stops responding when the library tries to retrieve extended information that contains magnetic data. * [HTML5] Fixed a bug where images can't be selected in batches (CTRL/SHIFT + Click) after swapping the current tag. ## `15.3` (01/07/2020) ### New * [HTML5] Added a new configuration `extendedImageInfoQueryLevel` for the method `AcquireImage()` that allows setting up how the library queries extended image info items. In version 15.2, the default level would result in scanning failure or serious performance issues with some scanners. * [HTML5] Added a new method `GetSourceNames(bool bIncludeDetails)` that returns the list of available data sources as a string array. On Windows, when `bIncludeDetails` is set to `true` , this method returns more details about the sources including its protocol versions, manufacturer and whether it's the default/current source, etc. * [HTML5] Added a new method `SelectAllImages()` that can select all images in buffer or all images that have been filtered by tags. * [HTML5] Added a new method `ConvertToBW(number imageIndex)` that converts a specific image to Black & White. * [HTML5] Added a new method `Invert(number imageIndex)` that inverts a specific image. ### Improved * [HTML5] changing the methods `HTTPUploadThroughPostDirectly()`, `HTTPDownloadDirectly()` to only work on whitelisted images/files (check NOTE below). * [HTML5] Changing the default SSL certificates is now officially supported. * [HTML5] Changed the property `LogLevel` so that when it's set to `1\0` , it's equivalent to setting `LogLevel` to `14\1` in the file `C:\Windows\SysWOW64\Dynamsoft\DynamsoftServicex64\DSConfiguration.ini` * [HTML5] Local caching is made smoother by introducing a new process to do the caching when the threshold is reached. As a result, it is significantly faster when loading a great many files. * [HTML5 on macOS] When using ICA(Image Capture Architecture) sources, info that was written to system log is now written to `wtss.log` . * [Upload Module] Now the module can only upload files/images that are whitelisted (check NOTE below) > Note on how whitelisting is done > > Dynamsoft Service keeps a whitelist of all images in buffer as well as images saved by the Service. The whitelist lives on until the current service process is destroyed. > Each Dynamic Web TWAIN object keeps a whitelist of file paths that are retrieved in the callback `OnGetFilePath` for the method `ShowFileDialog()` . ### Deprecated [HTML5] Further improved security by deleting the methods `FTPUploadDirectly()` , `FTPDownloadDirectly()` , `FileExists()`. ### Fixed [HTML5] Fixed a bug where Dynamsoft Service gets stuck when you try to perform concurrent operations on the same image(s) like uploading and converting them at the same time. [HTML5] Fixed a bug where Dynamsoft Service crashes when the callback OnBitmapChanged is called recursively. ## `15.2` (09/19/2019) ### New * [HTML5] Added the capability to add tags to images. The tags can then be used to filter the images. The new APIs are `TagImages()` , `ClearImageTags()` , `SetDefaultTag()` and `FilterImagesByTag()` . ### Improved * [HTML5] Tidied up the Dynamsoft Service installer by removing redundant files. * [HTML5] Unified image decoding capabilities for JPEG and PNG on Windows, macOS and Linux. * [HTML5] Improved the speed of PDF decoding by loading the file as a whole instead of per page. * [HTML5 on Windows] Improved Windows buffer management so that its capacity is only limited by the size of disk space on the machine. * [HTML5 on macOS] Improved macOS installers for better user experience. * [ActiveX] Aligned PDF rasterizer in ActiveX so that it shares the same feature set with the HTML5 edition. ### Fixed * [HTML5] Fixed a bug with the API `CreateTextFont()` where the text takes up extra space when it is rotated by 90 degrees. * [HTML5] Fixed a bug where printing results in unnecessary extra blank pages in Firefox or IE11. * [HTML5] Fixed a bug where a missing filename parameter results in upload failure. * [HTML5 on Windows] Fixed a bug where the library attempts to download an incorrect installer when the Barcode Reader add-on is used. * [HTML5 on Windows] Fixed a bug with the API `GenerateURLForUploadData()` so that it returns an URL that shows the correct SDK version. * [All] Fixed a bug where 8-bit image data can't be compressed as a JPEG-TIFF. * [All] Fixed a bug with the event `OnTopImageInTheViewChanged()` where it doesn't get triggered if images are acquired into an empty buffer. ## `15.1` (08/13/2019) ### New * [macOS] Added 64bit support to macOS. * [macOS & Linux] Expanded the event `OnPostTransferAsync` from Windows to macOS & Linux. The method serves as the asynchronous counterpart to the existing synchronous event `OnPostTransfer` . Information about the transferred image is returned in the event listener. * [macOS & Linux] Expanded the method `startScan()` from Windows to macOS & Linux. The method accepts a JSON object that specifies all the scan parameters. This makes it simpler and even faster to initiate a scan job. At the same time, you can specify how you want the scanned data to be processed by adding extra output parameters in the same JSON object. ### Improved * [Win] Improved the methods `ConvertToBlob()` , `ConvertToBase64()` and image loading methods so that they can handle much bigger files. * [Linux] Improved the image encode/decode functionalities on Linux so that it can encode/decode files just like Windows. * [macOS & Linux] Expanded PDF related capabilities to macOS and Linux so that all 3 platforms share the same features. * [macOS & Linux] Improved the PDF decode engine so that it can load more PDF files without invoking the PDF rasterizer. ### Fixed * [Win] Fixed a bug where some scanners can only scan with document feeder but not the flatbed. ## `15.0` (06/27/2019) ### New * [HTML5 on Windows] Added a new method `startScan()` which accepts a JSON object that specifies all the scan parameters. This makes it simpler and even faster to initiate a scan job. At the same time, you can specify how you want the scanned data to be processed by adding extra output parameters in the same JSON object. * [HTML5 on Windows] Added a new event `OnPostTransferAsync` as the asynchronous counterpart to the existing synchronous event `OnPostTransfer` . Information about the transferred image is returned in the event listener. * [HTML5 on Windows] Added a new PDF core DLL as the default engine for PDF encoding & decoding. This new PDF DLL has added support for JPEG2000 and JBIG2 compression types. * [HTML5 on Windows] Added a new method `PDF.Write.Setup()` which accepts a JSON object that contains all the parameters needed for creating PDF files. * [HTML5 on macOS] Added a new file `libDynamicImg.dylib` to the macOS edition which provides functionalities equal to those provided by the file `DynamicImage.dll` on Windows. Essentially, this file offers better image encoding and decoding. * [HTML5] Added a pair of methods `IndexToImageID()` and `ImageIDToIndex()` which converts the index of an image to its image id or vice versa. The id of an image is an unique number that can be used to specify the image. * [HTML5] Added a new event `OnIndexChangeDragDropDone` which is triggered when you drag and drop images to resort them in the viewer. The event returns the from and to indices for the operation. ### Improved * [HTML5] Improved the method `AcquireImage()` by adding two more options `IfGetImageInfo` & `IfGetExtImageInfo` to its parameter `optionalDeviceConfig` which are `true` by default and means extra image info will be returned with each transferred image. * [HTML5 on Windows] Improved the method `SetFileXferInfo()` so that you can specify a naming pattern for the transferred images when the transfer mode is Disk File. * [HTML5] Improved the performance of Dynamsoft Service by allowing two time-consuming operations to occur concurrently. The affected methods are `ConvertToBlob()` , `ConvertToBase64()` , `GenerateURLForUploadedData()` as well as a few HTTP Upload methods. * [HTML5] Improved service connecting efficiency by removing optional ports and use the same ports no matter it's 64bit service or 32bit. Also, during initialization, JavaScript will attempt to connect to the core scan module directly instead of connecting to the service first. * [HTML5] Improved the functions `ConvertToBase64()`, `ConvertToBlob()`, `GenerateURLForUploadData()` , `HTTPUpload()` , `HTTPUploadAllThroughPostAsMultiPageTIFF()` , `HTTPUploadAllThroughPostAsPDF()` , `HTTPUploadThroughPost()` , `HTTPUploadThroughPostAsMultiPagePDF()` , `HTTPUploadThroughPostAsMultiPageTIFF()` , `HTTPUploadThroughPostEx()` so that the current indices of the images which were operated on in these methods are returned in the callback functions. This is due to the fact that the indices might have changed during these time-consuming operations. ### Changed * [HTML5 on Windows] 64bit service has been made the default option on 64bit machines. ### Fixed * [HTML5 on Windows] Fixed a bug where it takes too much time to load a network file in RDS-mode Chrome. * [HTML5 on Windows] Fixed a bug where an unwanted black line may appear as the right edge of saved TIFF files. ## `14.3.1` (01/15/2019) ### New * [ActiveX] Added method `GetImagePartURL()` to work with the Barcode Reader. * [HTML5] Added a few global settings which may speed up the initialization process of the SDK. The settings are `IfCheckDCP` , `IfCheckDWT` , `IfDisableDefaultSettings` and `IsLicensePromptFriendly` . ### Improved * [HTML5 on Windows] Improved the TIFF compression algorithm when it's set to JPEG so that the resulting file size is significantly reduced. * [ActiveX & HTML5 on Windows] Included the Webcam and Barcode reader libraries in the service installer for easier distribution. * [HTML5] Improved the built-in image viewer to be more responsive when navigating through images. ### Changed * [All Editions] Changed the Hex Code for representing a color from `#BBGGRR` to `#RRGGBB` for all methods that may require a color as one of its parameters. ### Fixed * [HTML5 on Windows] Fixed a bug where the method `LoadImageFromBase64Binary()` may fail to decode a string. * [HTML5 on Windows] Fixed a bug where the service may crash during string conversion. * [File Uploader] Fixed a bug where the upload module may fail to open 4 threads for uploading. ## `14.3` (11/20/2018) ### Improved * [All Editions] Unified the installation prompt for all editions. ### Fixed * [HTML5] Fixed a bug where images to print appear shrunken when rotated. * [HTML5] Fixed a bug where the method `CancelAllUpload()` only cancels one job. * [HTML5] Fixed a bug where OCR Pro Full license gives out an error message when used on the client-side. ## `14.2` (10/16/2018) ### Improved * [All Editions] Simplified the installation process of the SDK by putting multiple installers together. From this version on, you can get the Dynamsoft Service, Dynamic Web TWAIN and its PDF Rasterizer addon installed with one installer. * [HTML5] Improved the method `ConvertToBlob()` so that it can be called multiple times in a row. * [File Uploader] Added a property `FormField` to allow adding extra fields when uploading. ### Fixed * [HTML5] Fixed a bug with the file `DynamicSocket.dll` to avoid service crash. ### Changed * Removed Dynamsoft Camera SDK related files. ## `14.1` (09/06/2018) ### Improved * [ActiveX] Improved the `SelectSource()` method so that it can also be used asynchronously. * [File Uploader] Updated the upload module so that the information returned from the server can be accessed in the callback functions of an upload job. * [File Uploader] Added the version number of the library to the name of the library so that different versions of the library can co-exist. ### Fixed * [HTML5] Fixed a bug with the event `OnInternetTransferPercentage` which doesn't fire when `IfShowCancelDialogWhenImageTransfer` is set to `false` . * [HTML5] Fixed a bug with the image editor where it stops responding after you scan or load new images without saving the currently modified image. * [HTML5] Fixed a bug with the image editor where it no longer adapts to the size change of the browser window after you pressed the scan button in its toolbar. * [HTML5] Fixed a bug that some files would fail to load when you drag and drop multiple TIFF files to load in Dynamic Web TWAIN. * [HTML5] Fixed a bug where loading a file from a path that is composed of Unicode characters would fail. * [HTML5 on Windows] Fixed a bug where the multi-user service doesn't start under the Enhanced Mode. * [HTML5 on macOS] Fixed a bug on macOS where the built-in Select-Source dialog appears to be too wide. * [HTML5 on macOS] Fixed a bug on macOS where `Undefined` shows up as available sources. * [HTML5 on macOS] Fixed a bug on macOS where you can't press Ctrl to select multiple zones on an image. Instead, you need to use the meta Key. ### Changed * [File Uploader] Changed `GenerateURLForUploadData()` to be an asynchronous method. * [File Uploader] Changed the module so that the encrypted files which are in the cache waiting to be uploaded will be cleared when the upload fails or when it is cancelled ## `14.0` (07/17/2018) ### New * [HTML5 on Windows] Added a new upload module to handle upload jobs which can carry out upload jobs behind the scene even after the browser is closed. * [HTML5 on Windows] Added a new API `GenerateURLForUploadData()` to generate a URL which will be used by the upload module to fetch the file/data to upload. * [HTML5 on Windows] Added a 64-bit service, 64-bit scan module, and 64-bit PDF Rasterizer. However, the 32-bit service and modules are still installed by default. * [HTML5 on Windows] Added Enhanced Mode to the service to optimize the performance for environments like Citrix. When enabled, the service can handle multiple client connections much better. * [HTML5] Added a JS-based `SelectSource()` dialog to replace the system's default dialog. * [HTML5] Added a feature to drag and drop one or multiple images in the viewer to rearrange them. * [HTML5] Added a feature to load images when they are dropped onto the viewer from the local disk. When dropping in-between 2 images in the viewer, the new images will be inserted between them, otherwise, the new images will be appended. * [HTML5] Added scan, load, and remove features to the image editor. * [HTML5] Added a configuration `IfCheck64bitServiceFirst` in `dynamsoft.webtwain.config.js` which determines whether the JavaScript library checks the 64-bit Dynamsoft Service first. If 64-bit server is installed, this setting will speed up the initialization of the SDK. The default value is false. * [HTML5] Added a configuration `IfAddMD5InUploadHeader` in `dynamsoft.webtwain.config.js` which determines whether the header `dwt-md5` is added in HTTP posts. The default value is `false` . * [HTML5] Added a configuration `IfConfineMaskWithinTheViewer` in `dynamsoft.webtwain.config.js` which determines whether the mask during SDK initialization or time-consuming operations covers the complete page or just the built-in viewer. The default value is `false` . * [HTML5] Added configurations in `dynamsoft.webtwain.config.js` that enables setting the display language for built-in prompts and image editor, etc. The default language is English. * [HTML5] Added configurations in `dynamsoft.webtwain.config.js` to show/hide certain buttons on the image editor. ### Improved * [All Editions] Rearranged the `/Resources/` folder in the installation directory which contains all the JavaScript library files and files for distribution. Removed the deprecated plug-in completely. * [HTML5 on Windows] Improved the file transfer mode to be able to transfer multiple files in one scan session. * [HTML5 on Windows] Added Unicode support to make it possible to access files which has special characters from non-English languages in its path or name. * [HTML5] When the viewer is set to the view mode of 1 * 1 or -1 * -1, users can now select multiple areas on the image by drawing rectangles while pressing the CTRL button. These selected areas can be moved around too. * [HTML5] Improved the event `OnImageAreaSelected` so that when it's triggered, it will return the 1-based index of the rectangle which represents a selected area on the image. The event is triggered when a new area is selected or a selected area is moved. * [HTML5] The HTML5 license can now be used to restrict the usage of the SDK in certain browsers. * [ActiveX] Updated the license verification module to be compatible with that of the HTML5 edition. ### Changed * [All Editions] Removed intellisense files but still available upon request. * [HTML5 on Windows] The service is now installed with a `.msi` by default instead of a `.exe` . * [HTML5 on macOS] Changed the API `ImageCaptureDriverType` which now is set to 4 by default and the only allowed values are 0 (TWAIN), 3 (ICA) and 4 (TWAIN & ICA). * [HTML5] All the required images in the SDK are hard-coded into JavaScript code. * [HTML5] The non-production server license will now come with a prompt of license notice. * [HTML5] Changed the background color for images when they are selected or when the mouse hovers over one of them. This only works when the view mode is n * n. By comparison, in old versions, the background stays white. * [HTML5] Changed the background color for the image editor. * [HTML5] Changed the theme of the SDK including the progress bar color, waiting spinner, etc. * [HTML5] Changed the events `OnMouseClick` , `OnMouseDoubleClick` and `OnMouseRightClick` to be triggered when the mouse is up. In old versions, they were triggered when the mouse is down. ## `13.4.1` (04/16/2018) ### New * [All Editions] Dynamic Web TWAIN is officially published to NPM. ### Improved * [HTML5 on Windows & Linux] Optimized the scanner module for better compatibility with certain scanner models. * [All Editions] Improved the JS library so that it works better with Angular 5. ## `13.4` (03/12/2018) ### Improved * [HTML5] Optimized the installation process so that users who are not able to download Dynamic Web TWAIN module as a ZIP can now download it as an MSI file to install. ### Changed * Updated the SDK installer to make it possible to download and install other Dynamsoft SDKs together with Dynamic Web TWAIN during the installation process. ### Fixed [HTML5] Fixed a bug where you see the progress bar displayed on the page for no reason when you use Dynamic Web TWAIN with other libraries or frameworks like the popular BootStrap. ## `13.3` (01/16/2018) ### Improved * [Add-on] Replaced the PDF Rasterizer add-on with a new technology which made it possible to use the rasterizer on macOS as well as Linux besides Windows. * [HTML5] Optimized the memory usage by Dynamsoft Service and the JavaScript library so that users can scan and process even more pages. * [HTML5] Optimized the scan module on Linux for better user experience. * [HTML5] Updated the `HTTPUpload***` methods so that they can be used in a for-loop. * [HTML5] Updated the installer of Dynamsoft Service so that Firefox no longer needs to be restarted twice. * [HTML5] Added a new button for the "Erase" feature on the built-in image editor. * [HTML5] Improved the method `OverlayRectangle()` so that the overlays will move with the image. * [HTML5] Improved the method `OverlayRectangle()` so that the image is moved automatically to make sure the newly added overlay is placed in the center of the viewer. This only works when the image is larger than the viewer. * [HTML5] Added a "readme" file in the `/Resources/` folder to explain what each file is for in that folder. ### Changed * [HTML5] Changed the installing process especially for users who need to use the SDK in a domain network. * [ActiveX] Changed the default value for `IfAllowLocalCache` to `true` . ### Fixed * [All Editions] Fixed a bug where the uploaded PDF files might be corrupted if the upload was interrupted during the process due to insufficient physical memory. * [HTML5] Fixed a bug where an error is thrown even after a TIFF file is loaded successfully. * [ActiveX] Fixed a bug where a very big PDF file might fail to be loaded. * [ActiveX] Fixed a bug where IE might crash when saving scanned images to a multi-page PDF or TIFF. ## `13.2` (11/01/2017) * [HTML5] Fixed a memory leak where the scanning service didn't release memory after transferring image data to web browsers. Note: this bug started in version 13.0. * [HTML5] Fixed a bug where sometimes the web twain service didn't get shut down properly * [ActiveX] Fixed a bug where a base64 string ended with "==" could not be decoded by using the `SetCustomDSDataEx()` method * [ActiveX] Fixed a bug where the `Dynamsoft.WebTwainEnv.Load()` method didn't work after calling the `Dynamsoft.WebTwainEnv.Unload()` method * [ActiveX] Fixed a bug where the `TransferMode` property didn't work properly ## `13.1` (08/22/2017) ### New * [HTML5 Only] Added the `ConvertToBlob()` API to return the Blob of specified indices in the designated file type. ### Improved * [HTML5 Only] Improved the `SetHTTPFormField()` API to be able to set Blobs in HTTP Forms aside from strings. * [HTML5 Only] Improved the `HTTPUpload()` API to be able to upload binary data set by `SetHTTPFormField()` . * [HTML5 Only] Improved the `SetHTTPHeader()` API to support `HTTPDownload()` and `HTTPDownloadEx()` methods as well. * [HTML5 Only] Added prefix to all names used in CSS to avoid possible conflict. * [HTML5 Only] Much improved performance for the communication between browsers and the service. ### Fixed * Fixed a bug where you can't initialize the SDK with the method `Dynamsoft.WebTwainEnv.Load()` on the page without first `Dynamsoft.WebTwainEnv.Unload()` it. * Fixed a bug where the `HTTPUpload()` API doesn't work if it's done asynchronously in a loop. * Fixed a bug where you get an error when setting the size of the viewer by percentage. ### NOTICE * The ActiveX edition stays unchanged for this upgrade. ## `13.0` (06/20/2017) ### Improved * [HTML5 Only] Replaced Dynamic Web TWAIN service with the unified Dynamsoft Service. * [HTML5 Only] Replaced the barcode add-on and the webcam add-on with Dynamsoft Barcode Reader SDK and Dynamsoft Camera SDK. * [HTML5 Only] Authorization prompts now support multiple languages. * [HTML5 Only] The method `LoadImageFromBase64Binary()` can now be called asynchronously. * [HTML5 Only] Much improved performance for the communication between browsers and the service. ### Changed * [HTML5 Only] Changed the default behavior of the authorization prompts to "always hide". ### Fixed * Fixed a bug where cropping an image doesn't use the new coordinates when the image has been scrolled. * Fixed a bug where you see an unnecessary error 'TypeMismatchError' when loading a multi-page TIFF/PDF. ### NOTICE * The ActiveX edition stays unchanged for this upgrade. ## `12.3.1` (04/14/2017) * [HTML5 Only] Updated the certificates used by Dynamic Web TWAIN service to handle the incompatibility in IE 10/11 on Windows 7/8/8.1. ## `12.3` (04/06/2017) * [HTML5 Only] Updated the certificates used by Dynamic Web TWAIN service to handle the updates introduced in Chrome 58+. * [HTML5 Only] Updated the key exchange as well as the cipher in Dynamic Web TWAIN service for secure connections. ## `12.2` (01/10/2017) ### Improved * [HTML5 Only] Improved the SSL certificate by updating the signature algorithm to SHA256 * [HTML5 Only] Improved the Web TWAIN service to handle the new certificate ### Fixed * Fixed a bug where scanning might fail if the user doesn't register the event `OnPostTransfer` * Fixed a bug where `Dynamsoft.WebTwainEnv.CreateDWTObject()` still tries to connect to non-SSL ports even when the page is running in HTTPS ## `12.1` (11/03/2016) ### New * Added the Linux Edition to support Firefox and Chrome on 64bit Linux OS. * [HTML5 Only] Added a new method `SetUploadSegment()` which can be used to set the threshold for segmented upload as well as size of each segment. ### Improved * [HTML5 Only] Improved the method `Dynamsoft.WebTwainEnv.CreateDWTObject()` to allow listening on multiple IPs. * [HTML5 Only] Improved the OCR pro license to allow using multiple licenses. * Improved how the SDK works in Edge. Now you can run local pages directly in Edge. ### Fixed * Fixed a bug where `CurrentImageIndexInBuffer` and `HowManyImagesInBuffer` return wrong values in the callback for the event `OnPostLoad` . * Fixed errors with license error messages. * Fixed a bug where an image disappears when you try to get information like resolution or size of the image in the callback for the `OnPostTransfer` event. * Fixed a bug where the 'decoding tiff' dialogue appears when converting PDF files to images. ## `12.0` (09/22/2016) ### New * [HTML5 Only] Added a new method `HTTPUpload()` which supports uploading files as binary as well as base64 string. The method also supports segmented upload when handling big files. * [HTML5 Only] Added a new method `ConvertToBase64()` which supports converting one or more images to a base64 string. * [HTML5 Only] Added a new method `SetHTTPHeader()` which supports adding a header to an HTTP Upload Post request. * [HTML5 Only] Added a new method `GetImageURL()` which returns the direct URL of an image based on its index in the buffer. * Added a new property `IfAutoScroll` which when set to false will stop the automatic scrolling of the viewer when scanning or loading images. * [HTML5 Only] Added a new security feature called Dynamsoft Authentication which requires more user interaction when dealing with local files or devices. * Added MSI installers for both ActiveX and HTML5 editions. ### Improved * Improved the method `ChangeImageSize()` by adding a new mechanism for the new option "Best Quality". * Improved the way license verification is done and optimized the error messages for license issues. * Improved the way a `WebTwain` instance is created by adding global methods like `Dynamsoft.WebTwainEnv.CreateDWTObject()` and `Dynamsoft.WebTwainEnv.DeleteDWTObject()` . * Improved the image editor's zooming feature by allowing it to zoom centered by the position of the mouse. * Improved the way uploading is done by adding a MD5 to every upload Post request. ### Fixed * Fixed a bug where `MagData` doesn't work during scanning. * Fixed a bug with the Mac edition where TIFF files are loaded with inverted colors. * Fixed a bug where the event `OnPostLoad` gets triggered twice when loading a file. * Fixed a bug with the ActiveX where selecting an image area returns the wrong coordinates when the image is bigger than the viewer (scroll bars are shown). * Fixed a bug where `CurrentImageIndexInBuffer` and `HowManyImagesInBuffer` are not updated correctly when the method `LoadImagesFromBase64Binary()` is used. ## `11.3.2` (07/05/2016) ### New * Added the feature to automatically create a dump file for debugging purposes when the scanning service crashes * Added official support for OCR Professional ### Improved * Optimized the scanning performance by reducing unnecessary web socket messages * Optimized the compatibility of the accompanying JS files so that they can work with different versions of scanning services * Added an internal mechanism in the accompanying JS files to support Angular2 * Optimized Mac scanning process to make it possible to switch from TWAIN protocol to ICA protocol ## `11.3` (03/01/2016) ### New * Added `IsTextBasedPDF()` API to the PDF rasterizer to determine whether a PDF is text-based. * Added support for reading binary barcode and returning the result as a base64 string. ### Improved * Updated barcode reader library to v4.1.0.112 which uses improved positioning algorithm that can better identify and locate DataMatrix barcodes. * Improved the event `OnPostLoad` so that it gets triggered for the methods `HTTPDownload(Ex)` , `FTPDownload(Ex)` as well as `LoadImageFromBase64Binary()` . * [HTML5 edition only] Improved the API `AcquireImage()` . Now you can set two callback functions to this method to check its status. ### Fixed * Fixed bugs related to asynchronous APIs such as the bug where the image index is not updated properly for the first and second images. * Fixed a bug where the error message for cancelling the "Open File Dialog" says "fail to open file dialog box". Now it correctly says that "User cancelled the operation". * [HTML5 edition only] Fixed a bug in printing where no matter how you set up, you can only get one copy. * [HTML5 edition only] Fixed a bug where the event `OnSourceUIClose` never gets triggered. * Fixed a few small bugs with the API documentation and Samples within the product installer. * The API `CloseSource()` used to be called automatically after a scanning job is done in v11.2 and a few earlier versions. This has caused issues for a few customers. In this version, this API is no longer called automatically. * We have improved the SDK so that it can also work seamlessly with our OCR add-on. ## `11.2` (11/24/2015) ### New * Added PDF Rasterizer Add-on to convert text PDF files to images. This way, text PDF files can be successfully displayed in the viewer. * Added DataMatrix Reader add-on to read data matrix code from an image. * Added PDF 417 reader add-on to read PDF 417 code from an image. * Added `CloseWorkingProcess()` method to close the current HTML5 scanning process. ### Improved * Improved `Print()` method to support printing images via Windows' native print program. * Improved the upload mechanism to indicate a successful upload if the returned string from server side only contains invisible characters. * Improved the performance of scanning by optimizing the scanning process. ### Fixed * Fixed a bug where scanner source can't be displayed when multiple scanning pages are opened in a browser on Mac. * Fixed a bug where the HTML/JS samples in the product installation folder failed to run locally in Edge browser unless the demos are deployed to an HTTP Server. * Fixed a bug where the return value is incorrect when users click on Cancel button in the Select Source dialog. * Fixed a bug where OnPostLoad event is not triggered when loading a local image via its full file path. * Fixed a bug where scanning log is enabled by default. It could affect the performance of HTML5 scanning. ## `11.1` (09/08/2015) * [HTML5 Edition] Added support for Microsoft Edge browser. * [Windows Edition] Added QR Code Reader Add-on. * [Mac Edition] Added Webcam Addon. * [Mac Edition] Added 1D Barcode Reader Add-on. * [Mac Edition] Added QR Code Reader Add-on. ## `11.0` (07/23/2015) ### New * [Mac Edition] Added HTML5 support for Safari v7+, Chrome v27+ and Firefox v27+ on Mac OS X 10.6 or later. * [HTML5 Edition] Added HTML5 support for Internet Explorer 10 and 11. * Added `SetOpenSourceTimeout()` method to check `ErrorString` property when `SelectSource()` method fails after a specified number of milliseconds. This prevents the scan page from being unresponsive when the selected device is not connected. * [Webcam Add-on] Added `SetVideoRotateMode()` method to rotate the video preview stream. * [HTML5 Edition] Added `OnWebTwainPreExecuteCallback` , `OnWebTwainPostExecuteCallback` events and `ShowCustomMask()` , `HideCustomMask()` methods in `dynamsoft.webtwain.install.js` to display or hide the Dynamsoft's progress overlay during scanning. ### Improved * [Barcode Add-on] Improved 1D Barcode Reader Add-on to support reading CodeBar, Code_93, EAN_8, EAN_13, ITF, UPC_A, UPC_E. * [HTML5 Edition] Improved performance of built-in image viewer when viewing images in 1 * 1 view mode. * [HTML5 Edition] The method Print now supports printing multiple pages. * Improved security by limiting the access of Dynamsoft Scanning Service to registered domain(s) or IP(s) for a particular website. ### Fixed * [HTML5 Edition] Fixed a bug where users are continuously prompt to install Dynamic Web TWAIN on Firefox when accessing a secure website on a different Windows user account. * [ActiveX Edition] Fixed a bug where the system's save-file dialog does not appear when saving images in IE11 on Windows 8.1. * [ActiveX Edition] Fixed a bug where the `DynamicWebTwainCtrl.dll` crashes when `LogLevel` is set to 1 and `HTTPPostResponseString` returns more than 1024 characters. * [ActiveX Edition] Fixed a bug where the remote file URL gets truncated if it is too long when uploading or downloading. * Fixed a bug where the method `SetHTTPFormField()` does not work as expected. * [HTML5 Edition] Fixed a bug where 'Upload Error' is returned when image uploading is cancelled. * Fixed a bug where the method `SetTiffCustomTag()` does not work. * [All Editions for Windows] Fixed a bug where the method `CapIfSupported()` does not return support level of specified capability. ## `10.2` (03/24/2015) ### New * [All Editions for Windows] Added Webcam Add-on to support image capturing from Webcams using Microsoft DirectShow API. The related APIs are: + `Addon.Webcam.CaptureImage()` + `Addon.Webcam.CloseSource()` + `Addon.Webcam.Download()` + `Addon.Webcam.GetCameraControlMoreSetting()` + `Addon.Webcam.GetCameraControlSetting()` + `Addon.Webcam.GetFrameRate()` + `Addon.Webcam.GetMediaType()` + `Addon.Webcam.GetResolution()` + `Addon.Webcam.GetSourceList()` + `Addon.Webcam.GetVideoPropertyMoreSetting()` + `Addon.Webcam.GetVideoPropertySetting()` + `Addon.Webcam.SelectSource()` + `Addon.Webcam.SetCameraControlPropertySetting()` + `Addon.Webcam.SetFrameRate()` + `Addon.Webcam.SetMediaType()` + `Addon.Webcam.SetResolution()` + `Addon.Webcam.SetVideoPropertySetting()` * [HTML5 Edition] Added the view mode n*-1 to allow horizontal thumbnails. * [HTML5 Edition] Added the property `ShowPageNumber` to allow hiding or showing of the number labels at the top-left corner of the images in the viewer. ### Improved * [HTML5 Edition] Greatly improved the performance of the built-in image viewer and editor by rewriting it. * [HTML5 Edition] Reduced CPU/Memory consumption when handling very big images. * Improved the property `Height` and `Width` to allow the use of percentages * [HTML5 Edition] Improved performance when navigating through images quickly using the built-in image editor * [HTML5 Edition] Improved security by limiting the web server to listen to 'localhost' only. * Improved IntelliSense by separating the original document into different modules. * Improved error message management by separating the add-on related messages. * Improved the property `MaxUploadImageSize` by providing a clear error message. * [HTML5 Edition] Methods which returns a Boolean value now returns `true` or `false` instead of `1` , or `0` . * Separated the old Plug-in edition from the HTML5 edition for easier deployment and better performance. The previous Chrome&Firefox Edition is now divided into 2 editions: Plugin Edition and HTML5 Edition. * `IfShowFileDialog` and `IfDisableSourceAfterAcquire` are set to `true` by default in the JS Client. ### Fixed * Fixed the bug in the Barcode Reader add-on where barcode location fails for 200 DPI. * [HTML5 Edition] Fixed the bug where the event `OnImageAreaSelected` is triggered when the mouse enters or leaves the image editor. * [HTML5 Edition] Fixed the bug where the event `OnImageAreaSelected` is triggered multiple times when selecting the area in the image editor. * [HTML5 Edition] Fixed the bug where the initialization of the SDK fails if `Dynamsoft.WebTwainEnv.Load()` is called more than once. * [HTML5 Edition] Fixed the bug where the SDK sends unnecessary WebSocket requests when loading images. * Fixed the bug with the method `ChangeBitDepth()` where the processed image appears to be covered in a grey mask. * Fixed the bug with the method `ConvertToGrayScale()` where calling this method on a 1-bit image turns it black. * Fixed the bug with the methods `SaveAsTIFF()` and `SaveAsPDF()` where the progress bar doesn't show. * Fixed the bug with image uploading when 'successful' is returned when it's actually cancelled. * Fixed a few unclear or wrong error messages. ## `10.1.1` (12/23/2014) ### New * Added `Dynamsoft.WebTwainEnv.AutoLoad` property to enable or disable automatic loading of Dynamic Web TWAIN. * Added dynamic loading and unloading methods `Dynamsoft.WebTwainEnv.Load()` and `Dynamsoft.WebTwainEnv.Unload()` . ### Improved * Improved the initiation process for Dynamic Web TWAIN so that you don't need to worry about the order of `dynamsoft.webtwain.initiate.js` and `dynamsoft.webtwain.config.js` . ### Fixed * Fixed a bug where the event `OnImageAreaSelected` gets fired multiple times when you draw a rectangle on the image. ## `10.1` (12/16/2014) Dynamsoft's Dynamic Web TWAIN V10.1 SDK Upgrades Include JavaScript IntelliSense, 1D Barcoding. ### New * Added 1D Barcode Reader Add-on to support reading Code39 and Code128. * Added JavaScript IntelliSense to help you write code faster and with fewer errors. You can use IntelliSense in Visual Studio 2010 or above and Eclipse 4.2 or above. * Added `BufferMemoryLimit` property to set how much physical memory is allowed for storing images. Once the limit is reached, images will be cached on the hard disk. Cached image data will be automatically deleted when the scan page is closed. * Added enumerated constants to make your code more readable. ### Improved * Greatly improved user experience by providing well-arranged API document and simplifying all sample code. * Dynamic Web TWAIN v10.1 now supports Internet Explorer (IE) 6 and 7. In v10.0 and v10.0.1, IE 6 and 7 were not supported. * The improvements below are specifically for Chrome&Firefox Edition - which uses HTML5 WebSocket. + Optimized memory usage to handle more scanned images, + Added support for cropping an image when the image viewer is set to 1 x 1 view mode, + Improved page size setting of the `Print()` method, + Supported `SetSelectedImageArea()` method and `OverlayRectangle()` method. ### Fixed * Fixed a bug where the property `TIFFCompressionType` does not work properly. * Fixed a bug where clipboard related APIs did not work in the HTML5 version. * Fixed a bug where uploading images in a loop did not work in the HTML5 version. ## `10.0.1` (10/16/2014) Dynamsoft's Dynamic Web TWAIN V10.0.1 SDK introduced improvements to the Chrome & Firefox Edition. The ActiveX and Mac Editions remained the same (these components remain as v10.0). ### New * Enhanced robustness of WebSocket connection: The new version will automatically try re-building the connection in case it is inadvertently closed due to network problems. * Better support for Chrome 38, such as downloading large files using the `HttpDownload()` method. ### Improved * When a user visits the scan page for the first time the new version takes 1~2 seconds to detect whether the client-side browser has Dynamic Web TWAIN installed. With v10.0, it took around 7 seconds before the installation prompt. * With the file updated to `dynamsoft.webtwain.config.js` you can freely move the Resources folder to any directory you like. * More detailed log files. ### Fixed In v10.0.1 there is no limit to the size of an Http Request. In v10.0, the WebSocket connection could have failed to be built if the size of Http Header exceeds 1kB, which led to a recurring prompt for installation. * Fixed a bug where the browser crashed if the WebSocket was closed during the upload process. * Fixed a bug where a time-out error might occur during uploading of a big file. * Fixed a bug where the property settings on `TIFFCompressionType` does not work. * Fixed the bug where the method `FTPDownloadDirectly()` does not work. * Fixed the bug where the method `FTPUploadDirectly()` does not work using "\\" in path parameters. * The responses from the server after upload are now wholly put into the property `HTTPPostResponseString` . With previous versions, the responses would be trimmed if longer than 1024 KB. ## `10.0` (09/16/2014) - Based on 10.0 Preview ### New * Added HTML5 Image Viewer to the Chrome&Firefox Edition. * Added progress bar when loading, saving, uploading & downloading multiple images. ### Improved * Faster and more stable image acquisition. * Improved samples in the installer. ### Fixed * Fixed the bug where image acquisition service sometimes stops during multiple operations. * Fixed the bug where `HTTPDownloadDirectly()` fail to download files. * Fixed the bug where some scanning settings don't work for some models of Neat scanners. ## `10.0 Preview` (08/21/2014) * New HTML5 WebSocket SDK to enable TWAIN scanning in Chrome and Firefox 27+ on Windows. * Added Disk Caching mechanism. This feature enables high volume document scanning which was limited by the physical memory size. * Added JPEG compression type to TIFF encoding/decoding. You can reduce the size of TIFF files significantly by using the JPEG compression. * Much improved image editing features like `ChangeBitDepth()` , `GrayScale()` , etc. ## `9.3 Preview` (06/10/2014) * New HTML5 WebSocket SDK to enable TWAIN scanning in post-NPAPI Chrome. The new SDK will be added to the Plugin Edition of Dynamic Web TWAIN. ## `9.2` (01/02/2014) * Fully support Internet Explorer 11. * Added `RegisterEvent()` method and `UnregisterEvent()` method for using Dynamic Web TWAIN events in IE 11 and other web browsers(e.g. Chrome, Firefox, Safari and Opera). ## `9.1` (08/27/2013) * Added native scanning support for Mac Edition. * The new property - `ImageCaptureDriverType` - allows Mac users to directly acquire images via native scan(without installing a TWAIN driver). * Improved IE users' experience when using a separate process(i.e. `BrokerProcessType` = 1) for document scanning. In v9.0, IE users might need to manually allow the broker process to run. It is now automated with the enhanced security of the ActiveX edition. * Fixed bug where `OnPostTransfer` event is not triggered in some cases. ## `9.0` (03/26/2013) * Simplified installation and deployment process. * For developers: no need to generate a LPK file to verify the license. The `ProductKey` property is available to set a series of alphanumeric code for license verification at runtime. Developers only need to generate a product key with Licensing Manager which is installed with Dynamic Web TWAIN. * For end users: no need to install/enable Microsoft Licensed Class Manager. It would be much easier for end users to activate the control. * Added a new feature to acquire images in an independent process which greatly improves the robustness of the application. * Added `MaxInternetTransferThreads` property to set the maximum number of threads for uploading /downloading files through POST. This can dramatically improve the performance. * Added `FileExists()` method to check if a certain file exists on the local disk. * Added `GetSkewAngle()` / `GetSkewAngleEx()` (Mac edition not supported) property to get the skew angle of an image by its index in buffer. ## `8.0.1` (09/04/2012) * New Events and Improvements: + `OnSourceUIClose()` : triggered when the user interface of source is closed. + `OnBitmapChanged()` : triggered when the bitmap of image buffer is changed, such as new image scanned, image deleted or image edited etc. * Improved `LoadDibFromClipboard()` method. You can now load images in clipboard of Windows Vista or above into Dynamic Web TWAIN. * Improved the performance of the `IsBlankImage()` and `IsBlankImageEx()` methods for detecting blank images. * Fixed bug where the original DPI (dots per inch) got lost when saving images using the 64-bit ActiveX Edition. ## `8.0` (07/17/2012) * Added new add-on: Barcode(1D) - supports 1D barcode recognition. * Added new add-on: Barcode(2D) - supports 2D barcode recognition. * Added new add-on: OCR(Optical Character Recognition) - performs OCR on documents in different languages and converts them to searchable text and PDFs. * Added `GetImageXResolution()` and `GetImageYResolution()` methods to get the resolution from the scanned image(s). * Added `SetDPI()` method to Change the DPI(dots per inch) for the specified image. * Added `ShowFileDialog()` method and `OnGetFilePath` event to show the "save file dialog"/"open file dialog" and get the path. * Added `AllowPluginAuthentication` property to allow the plugin to send authentication requests. * Added `BlankImageCurrentStdDev` property to return the current standard deviation of the pixels in the image. * Added `MagData` and `MagType` properties to read magnetic data from scanners. ## `7.0` (03/06/2012) * Improved the image decoder for ActiveX x86 edition. Dynamic Web TWAIN will use GDI+ to decode the image if gdiplus.dll is available in the operating system. * Added the support for simple annotation. Now you can add a text on the image. * Added `FTPUploadDirectly()`, `HTTPUploadThroughPostDirectly()` and `HTTPUploadThroughPutDirectly()` methods to upload all types of local files without encoding/decoding. * Added `HTTPDownloadDirectly()` and `FTPDownloadDirectly()` methods to download files to local without encoding/decoding. * Improved the performance of image rotate method. * Standardized the naming convention for the properties and methods in ActiveX edition. * Modified the default value of `MaxImagesInBuffer` to 64. * Added `GetDeviceType()` method to determine the type of the image acquisition device. * Added `PDFVersion` property to read/write the PDF version. * Added `IfScanInNewThread` property to allow Dynamic Web TWAIN to communicate with scanner in a separate thread. * Added `ImageEditorIfModal` property to set whether the image editor runs in modal state. * Added `CapValueType` property to return or set the type of the `CapValue` . * Added `IfAutomaticBorderDetection` property to encapsulate the `ICAP_AUTOMATICBORDERDETECTION` capability. * Added `IfAutomaticDeskew` property to encapsulate the `ICAP_AUTOMATICDESKEW` capability. * Added `IfAutoDiscardBlankpages` property to encapsulate the `ICAP_AUTODISCARDBLANKPAGES` capability. * Improved `IfDeviceOnline` property. Now `TW_ENUMERATION` type of the return result is supported. ## `6.4` (11/15/2011) * Mac Edition added. Compatible with browsers including Safari, Firefox, Chrome and Opera on Mac OS X 10.5 or later.(PPC not supported). * Mac Edition supports TWAIN Specification 1.9. A TWAIN driver for Mac is required to use a scanner with the plug-in. * Mac Edition supports loading all PDF, PSD and TGA formats. * Mac Edition supports loading images with JPEG2000 compression. ## `6.3.1` (09/01/2011) * Improved the memory management for ActiveX 64-bit Edition. * Added `LogLevel` property to capture more exceptions. * Changed the "Thank you for evaluating ..." dialog box to non-modal dialog.(For Plug-in edition only). ## `6.3` (06/14/2011) * Support both 32-bit and 64-bit TWAIN device drivers(ActiveX Edition only). * Support both 32-bit and 64-bit Internet Explorer(ActiveX Edition). * Support Firefox 4. * Added the `OnPostLoad` event which is triggered after executing `LoadImage()` / `LoadImageEx()` . * Optimized the `LoadDibFromClipboard()` method. * Optimized image editor. ## `6.2` (03/15/2011) * Support TWAIN Specification 2.1. * Further improved the security: + Compatible with Data Execution Prevention(DEP) and Protected Mode. + Added Windows Authentication and Basic Authentication support for Plug-in Edition. + Allow you to install the ActiveX control to your personal folder. * Easier and faster image processing: + Added `IfShowFileDialog` property to show the browse dialog box when loading and saving images. + Optimized the blank page detection. Added `IsBlankImageEx()` method to detect whether a certain area on an image is blank. * Added `SaveSelectedImagesToBase64Binary()` to save selected images to base64 binary. * Added `LoadImageFromBase64Binary()` to load images from a base64 byte array. * Added support for fitting the selected image to the width or height of the window with the property `FitWindowType` . * Added support for getting general info of a scanned image including image width/height and bit depth with the methods `GetImageBitDepth()` , `GetImageWidth()` and `GetImageHeight()` . * Further improved the print feature with the property `IfShowPrintUI` to set whether to display the user interface of the printer. * Support more models of Canon scanners. ## `6.1` (08/31/2010) * Simplified installation process for Chrome, Safari, Opera users. * Support simple Annotation. * Support Forms Authentication. * Support certificate binding. * Added session/cookie support for Plug-in Edition. * Added removing selected images. * `MaxImagesInBuffer` : In both the trial and full versions of Dynamic Web TWAIN, the maximum value you can set to the property has been raised from 1024 to 4096. * Added methods: `SetCookie()` , `BindSSLCert()` , `BindSSLCertEx()`, `OverlayRectangle()` , `RemoveAllSelectedImages()` . * Added properties: `MouseX` , `MouseY` . ## `6.0` (05/18/2010) * Firefox 3.6 supported. * Chrome, Opera, Safari on Windows supported(Plug-in Edition). * Added barcode detection. * Added multiple images selection. * Added saving images to a byte array. * Added loading an image from a byte array. * Added uploading multiple images as a multi-page PDF/TIFF file. * Support setting board color for selected images. * Support FTP passive mode. * Support specifying the field name when uploading through HTTP POST. * Added rotating the image of a specified index in buffer by a specified angle. * Added cutting the image data in the specified area to the system clipboard in DIB format. * Added clearing the specified area of an image and filling the area with a color. * `MaxImagesInBuffer` : In the trial version of Dynamic Web TWAIN, the maximum value you can set to the property has been raised from 4 to 1024. * Optimized `HTTPPostResponseString` in Plug-in Edition: You can use `HTTPPostResponseString` property to get much more detailed info returned from the web server. * Added methods: `CutFrameToClipboard()`, `Erase()` , `FTPUploadSelectedImagesAsMultiPagePDF()` , `FTPUploadSelectedImagesAsMultiPageTIFF()` , `GetBarcodeInfo()` , `GetBarcodeText()` , `HTTPUploadSelectedImagesThroughPostAsMultiPagePDF()` , `HTTPUploadSelectedImagesThroughPostAsMultiPageTIFF()` , `HTTPUploadSelectedImagesThroughPutAsMultiPagePDF()` , `HTTPUploadSelectedImagesThroughPutAsMultiPageTIFF()` , `LoadImageFromBytes()` , `MoveImage()`, `Print()`, `Rotate()` , `SaveSelectedImagesAsMultiPagePDF()` , `SaveSelectedImagesAsMultiPageTIFF()` , `SaveSelectedImagesToBytes()`, `GetSelectedImagesSize()` . * Added properties: `AllowMultiSelect`, `BackgroundColor` , `BackgroundFillColor` , `BarcodeCount` , `HttpFieldNameOfUploadedImage` , `IfPASVMode` , `SelectedImageIndex`, `SelectedImagesCount`, `SelectionImageBorderColor` , `VScrollBar` . * Added event: `OnInternetTransferPercentageEx` ## `5.2` (07/14/2009) * Added Windows authentication support(ActiveX edition only). * Fixed session bug. * Improved TIFF and PDF support. * Added blank page detection. * Added zoom in/zoom out features. * Added a new feature in `ShowImageEditor()` : If the `IfFitWindow` property is set to `true` , the image will fit the size of window when the Image Editor prompts; otherwise the image will be displayed in its full size. * Added method: `IsBlankImage()` . * Added properties: `BlankImageMaxStdDev` , `BlankImageThreshold` , `Zoom` , `EnableInteractiveZoom` . * Added capability: `ICAP_EXTIMAGEINFO` . ## `5.1.1` (09/09/2008) * Optimized distribution of Dynamic Web TWAIN Plug-in Edition for Firefox 3. You can now install Dynamic Web TWAIN automatically in Firefox 3. * Fixed issue that the action page is called twice when uploading image data by using HTTP POST method. * The specified image displayed when this image is set as the current image by using the `CurrentImageIndexInBuffer` property. ## `5.1` (05/27/2008) * Cookie session integration support added(ActiveX edition only). * Insert and switch features added. You can now insert new scanned images before the current image and switch the positions of two images in buffer. * More user interaction features added. One more view mode(-1 by -1) is added and scroll bars will be shown if necessary. Also, you can now drag the image to adjust its position in the control or select an area on the control directly. * More mouse events added. Events will be fired when you double click the mouse, right click the mouse, select an area on the control and so on. * New feature added in `SetViewMode()` : when the view mode is set to -1 by -1, Dynamic Web TWAIN only shows the current image. No scroll bar is provided to navigate to other images. * New feature added in `IfFitWindow` : when the value of this property is `false` , the image will be displayed in its full size and scroll bars will be shown if necessary(the width or height of the image is bigger than the control size). * New feature added in `MouseShape` : when the value of this property is set to `true` , the cursor is set as a hand. If the width or height of the image is bigger than the control size, scroll bars will be shown and you can drag the image to adjust its position in the control. When the value of the property is set to `false` , the cursor is set as an arrow. You can select an area on the control directly. * Added methods: `GetImageSizeWithSpecifiedType()` , `SwitchImage()` . * Added property: `IfAppendImage` . * Added events: `OnMouseDoubleClick`, `OnMouseRightClick`, `OnImageAreaSelected` , `OnImageAreaDeSelected` , `OnTopImageInTheViewChanged` . ## `5.0.1` (12/04/2007) * Optimized PDF encoder and decoder. * Detail error message returned when uploading images through POST method fails. * Fixed bugs. ## `5.0` (10/19/2007) * PDF and multi-page PDF support added. You can now save the scanned document to local disk or upload to web server in PDF format. * HTML form manipulation support added. You can now add fields to the HTML form to have additional information for web server before uploading the scanned images to the web server. * Image preview mode added. You can view the scanned images in the preview mode, like 1 by 2, 2 by 2. This feature helps you have better overview of your images when you have multi-page document. * Image upload progress bar and cancel option added. You can use the built-in progress bar or your own progress bar for the upload. Cancel option is also provided. * Download from HTTP stream support added. You do not need to create temp files at server side for download. * More user interaction features added. Several mouse events are added. * Added methods: `SetViewMode()` , `GetViewMode()`, `SaveAsPDF()` , `SaveAllAsPDF()` , `FTPUploadAllAsPDF()` , `HTTPUploadAllThroughPostAsPDF()` , `HTTPUploadAllThroughPutAsPDF()`, `LoadImageEx()` , `FTPDownloadEx()` , `FTPUploadEx()`, `HTTPDownloadEx()` , `HTTPUploadThroughPostEx()` , `HTTPUploadThroughPutEx()`, `SetHTTPFormField()` , `ClearAllHTTPFormFiled()` . * Added properties: `ImageMargin`, `MouseShape` , `PDFCompressionType` , `PDFAuthor` , `PDFCreationDate` , `PDFCreator` , `PDFKeywords` , `PDFModifiedDate` , `PDFProducer` , `PDFSubject` , `PDFTitle`, `IfShowCancelDialogWhenImageTransfer` . * Added events: `OnMouseClick` , `OnMouseMove`, `OnInternetTransferPercentage` . ## `4.2.1` (04/28/2006) * Fixed bug where uploading or downloading images via SSL connection fails sometimes. * `IfSSL` property added. ## `4.2` (11/02/2005) * Dynamic Web TWAIN ActiveX is digitally signed by VeriSign. ## `4.1` (09/08/2005) * Image Editor added which can be used for image editing and viewing. Supports basic image editing features including Rotate, Crop, Mirror, Flip and ChangeImageSize. * Related methods: `RotateLeft()`, `RotateRight()`, `Mirror()`, `Crop()` , `CropToClipboard()` , `GetImageSize()` , `ChangeImageSize()`, `ShowImageEditor()` . * Related properties: `ImageEditorWindowTitle` , `ImageEditorIfReadonly` , `ImageEditorIfEnableEnumerator` . * Other methods added: `LoadDibFromClipboard()` , `GetDefaultImageLayout()` , `GetImageLayout()` , `ResetImageLayout()` , `SetImageLayout()` . ## `4.0` (05/31/2005) * Plug-In Edition added. Compatible with Netscape, Mozilla, FireFox and other Gecko-based browsers. * PNG supported. * RLE, G3, G4, LZW, PackBits TIFF compression supported. * Local multi-image buffer added: you can view and manage multiple acquired images locally before uploading them to web server. * Multi-page TIFF upload/download supported. * Added methods: `SaveAllAsMultiPageTIFF()` , `SaveAsPNG()` , `RemoveAllImages()` , `RemoveImage(),` `FTPUpload()` , `FTPDownload()` , `HTTPUploadThroughPost()` , `HTTPUploadThroughPut()`, `HTTPDownload()` , `FTPUploadAllAsMultiPageTIFF()` , `HTTPUploadAllThroughPostAsMultiPageTIFF()` , `HTTPUploadAllThroughPutAsMultiPageTIFF()` * Added properties: `MaxImagesInBuffer`, `HowManyImagesInBuffer`, `CurrentImageIndexInBuffer`, `TIFFCompressionType`, `IfFitWindow` . * `SaveAsBMP()` , `SaveAsJPEG()` and `SaveAsTIFF()` methods modified. They now save images of specified indexes in buffer. * `CopyToClipboard()` method modified. It copies the image of a specified index in buffer. * `CutToClipboard()` method modified. It cuts the image of a specified index in buffer. * The behavior of `hDib` property changed. It returns the Handle of the DIB of a specified index in buffer. * The behavior of `Picture` property changed. It returns the `Picture` object of the image of a specified index in buffer. * `FTPUploadAsBMP()` , `FTPUploadAsJPEG()` , `FTPUploadAsTIFF()` methods replaced by `FTPUpload()` method. * `FTPDownloadBMP()` and `FTPDownloadJPEG()` methods replaced by `FTPDownload()` method. * `HTTPUploadAsBMPThroughPost()` , `HTTPUploadAsJPEGThroughPost()` and `HTTPUploadAsTIFFThroughPost()` methods replaced by `HTTPUploadThroughPost()` method. * `HTTPUploadAsBMPThroughPut()` , `HTTPUploadAsJPEGThroughPut()` and `HTTPUploadAsTIFFThroughPut()` methods replaced by `HTTPUploadThroughPut()` method. * `HTTPDownloadBMP()` and `HTTPDownloadJPEG()` methods replaced by `HTTPDownload()` method. * `LoadBMP()` and `LoadJPEG()` methods replaced by `LoadImage()` method. ## `3.0.3` (03/15/2005) * `HTTPPostResponseString` property added. Response string from the HTTP server will be available in `HTTPPostResponseString` property if an error occurs for `HTTPUploadAsBMPThroughPost()` , `HTTPUploadAsJPEGThroughPost()` and `HTTPUploadAsTIFFThroughPost()` methods. ## `3.0.2` (03/07/2005) * `HTTPUploadAsBMPThroughPost()` , `HTTPUploadAsJPEGThroughPost()` and `HTTPUploadAsTIFFThroughPost()` methods memory access violation bug fixed. ## `3.0` (01/18/2005) * One page and multi-page Tiff supported. * HTTP Upload now supports HTTP Post command. * Many high level properties and methods added. * Method `EnableSource(Boolean IfShowUI)` changed to `EnableSource()` , method `HTTPUploadAsBMP()` changed to `HTTPUploadAsBMPThroughPut()` , method `HTTPUploadAsJPEG()` changed to `HTTPUploadAsJPEGThroughPut()` . * Added methods: `FeedPage()` , `FTPUploadAsTIFF()` , `RewindPage()`, `HTTPUploadAsBMPThroughPost()` , `HTTPUploadAsJPEGThroughPost()`, `HTTPUploadAsTIFFThroughPost()`, `HTTPUploadAsTIFFThroughPut()`, `SaveAsTIFF()` . * Added properties: `BitDepth` , `Brightness` , `Contrast` , `DataSourceStatus` , `Duplex` , `IfAutoBright` , `IfAutoFeed` , `IfAutoScan`, `IfDeviceOnline`, `IfDisableSourceAfterAcquire` , `IfDuplexEnabled` , `IfFeederEnabled` , `IfModalUI` , `IfPaperDetectable` , `IfShowIndicator` , `IfShowUI` , `IfThrowException` , `IfTiffMultiPage` , `IfUIControllable` , `PageSize` , `PixelFlavor` , `PixelType` , `Resolution` , `Unit` , `XferCount` ## `2.0.1` (12/21/2004) * `HTTPUploadAsJPEG()` and `HTTPUploadAsBMP()` modified to accommodate the new behavior of the IIS of Windows 2003 Server. ## `2.0` (06/01/2004) * The online demo is available. * Supports uploading and downloading through HTTP. * Supports proxy. * Built-In JPEG codec. * Supports Buffered Memory image transfer mode. * Supports Disk File image transfer mode. * Totally rewritten with pure Windows API and assembly language. * Built-In TWAIN session wizard. * `CapSetFrame()`, `CapGetFrameLeft()`, `CapGetFrameTop()`, `CapGetFrameRight()`, `CapGetFrameBottom()` added for the negotiation of `ICAP_FRAMES` capability. * `OnPreAllTransfers` , `OnPostAllTransfers` , `OnTransferCancelled` , `OnTransferError` events added. ## `1.0.2` (03/15/2004) * `BorderStyle` property added. ## `1.0.1` (11/15/2003) * `hDIB` property added. * `Picture` property can work properly. ## `1.0` (08/20/2003) * TWAIN specification 1.9 compatible. * Supports Native image transfer mode. * Supports uploading and downloading image through FTP. --- title: Dynamic Web TWAIN SDK Schedule - Beta Release description: Dynamic Web TWAIN SDK Documentation Schedule - Beta Release Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/schedule/beta.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/schedule/beta.md --- # Beta Releases - test branch Currently there is no beta release available. --- title: Dynamic Web TWAIN SDK Schedule - Known Bugs description: Dynamic Web TWAIN SDK Documentation Schedule Known Bugs Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/schedule/bugs.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/schedule/bugs.md --- # Known Bugs --- title: Dynamic Web TWAIN SDK Schedule - Deprecated Features description: Dynamic Web TWAIN SDK Documentation Deprecated Features Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/schedule/deprecated.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/schedule/deprecated.md --- # All Deprecated Features & APIs > [!NOTE] > All deprecated APIs are considered unsupported as of the version they are deprecated. They may be removed at any time with no further notice. ## 19.3 Deprecated Method: DWTObject.Print ## 19.0 ### Global * Deprecated Property: Dynamsoft.DWT.IfUseActiveXForIE10Plus ### Util * Deprecated Method: DWTObject.isUsingActiveX ## 18.4 ### PDF Rasterizer > [Alternative] Use the [SetReaderOptions()](/_articles/info/api/Addon_PDF.md#setreaderoptions) and [GetReaderOptions()](/_articles/info/api/Addon_PDF.md#getreaderoptions) functions instead. * GetConvertMode() * SetConvertMode() * SetPassword() * SetResolution() Deprecate the enum value CM_RENDERALLWITHANNOTATION from [`Dynamsoft.DWT.EnumDWT_ConvertMode`](/_articles/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_convertmode). ### Viewer > This API has been deprecated as of release 18.4. Please use the [`updateSelectionBoxStyle()`](/_articles/info/api/WebTwain_Viewer.md#updateselectionboxstyle) function. * selectedAreaBorderColor ## 18.2 ### Global * Dynamsoft.DWT.GetWebTwainEx() ## 18.1 The WASM edition (camera add-on) is removed from Web TWAIN. The following API is deprecated: `UseLocalService`. ## 18.0 ### Dynamic Web TWAIN > [Alternative] Use [Dynamsoft.DWT.ProductKey](/_articles/info/api/Dynamsoft_WebTwainEnv.md#productkey) instead. * Dynamsoft.DWT.licenseServer * Dynamsoft.DWT.sessionPassword * Dynamsoft.DWT.organizationID * Dynamsoft.DWT.handshakeCode ### Util * Deprecated Method: DWTObject.SetProductKeyAsync * Deprecated Property: DWTObject.ProductKey ### Scan * Deprecated Method: DWTObject.GetDeviceType ## 17.3 ### Dynamic Web TWAIN * Deleted property: Dynamsoft.DWT.UseDefaultInstallUI ### Viewer > [Alternative] Use [updateCheckboxStyle](/_articles/info/api/WebTwain_Viewer.md#updatecheckboxstyle) and [updatePageNumberStyle](/_articles/info/api/WebTwain_Viewer.md#updatepagenumberstyle) instead. * Viewer.showPageNumber * Viewer.showCheckbox * thumbnailViewer.showCheckbox * thumbnailViewer.showPageNumber ### Camera Add-On > [Alternative] Use [Mobile Document Scanner](https://www.dynamsoft.com/use-cases/mobile-document-scanner/) instead. * Camera.showVideo() ### OCR Add-On OCR Basic and OCR Pro client-side are deprecated. ## 17.0 ### Viewer * New APIs in v17.0 replace old APIs in v16.2-, all old APIs are deprecated. | v17.0 | v16.2- | |:-|:-| | [ `Viewer.autoChangeIndex` ](/_articles/info/api/WebTwain_Viewer.md#autochangeindex) | `Viewer.topPageChanged()` | * The following APIs are new in v17.0 + [ `RemoveTag` ](/_articles/info/api/WebTwain_Buffer.md#removetag) + [ `GetTagList` ](/_articles/info/api/WebTwain_Buffer.md#gettaglist) + `DWT.licenseServer` + `DWT.handshakeCode` + `DWT.sessionPassword` + `DWT.licenseException` ## 16.2 * Internet Explorer 8 is no longer supported. ### Camera Add-On * New APIs in v16.2 replace old APIs in v16.1-, all old APIs are deleted. | v16.2 | v16.1- | |:-|:-| | [ `Addon.Camera.showVideo()` ](/_articles/info/api/Addon_Camera.md#showvideo) | `Viewer.showVideo()` | | [ `Addon.Camera.closeVideo()` ](/_articles/info/api/Addon_Camera.md#closevideo) | `Viewer.closeVideo()` | | [ `Addon.Camera.off()` ](/_articles/info/api/Addon_Camera.md#off) | `Viewer.off()` | | [ `Addon.Camera.on("video-closed")` ](/_articles/info/api/Addon_Camera.md#video-closed) | `Viewer.on("video-closed")` | | [ `Addon.Camera.on("video-error")` ](/_articles/info/api/Addon_Camera.md#video-error) | `Viewer.on("video-error")` | ### Viewer * New APIs in v16.2 replace old APIs in v16.1-, all old APIs are deprecated. | v16.2 | v16.1- | |:-|:-| | [ `Viewer.background` ](/_articles/info/api/WebTwain_Viewer.md#background) | `BackgroundColor` | | [ `Viewer.bind()` ](/_articles/info/api/WebTwain_Viewer.md#bind) , [ `Viewer.show()` ](/_articles/info/api/WebTwain_Viewer.md#show) , [ `Viewer.hide()` ](/_articles/info/api/WebTwain_Viewer.md#hide) | `BindViewer()` | | [ `Viewer.cursor` ](/_articles/info/api/WebTwain_Viewer.md#cursor) | `MouseShape` | | [ `Viewer.fitWindow()` ](/_articles/info/api/WebTwain_Viewer.md#fitwindow) | `FitWindowType` , `IfFitWindow` | | [ `Viewer.height` ](/_articles/info/api/WebTwain_Viewer.md#height) | `Height` | | [ `Viewer.ifAutoScroll` ](/_articles/info/api/WebTwain_Viewer.md#ifautoscroll) | `IfAutoScroll` | | [ `Viewer.on("click", callback)` ](/_articles/info/api/WebTwain_Viewer.md#click) | `RegisterEvent("OnMouseClick", callback)` | | [ `Viewer.on("contextmenu", callback)` ](/_articles/info/api/WebTwain_Viewer.md#contextmenu) | `RegisterEvent("OnMouseRightClick", callback)` | | [ `Viewer.on("dblclick", callback)` ](/_articles/info/api/WebTwain_Viewer.md#dblclick) | `RegisterEvent("OnMouseDoubleClick", callback)` | | [ `Viewer.on("mousemove", callback)` ](/_articles/info/api/WebTwain_Viewer.md#mousemove) | `RegisterEvent("OnMouseMove", callback)` | | [ `Viewer.on("pageAreaSelected", callback)` ](/_articles/info/api/WebTwain_Viewer.md#pageareaselected) | `RegisterEvent("OnImageAreaSelected", callback)` | | [ `Viewer.on("pageAreaUnselected", callback)` ](/_articles/info/api/WebTwain_Viewer.md#pageareaunselected) | `RegisterEvent("OnImageAreaDeSelected", callback)` | | [ `Viewer.pageMargin` ](/_articles/info/api/WebTwain_Viewer.md#pagemargin) | `ImageMargin` | | [ `Viewer.selectedPageBorder` ](/_articles/info/api/WebTwain_Viewer.md#selectedpageborder) | `SelectionImageBorderColor` | | [ `Viewer.selectionRectAspectRatio` ](/_articles/info/api/WebTwain_Viewer.md#selectionrectaspectratio) | `SelectionRectAspectRatio` | | [ `Viewer.setSelectedAreas()` ](/_articles/info/api/WebTwain_Viewer.md#setselectedareas) | `SetSelectedImageArea()` | | [ `Viewer.showPageNumber` ](/_articles/info/api/WebTwain_Viewer.md#showpagenumber) | `ShowPageNumber` | | [ `Viewer.unbind()` ](/_articles/info/api/WebTwain_Viewer.md#unbind) | `UnbindView()` | | [ `Viewer.width` ](/_articles/info/api/WebTwain_Viewer.md#width) | `Width` | | [ `Viewer.zoom` ](/_articles/info/api/WebTwain_Viewer.md#zoom) | `Zoom` | | `ViewerEvent.imageX` | `MouseX` | | `ViewerEvent.imageY` | `MouseY` | > NOTE > > `ViewerEvent.imageX` and `ViewerEvent.imageY` are only available as the first argument in callback functions for the mouse events "click", "dblclick", "contextMenu" and "mousemove". * The following APIs are new in v16.2 + [ `Viewer.acceptDrop` ](/_articles/info/api/WebTwain_Viewer.md#acceptdrop) + [ `Viewer.allowSlide` ](/_articles/info/api/WebTwain_Viewer.md#allowslide) + [ `Viewer.clearSelectedAreas()` ](/_articles/info/api/WebTwain_Viewer.md#clearselectedareas) + [ `Viewer.createThumbnailViewer()` ](/_articles/info/api/WebTwain_Viewer.md#createthumbnailviewer) + [ `Viewer.border` ](/_articles/info/api/WebTwain_Viewer.md#border) + [ `Viewer.first()` ](/_articles/info/api/WebTwain_Viewer.md#first) + [ `Viewer.getUISettings()` ](/_articles/info/api/WebTwain_Viewer.md#getuisettings) + [ `Viewer.gotoPage()` ](/_articles/info/api/WebTwain_Viewer.md#gotopage) + [ `Viewer.idPostfix` ](/_articles/info/api/WebTwain_Viewer.md#idpostfix) + [ `Viewer.innerBorder` ](/_articles/info/api/WebTwain_Viewer.md#innerborder) + [ `Viewer.last()` ](/_articles/info/api/WebTwain_Viewer.md#last) + [ `Viewer.next()` ](/_articles/info/api/WebTwain_Viewer.md#next) + [ `Viewer.on("pageRendered", callback)` ](/_articles/info/api/WebTwain_Viewer.md#pagerendered) + [ `Viewer.on("resize", callback)` ](/_articles/info/api/WebTwain_Viewer.md#resize) + [ `Viewer.previous()` ](/_articles/info/api/WebTwain_Viewer.md#previous) + [ `Viewer.render()` ](/_articles/info/api/WebTwain_Viewer.md#render) + [ `Viewer.resetUISettings()` ](/_articles/info/api/WebTwain_Viewer.md#resetuisettings) + [ `Viewer.selectedAreaBorderColor` ](/_articles/info/api/WebTwain_Viewer.md#selectedareabordercolor) + [ `Viewer.selectedPageBackground` ](/_articles/info/api/WebTwain_Viewer.md#selectedpagebackground) + [ `Viewer.singlePageMode` ](/_articles/info/api/WebTwain_Viewer.md#singlepagemode) * The following APIs in v16.2 are improved based on old APIs in v16.1-. + [`Viewer.setViewMode()`](/_articles/info/api/WebTwain_Viewer.md#setviewmode) It also accepts the values "-1, -1" which is equivalent to setting `Viewer.singlePageMode` to `true` . + [`Viewer.updateUISettings()`](/_articles/info/api/WebTwain_Viewer.md#updateuisettings) * The following APIs are also deprecated in v16.2 + `SetViewMode()` Use Viewer.setViewMode() instead. * The following APIs from v16.1- are removed + `Viewer.bOnlyShowThumbnailsView` + `Viewer.cursorOverThumbnailsView` + `Viewer.bindCustomElement()` + `Viewer.showCustomElement()` + `Viewer.hideCustomElement()` + `Viewer.toggleCustomElement()` + `Viewer.setSelectedImageArea()` + `Viewer.zoomIn()` + `Viewer.zoomOut()` * The following APIs in v16.1- are implemented differently in v16.2 + `BindViewer()` with two parameters + `UpdateViewer()` The two methods above were used to set the size of the viewer or to show the thumbnail viewer. In v16, 2, different APIs are used as shown below: ``` javascript /* Set the size of the viewer */ DWTObject.Viewer.height = 800; DWTObject.Viewer.width = 600; /* Create a thumbnail viewer, note that this viewer can be hidden or disposed */ var objThumbnailViewer = DWTObject.Viewer.createThumbnailViewer(thumbnailViewerSettings); objThumbnailViewer.show(); //objThumbnailViewer.hide(); //objThumbnailViewer.dispose(); /* updateViewMode() is used to change only the view mode of the thumbnail viewer */ objThumbnailViewer.updateViewMode(viewMode: ViewMode); /* The following two are used to hook or unhook events to the thumbnail viewer */ objThumbnailViewer.on() objThumbnailViewer.off() ``` + `ShowImageEditor()` While this method still works, it's deprecated and the alternative is shown in the code below ``` javascript /* The image editor is now created on the fly and can be hidden or disposed */ var objImageEditor = DWTObject.Viewer.createImageEditor(editorSettings); objImageEditor.show(); objImageEditor.hide(); objImageEditor.dispose(); ``` + `Viewer.bindCustomElement()` + `Viewer.showCustomElement()` + `Viewer.hideCustomElement()` + `Viewer.toggleCustomElement()` As already mentioned, these four methods are removed and the alternative implementation is shown in the code below ``` javascript var objCustomElement = DWTObject.Viewer.createCustomElement(document.getElementById("divCustomElement")); objCustomElement.show(); objCustomElement.hide(); objCustomElement.dispose(); ``` ## 16.1.1 ### TWAIN Capability Negotiation > [Alternative] Use [getCapabilities()](/_articles/info/api/WebTwain_Acquire.md#getcapabilities) and [setCapabilities()](/_articles/info/api/WebTwain_Acquire.md#setcapabilities) instead. * CapGet() * CapGetHelp() * CapGetCurrent() * CapGetDefault() * CapGetFrameBottom() * CapGetFrameLeft() * CapGetFrameRight() * CapGetFrameTop() * CapGetLabel() * CapGetLabels() * CapSet() * CapReset() * CapSetFrame() * CapIfSupported() * GetCapItems() * GetCapItemsString() * SetCapItems() * SetCapItemsString() * Capability * CapNumItems * CapMaxValue * CapMinValue * CapCurrentValue * CapCurrentIndex * CapDefaultValue * CapDefaultIndex * CapType * CapValueType * CapStepSize * CapValue * CapValueString ### Buffer Management > [Alternative] Use [SelectedImagesIndices](/_articles/info/api/WebTwain_Buffer.md#selectedimagesindices), [SelectAllImages()](/_articles/info/api/WebTwain_Buffer.md#selectallimages) and [SelectImages()](/_articles/info/api/WebTwain_Buffer.md#selectimages) instead. * GetSelectedImageIndex() * SetSelectedImageIndex * SelectedImagesCount ### Image Editing * AddText() * CreateTextFont() * OverlayRectangle() ### Input and Output > [Alternative] Use new methods like [ConvertToBase64()](/_articles/info/api/WebTwain_IO.md#converttobase64), [PDF.Write.Setup()](/_articles/info/api/Addon_PDF.md#writesetup) * SaveSelectedImagesToBase64Binary() * SetCookie() * IfOpenImageWithGDIPlus * PDFAuthor * PDFCompressionType * PDFCreationDate * PDFCreator * PDFKeywords * PDFModifiedDate * PDFProducer * PDFSubject * PDFTitle * PDFVersion * MaxInternetTransferThreads ### Viewer > [Alternative] Use methods like [Viewer.setViewMode()](/_articles/info/api/WebTwain_Viewer.md#setviewmode), [Viewer.setViewMode()](/_articles/info/api/WebTwain_Viewer.md#setviewmode) * SetViewMode() * SetSelectedImageArea() --- title: Dynamic Web TWAIN SDK Schedule - Release Notes description: Dynamic Web TWAIN SDK Documentation Schedule - Release Notes Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/schedule/index.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/schedule/index.md --- # Release Notes ## [Stable](/_articles/info/schedule/Stable.md) ## [Addon Release](/_articles/info/schedule/Addon.md) ## [Deprecated](/_articles/info/schedule/deprecated.md) --- title: Dynamic Web TWAIN SDK Schedule - Features Proposed description: Dynamic Web TWAIN SDK Documentation Schedule Features Proposed Page source_url: html: https://www.dynamsoft.com/web-twain/docs/info/schedule/proposed.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/info/schedule/proposed.md --- # Features confirmed to be implemented in a later release ## Add TWAIN Direct Support ## Add Watermarks ## Add Annotations --- title: Imaging Hardware description: Dynamic Web TWAIN supports image capture from TWAIN Scanners, ICA Scanners, SANE Scanners, DirectShow Cameras, and MediaDevices Cameras. source_url: html: https://www.dynamsoft.com/web-twain/docs/introduction/imaging-hardware.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/introduction/imaging-hardware.md --- # Imaging Hardware Dynamic Web TWAIN's main feature is interacting with imaging devices like scanners and cameras via different APIs like TWAIN, ICA, SANE, WIA, eSCL and DirectShow. As long as the scanners are supported by these APIs, Dynamic Web TWAIN can use them. In this section, we'll look at these APIs. ## TWAIN ![Hardware-Scanners-Cameras-1](/assets/imgs/Hardware-Scanners-Cameras-1.png) * TWAIN is an application programming interface (API) and communication protocol that regulate communication between software and digital imaging devices, such as image scanners and digital cameras. * TWAIN is supported on Microsoft Windows, Linux, and macOS X. However, based on our experience and the experience of many customers, TWAIN only works well on Windows. On Linux, [SANE](#sane) is the better and preferred alternative; on macOS, [ICA](#ica) is the better and preferred alternative. * TWAIN is actively maintained by the non-profit [TWAIN Working Group](https://www.twain.org/). Members of the group consist of scanner vendors and imaging software vendors, including FUJITSU, Panasonic, Epson, HP, ExactCODE, LEADTOOLS, and of course, Dynamsoft. * TWAIN is [the most commonly used protocol](https://www.twain.org/why-twain/) for image capturing and processing. Almost all scanners on the market come with a TWAIN driver and are supported by TWAIN applications like `Dynamic Web TWAIN`. See more: [How to use TWACKER to check if your device is TWAIN Compliant?](/_articles/faq/how-to-use-TWACKER-to-check-if-your-device-is-TWAIN-Compliant.md){:target="_blank"} ## ICA ![Hardware-Scanners-Cameras-2](/assets/imgs/Hardware-Scanners-Cameras-2.png) * ICA is a framework ([ImageCaptureCore Framework](https://developer.apple.com/documentation/imagecapturecore)) from Apple designed to "Browse for media devices and control them programmatically from your app." * ICA is supported on macOS X. See more: [How to test if your scanner supports ICA scanning on Mac OS?](/_articles/faq/how-to-test-if-your-scanner-supports-ICA-scanning-on-Mac-OS.md){:target="_blank"} ## SANE ![Hardware-Scanners-Cameras-3](/assets/imgs/Hardware-Scanners-Cameras-3.png) * [SANE](http://www.sane-project.org/) stands for "Scanner Access Now Easy" and is an application programming interface (API) that provides standardized access to any raster image scanner hardware. * SANE is supported on multiple Linux distributions. * `Dynamic Web TWAIN` supports SANE v1.0.25+. * You can find the list of supported devices [here](http://www.sane-project.org/sane-supported-devices.html). See more: [How to test if your device is SANE compliant?](/_articles/faq/how-to-test-if-your-device-is-SANE-compliant.md){:target="_blank"} ## WIA ![Hardware-Scanners-WIA](/assets/imgs/Hardware-Scanners-WIA.png) * Windows Image Acquisition (WIA) is the still image acquisition platform in the Windows family of operating systems starting with Windows Millennium Edition (Windows Me) and Windows XP. * Most multi-function printers are supported by WIA without the need to install extra drivers. But for advanced scanners, TWAIN is still a better choice. ## eSCL * eSCL (also named Mopria) is a RESTful interface. The network scanners broadcast themselves via Bonjour and the client can find them and send HTTP requests to scan documents. * It is a driverless solution. * The supported devices are mostly multi-function printers (MFPs). You can find the list of supported scanners [here](https://mopria.org/certified-products). ## DirectShow ![Hardware-Scanners-Cameras-4](/assets/imgs/Hardware-Scanners-Cameras-4.png) Cameras can be accessed via the [Microsoft DirectShow architecture](https://docs.microsoft.com/en-us/windows/win32/directshow/introduction-to-directshow). These cameras are either built into desktops / laptops or connected via USB. See more: [Is my Camera DirectShow Compliant?](/_articles/faq/how-to-test-if-your-camera-is-DirectShow-compliant.md){:target="_blank"} --- title: Document Scanning SDK | Dynamic Web TWAIN Documentation description: Dynamic Web TWAIN SDK Documentation. This will help you integrate document scanning into your app, no matter whether you are building a workflow from scratch or optimizing an existing workflow. source_url: html: https://www.dynamsoft.com/web-twain/docs/introduction/index.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/introduction/index.md --- # Introduction **Dynamsoft Dynamic Web TWAIN** (DWT) is a software development kit (SDK) that enables users to scan documents from a **web environment** via APIs like TWAIN, WIA, ICA, SANE and eSCL. DWT handles the whole data flow, from image acquisition at the scanner, to displaying and editing scanned images in the browser, and finally uploading to the server. To see it in action, please visit its [online demo](https://demo.dynamsoft.com/web-twain/). ## Quick Start * [Hello World](/_articles/hello-world/index.md) demo that demonstrates how to enable basic scanning, viewing, and uploading functionality in a web application. * [General usage](/_articles/general-usage/index.md) and [extended usage](/_articles/extended-usage/index.md) guides for you to quickly start making use of both basic and advanced features of DWT. ## Key Features 1. Platform support: Broad compatibility with browsers, operating systems, and image sources 2. Image acquisition: - Connect to scanners from web browser with industry standard protocols - Communicate with scanners using a background service ([The Dynamic Web TWAIN Service](/_articles/faq/what-does-dynamsoft-service-do-on-end-user-machine.md)) with flexible configurations 3. Image upload: - Upload over HTTP, HTTPS (HTTP + TLS), and FTP - Optionally upload large files through background service 4. Document management: - Configurable document viewer for scanned images - Visual editor for reordering, marking up, cropping images, etc. 5. Secure data handling: - Encrypted data pipeline - Cache sanitization even upon unexpected shutdown of SDK 6. PDF annotation with [Dynamsoft Document Viewer](https://www.dynamsoft.com/document-viewer/docs/introduction/index.html) ([demo](https://demo.dynamsoft.com/web-twain/annotate-scan)) ## Add-Ons DWT add-ons provide additional features: * [Webcam add-on](/_articles/info/api/Addon_Webcam.md) to access cameras in the browser. * [Barcode Reader add-on](/_articles/info/api/Addon_BarcodeReader.md) to read barcodes in documents. * [PDF Rasterizer add-on](/_articles/info/api/Addon_PDF.md) to load external PDFs. * [OCR add-on](/_articles/info/api/Addon_OCR.md) to extract text, correct document orientation and create searchable PDFs. ## Requirements You can find supported systems, browsers, and hardware in the following pages: * [System requirements](/_articles/introduction/system-requirements.md) * [Hardware requirements](/_articles/introduction/imaging-hardware.md) In addition, [local network access permission](https://www.dynamsoft.com/web-twain/docs/faq/chromium-142-local-network-access-issue.html) and [HTTPS](https://www.dynamsoft.com/web-twain/docs/faq/http-insecure-websites-in-chromium-browser.html) are also required by latest browsers. ## API Reference See [API reference](/_articles/info/api/index.md) where you can find more comprehensive descriptions of our product. ## RESTful API Dynamic Web TWAIN also provides [RESTful API](https://www.dynamsoft.com/web-twain/restfulapi/) to access scanners using various programming languages. You can check out the [samples](https://www.dynamsoft.com/web-twain/docs/extended-usage/restful-api.html) and [APIs](https://www.dynamsoft.com/web-twain/docs/info/api/restful.html) to learn more. ## Scan with Camera If you need to scan documents using your camera, with features like automatic border detection and cropping, try our other product: [Mobile Document Scanner](https://www.dynamsoft.com/use-cases/mobile-document-scanner/). --- title: Dynamic Web TWAIN SDK Supported File Formats description: Dynamic Web TWAIN SDK Documentation File Types Page source_url: html: https://www.dynamsoft.com/web-twain/docs/introduction/supported-file-formats.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/introduction/supported-file-formats.md --- # Supported File Formats Dynamic Web TWAIN supports the following file types: ## BMP **BMP** is an uncompressed image format. Such a file is huge because of the lack of compression. A lower limit on storage size for a n-bit-per-pixel bitmap, in bytes, can be calculated as: ``` size = width * height * n/8; // where height and width are given in pixels ``` For example, a US Letter sized paper scanned in 300 DPI and in color has the size of (8.5 * 300) * (11 * 300) * 24 / 8 = 25, 245, 000 bytes which is close to 24 MB. ## JPEG The **JPEG** format supports eight-bit grayscale images and 24-bit color images (eight bits each for red, green, and blue). Black & white image data which is 1-bit can not be saved in this format. This format applies lossy compression to images, which can result in a significant reduction of the file size. Applications can determine the degree of compression to apply, and the amount of compression affects the visual quality of the result. `Dynamic Web TWAIN` uses the API [ `JPEGQuality` ](/_articles/info/api/WebTwain_IO.md#jpegquality) to control this. > NOTE > > The API `JPEGQuality` affects the degree of compression of the file as long as it uses the **JPEG** compression type. In other words, a TIFF file or a PDF file using **JPEG** compression will also be affected. ## TIFF Compared with **BMP** and **JPEG** , the **TIFF** format is more like a container that holds image(s) and data in a single file. A TIFF file uses tags to describe the data it holds so that applications know how to read it. `Dynamic Web TWAIN` allows custom tags with the APIs [ `ClearTiffCustomTag()` ](/_articles/info/api/WebTwain_IO.md#cleartiffcustomtag) and [ `SetTiffCustomTag()` ](/_articles/info/api/WebTwain_IO.md#settiffcustomtag). **TIFF** also allows multiple images in the same file. `Dynamic Web TWAIN` controls this with the API [ `IfTiffMultiPage` ](/_articles/info/api/WebTwain_IO.md#iftiffmultipage). ## PNG The **PNG** format supports lossless data compression. The same image may save bigger as a `.png` than a `.jpg` but it preserves all information. ## PDF The **PDF** format is an advanced and popular file format that allows a variety of content. Because of the complexity of the format, it is impractical for a lightweight SDK such as `Dynamic Web TWAIN` to have full support for it. Instead, `Dynamic Web TWAIN` supports the format in two ways * `Dynamic Web TWAIN` can read and write a pure-image-based **PDF** file; * `Dynamic Web TWAIN` can use its [PDF Rasterizer module](/_articles/extended-usage/pdf-processing.md) to rasterize almost any **PDF** file and convert its visible content into images so as to "read" it. --- title: Dynamic Web TWAIN SDK System Requirements description: Dynamic Web TWAIN SDK Documentation Platform Page source_url: html: https://www.dynamsoft.com/web-twain/docs/introduction/system-requirements.html md: https://github.com/dynamsoft-docs/web-twain-docs/blob/master/_articles/introduction/system-requirements.md --- # System Requirements ## Supported Systems and Browsers Dynamic Web TWAIN is designed to be cross-platform, thus, it works in all major browsers across all major operating systems: * Windows: Windows 7 or later * macOS: macOS 10.15 or later * Linux: Ubuntu, Debian, Fedora, Linux on ChromeOS ([guide](https://www.dynamsoft.com/codepool/chrome-os-web-document-scanning.html)), etc [See the list of supported systems and browsers >](https://www.dynamsoft.com/web-twain/features/) ## Other Operating Systems There could be some other systems which are also supported but not listed above. Dynamsoft doesn't recommend the use of such systems as they are not officially tested. If you need to use Dynamic Web TWAIN on a system not mentioned above, please first contact [Dynamsoft Support](/_articles/about/getsupport.md) to get more information. ## Other Browsers There are many different browsers on the market which may not have been listed above. However, these browsers most likely use the same browser engines that one of the listed browsers use. For example, on desktop Opera uses [ `Blink` ](https://en.wikipedia.org/wiki/Blink_(web_engine)) just like Chrome. These browsers probably work too. If you plan to use any of the browsers that are not listed above, you should - Make sure it works by testing our [demo page](https://demo.dynamsoft.com/dwt/online_demo_scan.aspx) - Do thorough tests before going into production