private static void SaveBlackWhiteTIFFwithCITT4(Document doc, string dataDir, bool highSensitivity)
{
// Select the TIFF format with 100 dpi.
ImageSaveOptions imgOpttiff = new ImageSaveOptions(SaveFormat.Tiff);
imgOpttiff.Resolution = 100;
// Set CCITT4 compression.
imgOpttiff.TiffCompression = TiffCompression.Ccitt4;
// Apply grayscale filter.
imgOpttiff.ImageColorMode = ImageColorMode.Grayscale;
// Set brightness and contrast according to sensitivity.
if (highSensitivity)
{
imgOpttiff.ImageBrightness = 0.4f;
imgOpttiff.ImageContrast = 0.3f;
}
else
{
imgOpttiff.ImageBrightness = 0.9f;
imgOpttiff.ImageContrast = 0.9f;
}
// Save multipage TIFF.
doc.Save(string.Format("{0}{1}", dataDir, "result Ccitt4.tiff"), imgOpttiff);
Console.WriteLine("\nDocument converted to TIFF successfully with black and white and Ccitt4 compression.\nFile saved at " + dataDir + "Result Ccitt4.tiff");
}