This project is read-only.

How To View TIFF Images

As of Document Toolkit 2.0.8 (June 2011 Update) a new package reader TiffPackageReader is available that supports TIFF images. Each sub-image of a TIFF file is rendered in its own page. The following step-by-step tutorial demonstrates how to view TIFF images with Document Toolkit.

1) Open Visual Studio 2010 and create a new Silverlight 4 application

2) Use NuGet to install the TIFF package reader (DocumentToolkit.IO.LibTiff). NuGet automatically installs the DocumentToolkit package as well. Please note that the Document Toolkit packages are found in the First Floor Software package feed. Learn more at How To Install Document Toolkit using NuGet.

3) (Optional) Install the Sample TIFF images (id:DocumentToolkit.SampleTiff) package for a set of sample TIFF images.

4) Open the MainPage.xaml and add the following XML namespace declaration:


5) Define a DocumentDataSource and DocumentViewer in XAML like so:

<doc:DocumentDataSource x:Name="DataSource" LoadError="DataSource_LoadError" />
<doc:DocumentViewer x:Name="Viewer" DocumentDataSource="{Binding ElementName=DataSource}">
    <doc:ViewMode ScaleMode="FitWidth" />

6) Make sure the DataSource LoadError event handler is implemented in the code-behind. The below snippet simply displays an error messagebox.

using FirstFloor.Documents.Controls;

private void DataSource_LoadError(object sender, ErrorEventArgs e)

7) To load a document we need to assign the TiffPackageReader to the DocumentDataSource. The following code snippet demonstrates how to load a TIFF image that is available as content in the project.

using FirstFloor.Documents.IO.LibTiff;

this.DataSource.PackageReader = new TiffPackageReader(new Uri("[myimage.tiff]", UriKind.Relative));

And that's it. To view TIFF images, you just need to create a TiffPackageReader and provide it with the TIFF image. All other controls in the Document Toolkit remain the same, you use the same DocumentViewer, DocumentDataSource and so on.

Last edited Dec 6, 2011 at 2:52 PM by kozw, version 9


No comments yet.