ScanResult

ScanResult

ScanResult is the result of the last scan operation. It contains the scanned page images, the image type, and the tiff file or pdf file if the image type is tiff or pdf.

Constructor

# new ScanResult(images, scanFormatType, tiffFile, pdfFile, imageType)

Parameters:
Name Type Description
images Array

An array of base64 encoded scanned page images.

scanFormatType String

The type of the scan. Can be jpeg, bmp, png, pdf or tiff.

tiffFile String

The base64 encoded tiff file. Only available if scanFormatType is tiff.

pdfFile String

The base64 encoded pdf file. Only available if scanFormatType is pdf.

imageType String

The type of the single image. Can be jpeg, bmp or png.

Members

# images :Array

An array of base64 encoded scanned page images.

Type:
  • Array

# imageType :String

The type of the single image. For scanFormatType = 'tiff','pdf' or 'jpeg' it is jpeg. For 'bmp' it is 'bmp'. For 'png' it is 'png'.

Type:
  • String

# pdfFile :String

The base64 encoded pdf file. Only available if scanFormatType is pdf.

Type:
  • String

# scanFormatType :String

The scan format type. Can be jpeg, bmp, png, pdf or tiff.

Type:
  • String

# scannedPageCount :Number

The number of pages the TWTwain client actually acquired from the scanner. Set when the scan finishes. It is authoritative: it can be greater than the number of pages that reached the browser, if a page failed to transfer. Undefined when talking to a client older than 1.2.4.0.

Type:
  • Number

# tiffFile :String

The base64 encoded tiff file. Only available if scanFormatType is tiff.

Type:
  • String

Methods

# getImageDataAsUint8Array(pageNumber) → {Uint8Array}

Get image as Uint8Array for selected page number.

Parameters:
Name Type Description
pageNumber Number

The page number to get the image data from.

Returns:

The image bytes

Type
Uint8Array

# getImageDataSrc(pageNumber) → {String}

Get image data source URL for selected page number. Useful for displaying the image in an canvas or img element.

Parameters:
Name Type Description
pageNumber Number

The page number to get the image data from.

Returns:

Data source URL with the base64 encoded image data.

Type
String

# missingPages() → {Array}

Page numbers whose image never reached the browser. Their slots are kept empty so the remaining pages stay in order.

Returns:

1-based page numbers, empty array when every page arrived.

Type
Array

# pageCount() → {Number}

The number of page slots in the scan result, including pages that failed to transfer. Use scannedPageCount for the number of pages the scanner actually produced, and missingPages() to find out which slots are empty.

Returns:

The number of pages in the scan result.

Type
Number