This method uses GDI+ to draw text on the designated object.

[Visual Basic]   [ Boolean = ]imagekitcontrolname.PrintDraw.DrawString(DeviceValue As LONG_PTR, left As Long, top As Long, right As Long, bottom As Long, BrushType As Integer, Style As Integer, ImageHandle As LONG_PTR, TextRenderingHint As Integer, FormatFlags As StringFormatFlagsConstants, DeviceMode As OutPutDeviceModeConstants)
[Visual C++]     [ BOOL = ]imagekitcontrolname.GetPrintDraw().DrawString(LONG_PTR DeviceValue, long left, long top, long right, long bottom, short BrushType, short Style, LONG_PTR ImageHandle, short TextRenderingHint, long FormatFlags, long DeviceMode)
[VB.NET]   [ Boolean = ]imagekitcontrolname.PrintDraw.DrawString(DeviceValue As Integer(x86) or Long(x64), left As Integer, top As Integer, right As Integer, bottom As Integer, BrushType As Short, Style As Short, ImageHandle As Integer(x86) or Long(x64), TextRenderingHint As Short, FormatFlags As ImageKit9(A)Lib.StringFormatFlagsConstants, DeviceMode As ImageKit9(A)Lib.OutPutDeviceModeConstants)
[C#.NET]   [ bool = ]imagekitcontrolname.PrintDraw.DrawString(int(x86) or long(x64) DeviceValue, int left, int top, int right, int bottom, short BrushType, short Style, int(x86) or long(x64) ImageHandle, short TextRenderingHint, ImageKit9(A)Lib.StringFormatFlagsConstants FormatFlags, ImageKit9(A)Lib.OutPutDeviceModeConstants DeviceMode)

* ImageKit9ALib refers to the ANSI version, ImageKit9Lib refers to the Unicode version, (x86) refers to the 32 bit version, and (x64) refers to the 64 bit version.

Parameters

Name Explanation
DeviceValue The device context or the raster image data (i.e. Hdc or ImageHandle) depending on the DeviceMode parameter
left, top The x, y coordinates of the top left corner of the rectangle
right, bottom The x, y coordinates of the bottom right corner of the rectangle
BrushType Sets the brush type (0: Solid, 1: Hatch, 2: Texture, 4: Gradiation)
Style Sets the style for each brush (Disabled when BrushType is 0)
ImageHandle The memory handle of the raster image used with the Texture Brush (BrushType=4)
TextRenderingHint Refers to the text rendering mode (Default is 0)
FormatFlags Format information for the text string (Default is 0)
DeviceMode If 0 (ikScreen), then the output will be drawn in pixel units. If 1 (ikPrinter), the output will be drawn in 0.1mm units. If 2 (ikMemoryHandle), the output will be drawn (in pixel units) to the image data according to the DeviceValue parameter

The following constants can be used: (ikScreen = 0, ikPrinter = 1, ikMemoryHandle = 2).

Return Value

Returns True (nonzero) if successful. Returns False (0) if unsuccessful.

Explanation

The DrawString method uses GDI+ to draw text on the designated object. If the right and bottom parameters are set to 0 then the text will be drawn with a start position determined by the left and top parameters. If the right and bottom parameters are set to values other than 0, then the text will be drawn within a rectangle defined by the left, top, right, and bottom parameters. Any text that cannot fit within this rectangle will be cut.

Supported designated objects are the screen, printer, or image data)

To draw text using the DrawString method, please set the following properties: TextColor1, Alpha1, TextColor2, Alpha2, FontName, FontSize, CharAngle, HCentering, VCentering, HotkeyPrefix, and Text.

When the HotkeyPrefix property is set to values other than 1, prefixed string functionality cannot be used.

The TextColor1 and Alpha1 properties relate to the following: Solid Brush: brush color; Hatch Brush: line color; Gradiation Brush: start color for lined gradiation. The TextColor2 and Alpha2 properties relate to the following: Hatch Brush: background color between the hatch lines; Gradiation Brush: end color for lined gradiation.

If using the gradiation brush (BrushType=4), please set the left, top, right,and bottom parameters

If the DeviceMode parameter is 0 or 2 then the left, top, right, bottom parameters are in pixel units.

If the DeviceMode parameter is 1 then the left, top, right, bottom parameters are in 0.1mm units.

The style settings for each brush

For the Hatch Brush

