Skip to main content

Creating TIFF Documents

The Scanbot SDK provides the ability to write scanned images into a TIFF file.

The SBSDKTIFFImageWriter contains convenient functions to write the scanned images into a multi-page TIFF file, adjust the TIFF file's parameters and encrypt the newly created file.

NOTE: The Scanbot SDK can optionally encrypt the TIFF file. This provides the best level of protection. To decrypt the TIFF file you can use the key property of SBSDKAESEncrypter or generate the key yourself using salt, password, and iterations.

Example code for creating a TIFF file from the scanned images:

    // For this example we're using an empty array, but there should be scanned images in it.
let scannedImages: [UIImage] = []

// Specify the file URL where the TIFF will be saved to. Nil makes no sense here.
guard let outputTIFFURL = URL(string: "outputTIFF") else { return }

// In case you want to encrypt your TIFF file, create encrypter using a password and an encryption mode.
guard let encrypter = SBSDKAESEncrypter(password: "password_example#42",
mode: .AES256) else { return }

// The `SBSDKTIFFImageWriter` has parameters where you can define various options,
// e.g. compression algorithm or whether the document should be binarized.
// For this example we're going to use the default parameters.
let parameters = SBSDKTIFFImageWriterParameters.defaultParameters

// Create the tiff image writer using created parameters and the encrypter.
let tiffImageWriter = SBSDKTIFFImageWriter(parameters: parameters, encrypter: encrypter)

// Write a TIFF file with scanned images into the defined URL.
// The result of this function is a boolean signifying whether the operation was successful or not.
let result = tiffImageWriter.writeTIFF(with: scannedImages, toFile: outputTIFFURL)

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?