DTWAIN_TwainSave Command Overview

Top  Previous  Next

DTWAIN_TwainSave can take various command options.  The only required command-line option is -f (the name of the image file to be saved).  Otherwise, DTWAIN_TwainSave uses the default setting for the option if the option is not specified.  If DTWAIN_TwainSave detects that an illegal command-line option is given, a dialog is displayed that has a summary of all the commands, and the DTWAIN_TwainSave returns an error code denoting that the operation failed.

 

When producing Acrobat PDF files, DTWAIN_TwainSave has various options including setting the producer, keywords, encryption, and other useful PDF options.  The options that are PDF specific start named -pdfxxxx where "xxxx" is the option.

 

The DTWAIN_TwainSave options can be one or more of the following:

 

-A

Use the automatic document feeder (default is feeder is not used).

 

-AF

Use the automatic document feeder, and if no paper is detected in feeder, use the flatbed portion of the device (detection of paper in feeder must be supported by the TWAIN driver).

 

-area

Specifies the acquisition area to acquire.

 

-B

Brightness level (must be supported by the TWAIN driver).

 

-blankthreshold

Sets the threshold (percentage) value for DTWAIN_TwainSave to determine if a page is blank.  The threshold is the ratio of white pixels to dark pixels on the page.  Use this option with -noblankpages
 

-bpp

Bits-per-pixel used to acquire the image.

 

-C

Set the contrast of the image

 

-color

Sets the color setting of the device.  

 

-D

Use the duplex unit.  Default is to not use the duplex unit.

 

-details

Writes to a file all TWAIN device names and color/bits-per-pixel information for each TWAIN device.

 

-diagnose

Turn on diagnostic mode.

 

-diagnoselog

Log diagnostic messages to the specified file.

 

-F

File type of the saved image.  Default is "bmp".  See -F for all the various file types.

 

-f

File name of the image file.
 
Unless the -details option is used, the -f option is a required command option.

 

-G

Gamma value used for the image.

 

-help

Display DTWAIN_TwainSave help.

 

-im

Sets the imprinter string.

 

-jc

Sets job control options.

 

-jquality

Sets the JPEG quality factor for JPEG files.

 

-multipage

Save all pages scanned to a multi-page file.

 

-multipage2

Save all pages scanned to a multi-page file only when the device user interface is closed.
 

-noblankpages

Discard any blank pages that have been acquired from the TWAIN device.
 

-noui

Do not display the TWAIN device user interface when acquiring pages.

 

-orientation

Specifies page orientation when acquiring pages.

 

-p

Number of pages to acquire.  Default is 0 (acquire all pages).

 

-pdfascii

Turns on ASCII compression for PDF files.

 

-pdfauthor

Sets the PDF author setting for the file.

 

-pdfcreator

Sets the PDF Creator field in PDF files.

 

-pdfencrypt

Turns on encryption for PDF file generation.

 

-pdfkeywords

Sets the PDF Keywords setting for the file.

 

-pdfownerpass

Sets the PDF owner password for encrypted files

 

-pdfpermit

Sets the PDF Permissions for an encrypted file.

 

-pdfproducer

Sets the PDF Producer field for the PDF file

(deprecated -- please use -pdfcreator).

 

-pdfquality

Sets the JPEG quality used in PDF files.

 

-pdfsize

Sets the size of the PDF page.

 

-pdfsubject

Sets the PDF Subject field for the PDF file.

 

-pdftitle

Sets the PDF Title field for the PDF file.

 

-pdfuserpass

Sets the PDF user password for encrypted files.

 

-pdf128

Use 128-bit encryption for PDF files.

 

-pdforient

Sets the PDF orientation (landscape or portrait).

 

-pdfscale

Sets the PDF scaling for the PDF file.

 

-pdfsize

Sets the size of the PDF page.

 

-P

Paper size. Default is US letter (8.5" x 11").

 

-saveoncancel

Save image file even if user cancels scanning.

 

-sd

Select the default TWAIN device.

 

-sn

Select the TWAIN device by using the name of the device.

 

-tempdir

Denotes path where temporary image files will be stored.
 

-thumbnail

Produces thumbnail images.

 

-trans

Use the transparency unit.

 

-U

Sets the unit of measure.

 

-uiperm

Allows the TWAIN device's user interface to remain visible after a set of images have been acquired.

 

-useinc

Use the smart auto-incrementing feature when saving multiple pages to multiple files.

 

-verbose

Outputs to the screen or file the current action that DTWAIN_TwainSave is executing.

 

-verboselog

Send -verbose output to a file.

 

-@

Use a command file to specify commands.

 

Here are a few examples of usage:

 

DTWAIN_TwainSave("-sd -F bmp -f mybmp.bmp");

Selects the default device (-sd), saves to BMP format (-F bmp), and the name of the file is mybmp.bmp.

 

DTWAIN_TwainSave("-F gif -f mygif.gif");

Displays the TWAIN "Select TWAIN device" dialog to select the device, saves to GIF format (-F gif), and the name of the file is mygif.gif.

 

DTWAIN_TwainSave("-F tif3 -color 0 -f mytifg3.tif -noui");

Displays the TWAIN "Select TWAIN device" dialog to select the device (-sd), saves to TIFF Group3 format (-F tif3).

The color is set to black and white (-color 0) to ensure that Group 3 format is created correctly (Group 3 must use black and white).  No user interface of the TWAIN device is displayed.

 

DTWAIN_TwainSave("-C 20 -f mybmp.bmp");

Acquires to a BMP file and sets the contrast of the image to 20.

 

DTWAIN_TwainSave("-C 20 -f mybmp.bmp -uiperm");

Same as above, except that the TWAIN user interface for the device does not close after a set of pages are acquired (the user must close the user interface).

 

DTWAIN_TwainSave("-sn "Fujitsu Twain Driver" -bpp 8 -F tif7 -f mytif.tif -noui -D");

Uses the TWAIN driver named "Fujitsu Twain Driver",

bits-per-pixel is 8

Save to TIFF-LZW format

Name of the file is mytif.tif

Do not display the user interface of the device

Use the duplex unit.

 

DTWAIN_TwainSave("-verbose");

Uses defaults and displays the progress of the acquisition on the screen.

 

DTWAIN_TwainSave("-f test.bmp");

Just specifying the filename does the following defaults:

 

Show the TWAIN "Select TWAIN device" window to select the TWAIN driver.
Displays the TWAIN driver's user interface.
Acquires entire page to a Windows BMP file.
The color used is black and white (1 bit per pixel), or the first available color that the TWAIN device supports that is compatble with BMP files.
Closes the TWAIN user-interface displayed after acquiring the image (see the -uiperm option to leave the user interface displayed after an acquistion)
No verbose output.

 

Note that some options may cancel out other options.  For example, an option to specify the PDFpage size (-pdfsize) will override the -P option.  Make sure that you choose options that do not conflict with other options in terms of functionality.

 

Also note that many of these command-line options can be overridden by the user of DTWAIN_TwainSave if the TWAIN user interface of the device is displayed (if you do not specify -noui) .  For example, if you specify on the command-line to use color (the -color 2 option), and the user changes this by selecting a different color type in the user interface, DTWAIN_TwainSave cannot override the user's choices, and will attempt to scan and save the image based on the choices in the user interface.