Value Explanation
0 A pattern of horizontal lines
1 A pattern of vertical lines
2 A pattern of diagonal lines from top left to bottom right
3 A pattern of diagonal lines from top right to bottom left
4 A pattern of horizontal and vertical lines that cross
5 A pattern of crisscross diagonal lines. Antialias has been applied to the lines
6 Specifies a 5-percent hatch. The ratio of foreground color to background color is 5:100
7 Specifies a 10-percent hatch. The ratio of foreground color to background color is 10:100
8 Specifies a 20-percent hatch. The ratio of foreground color to background color is 20:100
9 Specifies a 25-percent hatch. The ratio of foreground color to background color is 25:100
10 Specifies a 30-percent hatch. The ratio of foreground color to background color is 30:100
11 Specifies a 40-percent hatch. The ratio of foreground color to background color is 40:100
12 Specifies a 50-percent hatch. The ratio of foreground color to background color is 50:100
13 Specifies a 60-percent hatch. The ratio of foreground color to background color is 60:100
14 Specifies a 70-percent hatch. The ratio of foreground color to background color is 70:100
15 Specifies a 75-percent hatch. The ratio of foreground color to background color is 75:100
16 Specifies a 80-percent hatch. The ratio of foreground color to background color is 80:100
17 Specifies a 90-percent hatch. The ratio of foreground color to background color is 90:100
18 Specifies diagonal lines that slant to the right from top points to bottom points, are spaced 50 percent closer together than 2. Antialias is not applied
19 Specifies diagonal lines that slant to the left from top points to bottom points, are spaced 50 percent closer together than 3. Antialias is not applied
20 Specifies diagonal lines that slant to the right from top points to bottom points, are spaced 50 percent closer together than 2 and are twice its width. Antialias is not applied
21 Specifies diagonal lines that slant to the left from top points to bottom points, are spaced 50 percent closer together than 3 and are twice its width. Antialias is not applied
22 Specifies diagonal lines that slant to the right from top points to bottom points, are spaced the same as 2 and are three times its width. Antialias is not applied
23 Specifies diagonal lines that slant to the left from top points to bottom points, are spaced the same as 3 and are three times its width. Antialias is not applied
24 Specifies vertical lines that are spaced 50 percent closer together than 1
25 Specifies horizontal lines that are spaced 50 percent closer together than 0
26 Specifies vertical lines that are spaced 75 percent closer together than 1 (or 25 percent closer than 24)
27 Specifies horizontal lines that are spaced 75 percent closer together than 0 (or 25 percent closer than 25)
28 Specifies vertical lines that are spaced 50 percent closer together than 1 and twice as wide
29 Specifies horizontal lines that are spaced 50 percent closer together than 0 and twice as wide
30 Specifies dashed diagonal lines that slant to the right from top points to bottom points
31 Specifies dashed diagonal lines that slant to the left from top points to bottom points
32 Specifies dashed horizontal lines
33 Specifies dashed vertical lines
34 Specifies a hatch that has the appearance of confetti
35 Specifies a hatch that has the appearance of confetti, and is composed of larger pieces than 34
36 Specifies horizontal lines that are composed of zigzags
37 Specifies horizontal lines that are composed of tildes
38 Specifies a hatch that has the appearance of layered bricks that slant to the left from top points to bottom points
39 Specifies a hatch that has the appearance of horizontally layered bricks
40 Specifies a hatch that has the appearance of a woven material
41 Specifies a hatch that has the appearance of a plaid material
42 Specifies a hatch that has the appearance of divots
43 Specifies horizontal and vertical lines, each of which is composed of dots, that cross
44 Specifies forward diagonal and backward diagonal lines, each of which is composed of dots, that cross
45 Specifies a hatch that has the appearance of diagonally layered shingles that slant to the right from top points to bottom points.
46 Specifies a hatch that has the appearance of a trellis
47 Specifies a hatch that has the appearance of spheres laid adjacent to one another
48 Specifies a pattern of horizontal and vertical lines that cross and have a width 50 percent closer together than 4
49 Specifies a hatch that has the appearance of a checkerboard
50 Specifies a hatch that has the appearance of a checkerboard with squares that are twice the size of 49
51 Specifies a pattern of crisscross diagonal lines. Antialias is not applied
52 Specifies a hatch that has the appearance of a checkerboard placed diagonally

