---
title: "TWAIN scanner: Scan and convert to TIFF in C# .NET | Nutrient .NET SDK"
canonical_url: "https://www.nutrient.io/guides/dotnet/scanning/to-tiff/"
md_url: "https://www.nutrient.io/guides/dotnet/scanning/to-tiff.md"
last_updated: "2026-05-21T17:12:02.219Z"
description: "Learn how to scan documents and convert them to TIFF files programmatically in C# using Nutrient .NET SDK. Implement scanning and image conversion within your applications."
---

# Scan and convert files to TIFF in C#

This guide explains how to scan a physical document with a scanner and then save the scanned image as a TIFF file. This guide uses the [TWAIN protocol](https://en.wikipedia.org/wiki/TWAIN).

Printing and scanning aren’t supported in the cross-platform.NET 6.0 assembly. For more information, see the [system compatibility](/guides/dotnet/about/system-compatibility.md)  guide.

To get an image from a scanner and then save it as a TIFF file, follow these steps:

1. Create a `GdPictureImaging` object.

2. Store the handle of the active windows in a variable by calling the `IntPtr.Zero` structure.

3. Select the scanner by passing the handle to the `TwainSelectSource` and the `TwainOpenDefaultSource` methods of the `GdPictureImaging` object.

4. Optional: Hide the scanning user interface with the `TwainSetHideUI` method of the `GdPictureImaging` object. Use this setting when your application cannot communicate with the scanner.

5. Get the image from the scanner by passing the handle to the `TwainAcquireToGdPictureImage` method of the `GdPictureImaging` object.

6. Save the scanned image with the `SaveAsTIFF` method of the `GdPictureImaging` object. This method takes the following parameters:
   - The image ID.
   - The file path of the output file.
   - The TIFF compression method. This parameter is a member of the `TiffCompression` enumeration.

7. Release unnecessary resources and close the TWAIN source handle.

The example below gets an image from a scanner and then saves it as a TIFF file:

### C#

```csharp

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Store the handle of the active windows in a variable.
IntPtr WINDOW_HANDLE = IntPtr.Zero;
// Select the scanner.
gdpictureImaging.TwainSelectSource(WINDOW_HANDLE);
gdpictureImaging.TwainOpenDefaultSource(WINDOW_HANDLE);
// (Optional) Hide the scanning user interface.
gdpictureImaging.TwainSetHideUI(true);
// Get the image from the scanner.
int imageId = gdpictureImaging.TwainAcquireToGdPictureImage(WINDOW_HANDLE);
// Save the scanned image.
gdpictureImaging.SaveAsTIFF(imageId, @"C:\temp\output.tiff", TiffCompression.TiffCompressionAUTO);
// Release unnecessary resources.
gdpictureImaging.ReleaseGdPictureImage(imageId);
gdpictureImaging.TwainCloseSource();

```

### VB.NET

```vb

Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    ' Store the handle of the active windows in a variable.
    Dim WINDOW_HANDLE = IntPtr.Zero
    ' Select the scanner.
    gdpictureImaging.TwainSelectSource(WINDOW_HANDLE)
    gdpictureImaging.TwainOpenDefaultSource(WINDOW_HANDLE)
    ' (Optional) Hide the scanning user interface.
    gdpictureImaging.TwainSetHideUI(True)
    ' Get the image from the scanner.
    Dim imageId As Integer = gdpictureImaging.TwainAcquireToGdPictureImage(WINDOW_HANDLE)
    ' Save the scanned image.
    gdpictureImaging.SaveAsTIFF(imageId, "C:\temp\output.tiff", TiffCompression.TiffCompressionAUTO)
    ' Release unnecessary resources.
    gdpictureImaging.ReleaseGdPictureImage(imageId)
    gdpictureImaging.TwainCloseSource()
End Using

```

#### Used methods

- [`SaveAsTIFF`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPictureImaging~SaveAsTIFF.html)

- [`ReleaseGdPictureImage`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPictureImaging~ReleaseGdPictureImage.html)

- [`TwainAcquireToGdPictureImage`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPictureImaging~TwainAcquireToGdPictureImage.html)

- [`TwainCloseSource`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPictureImaging~TwainCloseSource.html)

- [`TwainOpenDefaultSource`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPictureImaging~TwainOpenDefaultSource.html)

- [`TwainSelectSource`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPictureImaging~TwainSelectSource.html)

- [`TwainSetHideUI`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPictureImaging~TwainSetHideUI.html)

#### Related topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)
---

## Related pages

- [TWAIN and WIA scanning using C#](/guides/dotnet/scanning.md)
- [Scan and OCR PDFs in C#](/guides/dotnet/scanning/to-searchable-pdf.md)

