Text Annotation in C# Images

How to Draw Text Annotation on Images in .NET Projects using C# Code
Yiigo.Image for .NET SDK includes several component libraries for users to easily add image writing, reading, processing, editing, sizing, rotating, converting, and annotating features into their system. To get it started, users only need to install Microsoft Visual Studio 2005 or above (MS VS Express will also work) first.
Of all the annotations supported by this DLL control, perhaps the most widely used one is the text annotation feature, through which developers can add / write text onto their images, PDF and other documents. Besides, it is quite simple to manipulate text font style, size, family, color and so on, as we have provided detailed imaging tutorial with Visual C# sample codes.
How to Add C# Text Annotation on Images

C# Image Text Annotation - Preparation

  • Install Microsoft VS 2005 or above versions / VS Express
  • Download the Yiigo .NET imaging Toolkit, and unzip to run the exe fill for integration.
  • Activate your purchased license or your requested evaluation license.

Draw a C# Text Annotation on Images

  • Start your Visual Studio and open your C#.NET imaging project.
  • Add the Yiigo.Image.Annotation.dll. from the download SDK to your project.
  • Add the following statements to your project to configure the application for drawing text annotation.
  • Copy the below C# sample code to create a text annotation in your C# image project.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using Yiigo.Image.Annotation;
private void InitializeDefaultAnnotations()
{
// Draw a text annotation.
TextAnnotation textAnnotation = new TextAnnotation();
textAnnotation.Text.Value = "This is a text annotation";
textAnnotation.Name = "TextAnnoDemo1";

// Set the text font style, size, family, and color.
textAnnotation.Font.Bold = True;
textAnnotation.Font.Italic = False;
textAnnotation.Font.Size = 24;
textAnnotation.Font.Family = Times_New_Roman;
textAnnotation.Font.Color = Color.Blue;

// Specify the X and Y coordinates of the lower left corner of the text annotation.
textAnnotation. X = 30;
textAnnotation. Y = 30;

// Now set the pixel size for the text annotation.
textAnnotation.Width = 200;
textAnnotation.Height = 100;

textAnnotation.Opacity = 1;
annotationController1.CurrentLayer.Items.Add(textAnnotation);
}
  • Now you have successfully created a text annotation on your png image, which displays as bold blue "This is a text annotation" sized 24 in Times New Roman.
  • Yiigo image annotation library also provides some other properties for you to customize. Please navigate to the Text Annotation Property section to view more.

C# Image Text Annotation - Property Settings

  • Type stands for annotation type. Default is callout.
  • X and Y stand for the X and Y coordinate of the text annotation in the image/document space.
  • Width and Height stand for the width and height of the text annotation.
  • Resizable is a Boolean which represents whether users are allowed to resize the text annotation, for example, through the grips or a pinch-zoom gesture.
  • Selectable is Boolean that represents whether the text annotation can be selected. If set to true, then the text can be removed or resized.
  • Text.Value is a string which represents the actual text displayed in the text annotation.
  • Text.ReadOnly is a Boolean value. If set to true, then users cannot edit the text.
  • Text.Font has several properties. Bold and Italic are two Boolean values to specify text style. Color is used to represent the text color. You can customize it with the color name supported by the CSS color specification, or with RGB color value. Font Family must be a string supported by the web browser. Default is Times New Roman. Lastly, you can also set the Font Size.

C# Image Text Annotation - Sample Image

Text Annotation Sample
Some More Image Annotations C# Examples
Products
Other Plugins
Image Viewer CoreBarcode PluginPDF Read & WriteTesseract OCR PluginForm Processing PluginJBIG2 CodecJPEG2000 CodecISIS ScannerTwain ScannerDICOM ReaderCAD Scanner