For the Texture Brush

Value Explanation
0 Tiles the gradient or texture
1 Reverses the texture or gradient horizontally and then tiles the texture or gradient.
2 Reverses the texture or gradient vertically and then tiles the texture or gradient.
3 Reverses the texture or gradient horizontally and vertically and then tiles the texture or gradient.
4 Clamps the texture or gradient to the object boundary

For the Gradiation Brush

Value Explanation
0 Specifies gradiation from left to right
1 Specifies gradiation from top to bottom
2 Specifies gradiation from top left to bottom right
3 Specifies gradiation from top right to bottom left

For Text Rendering

Value Explanation
0 Each character is drawn using its glyph bitmap, with the system default rendering hint. The text will be drawn using whatever font-smoothing settings the user has selected for the system. 
1 Each character is drawn using its glyph bitmap. Hinting is used to improve character appearance on stems and curvature. 
2 Each character is drawn using its glyph bitmap. Hinting is not used. 
3 Each character is drawn using its antialiased glyph bitmap with hinting. Much better quality due to antialiasing, but at a higher performance cost.
4 Each character is drawn using its antialiased glyph bitmap without hinting. Better quality due to antialiasing. Stem width differences may be noticeable because hinting is turned off.
5 Each character is drawn using its glyph ClearType bitmap with hinting. The highest quality setting. Used to take advantage of ClearType font features.

String format info

Value Explanation
0x00000001 Text is displayed from right to left
0x00000002 Text is vertically aligned.
0x00000004 Parts of characters are allowed to overhang the string's layout rectangle. By default, characters are repositioned to avoid any overhang.
0x00000020 Control characters such as the left-to-right mark are shown in the output with a representative glyph.
0x00000400 Fallback to alternate fonts for characters not supported in the requested font is disabled. Any missing characters are displayed with the fonts missing glyph, usually an open square.
0x00000800 Includes the trailing space at the end of each line. Set this flag to include that space in measurement.
0x00001000 Text wrapping between lines when formatting within a rectangle is disabled. This flag is implied when a point is passed instead of a rectangle, or when the specified rectangle has a zero line length.
0x00002000 Only entire lines are laid out in the formatting rectangle. By default layout continues until the end of the text, or until no more lines are visible as a result of clipping, whichever comes first. Note that the default settings allow the last line to be partially obscured by a formatting rectangle that is not a whole multiple of the line height. To ensure that only whole lines are seen, specify this value and be careful to provide a formatting rectangle at least as tall as the height of one line.
0x00004000 Overhanging parts of glyphs, and unwrapped text reaching outside the formatting rectangle are allowed to show. By default all text and glyph parts reaching outside the formatting rectangle are clipped.

The values of the DrawString method in Visual Basic and in .NET should start with H instead of 0x.

The following constants can be used: (ikDirectionRightToLeft = 0x00000001, ikDirectionVertical = 0x00000002, ikNoFitBlackBox = 0x00000004, ikDisplayFormatControl = 0x00000020, ikNoFontFallback = 0x00000400, ikMeasureTrailingSpaces = 0x00000800, ikNoWrap = 0x00001000, ikLineLimit = 0x00002000, ikNoClip = 0x00004000).

 

Sample code:

Visual Basic

    Dim Str_Width As Single

    Dim Str_Height As Single

    Dim charactersFitted As Long

    Dim linesFilled As Long

    Dim TxRight As Long

    Dim TxBottom As Long

 

    ImageKit1.PrintDraw.FontSize = 20

    ImageKit1.PrintDraw.FontName = "Arial"

    ImageKit1.PrintDraw.HotkeyPrefix = 0

    ImageKit1.PrintDraw.Text = "Text"

    ImageKit1.PrintDraw.MeasureString(hDC, 0, 0, Str_Width, Str_Height, charactersFitted, linesFilled, 0, 0)

 

    TxRight = 10 + CLng(Str_Width) - 1

    TxBottom = 10 + CLng(Str_Height) - 1

    ImageKit1.PrintDraw.CharAngle = 0

    ImageKit1.PrintDraw.TextColor1 = vbRed

    ImageKit1.PrintDraw.Alpha1 = 255

    ImageKit1.PrintDraw.TextColor2 = vbWhite

    ImageKit1.PrintDraw.Alpha2 = 255

    'using the Gradiation Brush

    ImageKit1.PrintDraw.DrawString(hDC, 10, 10, TxRight, TxBottom, 4, 0, 0, 0, 0, 0)

 

