Using DTWAIN_TwainSave

Top  Previous  Next

The following code snippets in the manual showing DTWAIN_TwainSave assumes you are using 'C' or C++.  Please change the syntax of the calls being used to match the language that you're using.  For example:

 

DTWAIN_TwainSave( "-f test.tif ")

 

In Visual Basic 6.0 and below would be:

 

DTWAIN_TwainSave "-f test.tif"

 


The following advisory is only necessary for C, C++, and for any other computer language you may be using that requires backslashes within strings to be specified by two backslashes, and double quotes within strings to be properly escaped.  

 

If you are not programming in the C or C++ language, you will still need to embed double quotes and backslashes where needed inside of strings.  Consult the rules of your language to properly insert double quotes and backslashes within strings.

 

End of advisory....


 

In general, you invoke a DTWAIN_TwainSave command-line as follows:

 

DTWAIN_TwainSave("options")

 

where options are the various command-line options that are available.  All the command options are preceded with a hyphen (-) or with a forward slash (/).  For example, these two commands do exactly the same thing:

 

DTWAIN_TwainSave("/f test.tif /noui");

DTWAIN_TwainSave("-f test.tif -noui");

 

For the remainder of this documentation, the commands will be preceded with a hyphen.

 

Very important:

 

The options are case-sensitive.  For example, an option of -p and -P are two different options.
Options that have spaces in the arguments must be enclosed in double quotes:

 Example - set the file name to c:\My Documents:

 -f "c:\My Documents"

 

 Example - set the area to acquire as a 3 x 3 inch square:

 -area "0 0 3 3 inch"

 


For C/C++ programmers:

Note that many times, you may have to insert double quotes in the command-string.  This requires you to properly use escape codes to enter the string.  For example:

 

DTWAIN_TwainSave("-f \"A file name that contains spaces.bmp\" ");

 

Note that for the above, since the file name used contains spaces, it is necessary to use double quotes around the file name.  For C/C++ programs, to embed quotes, use the escape sequence \".   In addition, for C/C++ the backslash character must also be escaped using two backslash characters.  For example:

 

DTWAIN_TwainSave("-f c:\\MyDirectory\\MyFile.bmp")

 

This is highly important for the C/C++ programmer to realize, since many string-related bugs can occur with an improperly escaped string sequence.

 

If you are not programming in the C or C++ language, you will still need to embed double quotes and backslashes where needed.  Consult the rules of your language to properly insert double quotes within strings.

 


 

The following calls DTWAIN_TwainSave with the option to open the TWAIN "Select Device" dialog box:

 

DTWAIN_SysInitialize( );

DTWAIN_TwainSave("-f test.bmp");

DTWAIN_SysDestroy( );

 

Note the usage of DTWAIN_SysInitialize to initialize the DTWAIN library, and DTWAIN_SysDestroy to properly shutdown DTWAIN.  These two functions are mandatory when utilizing the DTWAIN library.

 

Once the device is selected, the call to DTWAIN_TwainSave allows the device's user interface will be displayed, allowing you to start the scanning or image retrieval process.

 

clip0014

 

The number of items that appear in the "Select TWAIN device" dialog box depends on the number of installed drivers.

 

The image retrieved will be saved in Windows bitmap (BMP) format, and the name of the file will be "test.bmp".

 

Various options are available to save to a different file format, select the device without the "Select TWAIN device" dialog from displaying, retrieving the image without displaying the device's user interface, acquiring multiple pages, etc.  It is recommended that you start with the basic set of command-line options (for example, acquire to another image type, change the file name, etc), and then add the more advanced options (for example, job control) as you get more experienced with using DTWAIN_TwainSave.

 

DTWAIN_TwainSave options