Guide for C#
Core Document Formats
Additional Features

C# Imaging - Create Windows Image Viewer in C#

Online C#.NET Tutorial for Creating Windows Document Image Viewer

Visual C#
Home > .NET Imaging SDK > C# > Create Windows Viewer
If this is your first time to use our DocImageSDK, we strongly suggest you reading How to Start first!

C# Windows Image Viewer SDK Overview

Like C#.NET Web Doc Image Viewer, this professional and mature Windows Document & Image Viewer from Rasteredge DocImage SDK for .NET, C#.NET can also be used to view, process and annotate image and document in C#.NET applications. Written in 100% managed C# code and developed in .NET Framework 2.0, this profesional and clean .NET doc imaging library SDK can help C# developers create a Windows document and image (picture/photo) viewer without using other external file viewing SDKs.
In this C#.NET tutorial page, you will find following aspects related to C#.NET Windows Document & Image Viewer.
  • Key feature list of C#.NET Windows image viewer control SDK
  • Related APIs for this Visual C#.NET Windows document image viewer library add-on
  • How to add a Windows document image viewer in your C#.NET application
  • How to customize your Windows Doc Image Viewer in C#.NET project
If you want to create a Windows document image viewing application for specific document or image type, please see these pages respectively: C#.NET Windows PDF document viewer SDK, Visual C#.NET Windows TIFF image viewer add-on and Windows Word (.doc/.docx) file viewer control .
C# Windows Document Image Viewer Features
  • No need for client download, installation, & flash plugin
  • Easily integrated into Visual C#.NET Windows application
  • Support creating Windows doc image viewing project in Visual Studio 2005 or greater versions
  • Programmed in full C# code and compatible with .NET-compliant programming languages C# & VB.NET
  • Support displaying and viewing multiple document & image formats (PDF, MS Word, Tiff, Png...) in C#.NET Windows class application
  • Users are allowed to add own commands to customize C#.NET Windows document & image viewer
  • Easy to create high-quality image thumbnails & automatic navigation from thumbnails to main Windows viewer
  • Provide flexible document image processing functions, like document image zooming and panning
  • Allow C#.NET developers to redact image and document with various text or graphical annotations
  • Mature Windows viewer control for C#.NET imaging application, allowing direct document and image saving
C#.NET Windows Doc Image Viewer Control APIs
RasterEdge .NET Windows Viewer Control provides C# developers with many APIs. The following list will give you a broad overview of these APIs functions.
  • LoadFromFile(String filePath): Accept the path of the file that you want to open in C#.NET Windows Viewer Control.
  • SaveFile(String filePath): Save loaded file to a specified path in C#.NET Windows Viewer Control.
  • UpPage, DownPage: Scroll to previous or next visible page in the currently open document.
  • ZoomIn, ZoomOut: Increase or decrease current zoom percentage of C#.NET Windows Viewer.
  • FitWidth, FitHeight, ShowOneToOne: Reset size of the currently displayed page.
  • AddPage: Prior to the currently displayed page to add a blank page.
  • DeletePage: Delete the currently displayed page.
  • Roate90, Rotate180, Rotate270: Rotate the currently displayed page 90, 180 or 270 degrees clockwise.
  • DrawText, DrawFreehand, DrawLine, DrawPolygonLines, DrawFilledRectangle, DrawRectangle, DrawHighLight, DrawEllipse, DrawPolygon, DrawRubberStamp: Draw specified type annotation on viewing page in C#.NET Windows Viewer.
  • BurnAnnotation: Burn all text or graphical annotations to viewing page.
  • DeleteAnnotation: Delete all selected text or graphical annotations.
How to Add Windows Viewer Control in C#.NET Application
This part will guide you to add .NET WinViewer control to your Visual C# project and invoke APIs of this control. See detailed steps below. (For VB.NET developers, please go to Create Windows Image Viewer using VB.NET Programming Code.)
  1. Set up your C#.NET Windows project;
  2. Open file from specified path;
  3. Draw specified type annotation on viewing file page.