Visual C++

    float Str_Width, Str_Height;

    long charactersFitted, linesFilled, right, bottom;

 

    ImageKit1.GetPrintDraw().ClearProperty();

    ImageKit1.GetPrintDraw().SetFontSize(20);

    ImageKit1.GetPrintDraw().SetFontName("Arial");

    ImageKit1.GetPrintDraw().SetHotkeyPrefix(0);

    ImageKit1.GetPrintDraw().SetText("Text");

    ImageKit1.GetPrintDraw().MeasureString(hDC, 0, 0, &Str_Width, &Str_Height, &charactersFitted, &linesFilled, 0, 0);

 

    right = 10 + (long)Str_Width - 1;

    bottom = 10 + (long)Str_Height - 1;

    ImageKit1.GetPrintDraw().SetCharAngle(0);

    ImageKit1.GetPrintDraw().SetTextColor1(RGB(255, 0, 0));

    ImageKit1.GetPrintDraw().SetAlpha1(255);

    ImageKit1.GetPrintDraw().SetTextColor2(RGB(255, 255, 255));

    ImageKit1.GetPrintDraw().SetAlpha2(255);

    //using the Gradiation Brush

    ImageKit1.GetPrintDraw().DrawString(hDC, 10, 10, right, bottom, 4, 0, 0, 0, 0, 0);

 

VB.NET

    Dim Str_Width As Single

    Dim Str_Height As Single

    Dim charactersFitted As Integer

    Dim linesFilled As Integer

    Dim TxRight As Integer

    Dim TxBottom As Integer

 

    ImageKit1.PrintDraw.FontSize = 20

    ImageKit1.PrintDraw.FontName = "Arial"

    ImageKit1.PrintDraw.HotkeyPrefix = 0

    ImageKit1.PrintDraw.Text = "Text"

    ImageKit1.PrintDraw.MeasureString(hDC, 0, 0, Str_Width, Str_Height, charactersFitted, linesFilled, 0, 0)

 

    TxRight = 10 + CLng(Str_Width) - 1

    TxBottom = 10 + CLng(Str_Height) - 1

    ImageKit1.PrintDraw.CharAngle = 0

    ImageKit1.PrintDraw.TextColor1 = ColorTranslator.ToWin32(Color.Red)

    ImageKit1.PrintDraw.Alpha1 = 255

    ImageKit1.PrintDraw.TextColor2 = ColorTranslator.ToWin32(Color.White)

    ImageKit1.PrintDraw.Alpha2 = 255

    'using the Gradiation Brush

    ImageKit1.PrintDraw.DrawString(hDC, 10, 10, TxRight, TxBottom, 4, 0, 0, 0, 0, 0)

 

C#.NET

    float Str_Width, Str_Height;

    int charactersFitted, linesFilled, right, bottom;

 

    Str_Width = Str_Height = 0;

    charactersFitted = linesFilled = 0;

 

    ImageKit1.PrintDraw.FontSize = 20;

    ImageKit1.PrintDraw.FontName = "Arial";

    ImageKit1.PrintDraw.HotkeyPrefix = 0;

    ImageKit1.PrintDraw.Text = "Text";

    ImageKit1.PrintDraw.MeasureString(hDC, 0, 0, ref Str_Width, ref Str_Height, ref charactersFitted, ref linesFilled, 0, 0);

 

    right = 10 + (int)Str_Width - 1;

    bottom = 10 + (int)Str_Height - 1;

    ImageKit1.PrintDraw.CharAngle = 0;

    ImageKit1.PrintDraw.TextColor1 = (uint)ColorTranslator.ToWin32(Color.Red);

    ImageKit1.PrintDraw.Alpha1 = 255;

    ImageKit1.PrintDraw.TextColor2 = (uint)ColorTranslator.ToWin32(Color.White);

    ImageKit1.PrintDraw.Alpha2 = 255;

    //using the Gradiation Brush

    ImageKit1.PrintDraw.DrawString(hDC, 10, 10, right, bottom, 4, 0, 0, 0, 0, 0);

Differences between the ImageKit7/8

The DeviceValue and ImageHandle arguments' type has changed.

The ImageKit9 ActiveX is a product created by Newtone Corporation