Skip to main content

Creating TIFF Documents | Cordova Document Scanner

ScanbotSdk.writeTiff(args: {images: string[], oneBitEncoded?: boolean, dpi?: number, compression?: TIFFCompression})

Renders the given image files into a multi-page TIFF and stores it as a file. For each image, a separate page is generated.

Typically, the final hi-res document image files of the scanned Pages (documentImageFileUri) are used to generate the TIFF file.

import ScanbotSdk, { Page } from 'cordova-plugin-scanbot-sdk';

private SDK = ScanbotSdk.promisify();
public scannedPages: Page[] = ...;

// Always make sure you have a valid license on runtime via SDK.getLicenseInfo()
if (!licenseCheckMethod()) { return; }

const result = await this.SDK.writeTiff({
imageFileUris: this.scannedPages.map(p => p.documentImageFileUri),
options: {
oneBitEncoded: true,
dpi: 300,
compression: 'CCITT_T6'
}
});

// use the TIFF file URI from result, e.g.:
await uploadTiff(result.tiffFileUri);

Input args:

  • images: Input images as an array of file URIs in proper order (image element 1 => page 1, etc).
  • oneBitEncoded : Optional boolean flag. If true, the input images will be binarized and the output TIFF file will be saved with one bit per pixel. If false, the input images will be stored as-is. The default value is false.
  • dpi : Optional integer value for Dots Per Inches. The default value is 200 dpi.
  • compression : Optional TIFF compression type. The default value depends on the oneBitEncoded flag. CCITT_T6 (CCITT Fax 4) is the default value for binarized (oneBitEncoded=true) images. For color images (oneBitEncoded=false) the default value is ADOBE_DEFLATE (ZIP).

Result:

  • tiffFileUri: File URI of the TIFF result file ('file:///...').

Supported TIFF Compression Types

  • NONE : No compression.
  • CCITT_T6 : "CCITT Fax 4" compression type. Most common and recommended type for binarized (1-bit) black and white images to achieve a small TIFF file size.
  • ADOBE_DEFLATE : "ZIP" compression type. Most common type for color images.
  • CCITTRLE
  • CCITTFAX3
  • CCITT_T4
  • CCITTFAX4
  • CCITTRLEW
  • LZW
  • PACKBITS
  • DEFLATE
caution

Please note that the following compression types are only compatible for binarized images (1-bit encoded black & white images): CCITTRLE, CCITTFAX3, CCITT_T4, CCITTFAX4, CCITT_T6, CCITTRLEW.

Want to scan longer than one minute?

Generate your free "no-strings-attached" Trial License and properly test the Scanbot SDK.

Get your free Trial License

What do you think of this documentation?


On this page

Scroll to top