Set up C#.NET Windows Project

  1. In Visual Studio, create a new C#.NET Windows Forms project called WinViewerDemo. If you already have a Windows Forms project, this step can be omitted.
  2. Add WinViewer control to your C#.NET project reference. Right-click on "Toolbox", select "Choose Items...", locate "RasterEdge.DocImagSDK8.0\bin" in download package, and browse to find and select "RasterEdge.Imaging.WinformsControl.DocumentViewer.dll", then .NET WinViewer control will appear in Toolbox.

Open File from Specified Path

There may be other elements on your C#.NET Windows application form, but in the following tutorial, we will take a blank form as an example.
  1. Drag the .NET WinViewer control onto your C#.NET Windows application form.
  2. Now, you only need several lines of C#.NET code to open a document in Windows viewer. And the following C#.NET code presents an open file dialog. You can select a file to be loaded into the WinViewer control. If the file format is not supported by .NET WinViewer control, there will prompt a window "cannot open your file".
private void OpenFile_Click(object sender, EventArgse)
{
OpenFileDialogofd = new OpenFileDialog();
ofd.Filter = "(*.*)|*.*";
ofd.Multiselect = false;
if (ofd.ShowDialog() == DialogResult.OK)
{
this.winViewer1.LoadFromFile(ofd.FileName);
}
}

Draw Specified Annotation on Viewing Page

You can directly call a single C#.NET method for each kind of annotation that you want to support in your toolbar button's Onclick events. Resizing, burning, deleting and moving are all built in.
private void HighLight_Click(object sender, EventArgse)
{
this.winViewer1.DrawHighLight();
}

private void Text_Click(object sender, EventArgse)
{
this.winViewer1.DrawText();
}
Right-clicking on the created annotation in C#.NET Windows Viewer, you will see the option to burn or delete. If you right-click on the thumbnail, there is the option to "Add new page" or "delete page". Using RasterEdge .NET WinViewer Control, there's necessary for you to add some buttons to complete these operations.
How to Customize Windows Doc Image Viewer in C#.NET Project

Customize C#.NET Windows Viewer Toolbar

It's easy to see from the above example that you can customize your toolbar in C#.NET Windows Doc Image Viewer, and the only thing you need to do is call the appropriate API.

Customize Annotation Style in C#.NET Windows Viewer

RasterEdge gives you default Annotation Style, but also allows you to modify the style according to your preferences. Here we take the styles modification of HighLight annotation and Text annotation as examples.
private void HighLight_Click(object sender, EventArgse)
{
this.winViewer1.HighLightAnnoStyle.FillColor = Color.Red;
this.winViewer1.HighLightAnnoStyle.Transparency = 0.2f;
this.winViewer1.DrawHighLight();
}
private void Text_Click(object sender, EventArgse)
{
   this.winViewer1.TextAnnoStyle.FillColor = Color.Yellow;
this.winViewer1.TextAnnoStyle.AnnoText = "double click to edit your content";
this.winViewer1.TextAnnoStyle.TextFont = new Font("Arial", 15, FontStyle.Bold | FontStyle.Italic);
this.winViewer1.TextAnnoStyle.Transparency = 0.8f;
this.winViewer1.DrawText();
}

Customize the Way to Open and Store File

The C#.NET WinViewer control offers developers two APIs to LoadFile. One is LoadFromFile(string filePath), and the other is LoadFromFile(Stream stream). Developer can feel free to invoke different APIs to customize the way to open and store files.

Customize Drop-down List of C#.NET Windows Viewer

Events, like OnFileAdded, PageIndexChanged and SelectedIndexChanged, are available to be used to customize the drop-down list of C#.NET Windows Document & Image Viewer. If you don't use the drop-down list, please omit these events.
  • OnFileAdded: Mainly in order to obtain the total number of document pages.
  • PageIndexChanged: Click on thumbnail to change the drop-down list displayed value.
  • SelectedIndexChanged: According to the value of selected drop-down list to switch pages.
See more Image Viewer Creation Tutorial!
More Tutorials!
Find more user guides with RasteEdge .NET Image SDK using Visual C# sample codings!


Recommend this to Google+