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

[C++Builder]   [ bool = ]imagekitcontrolname->PrintDraw->DrawString(NativeUInt DeviceValue, int ALeft, int ATop, int ARight, int ABottom, short BrushType, short Style, NativeUInt ImageHandle, short TextRenderingHint, int FormatFlags, TVIkOutPutDeviceMode DeviceMode)
[C++Builder]   [ bool = ]imagekitcontrolname->PrintDraw->DrawString(NativeUInt DeviceValue, const TRect &ARect, short BrushType, short Style, NativeUInt ImageHandle, short TextRenderingHint, int FormatFlags, TVIkOutPutDeviceMode DeviceMode)
[C++Builder]   [ bool = ]imagekitcontrolname->PrintDraw->DrawString(void * DeviceValue, int ALeft, int ATop, int ARight, int ABottom, short BrushType, short Style, NativeUInt ImageHandle, short TextRenderingHint, int FormatFlags, TVIkOutPutDeviceMode DeviceMode)
[C++Builder]   [ bool = ]imagekitcontrolname->PrintDraw->DrawString(void * DeviceValue, const TRect &ARect, short BrushType, short Style, NativeUInt ImageHandle, short TextRenderingHint, int FormatFlags, TVIkOutPutDeviceMode DeviceMode)
[Delphi]   [ Boolean = ]imagekitcontrolname.PrintDraw.DrawString(DeviceValue: THandle; ALeft: Integer; ATop: Integer; ARight: Integer; ABottom: Integer; BrushType: Smallint; Style: Smallint; ImageHandle: THandle; TextRenderingHint: Smallint; FormatFlags: Integer; DeviceMode: TVIkOutPutDeviceMode)
[Delphi]   [ Boolean = ]imagekitcontrolname.PrintDraw.DrawString(DeviceValue: THandle; const ARect: TRect; BrushType: Smallint; Style: Smallint; ImageHandle: THandle; TextRenderingHint: Smallint; FormatFlags: Integer; DeviceMode: TVIkOutPutDeviceMode)
[Delphi]   [ Boolean = ]imagekitcontrolname.PrintDraw.DrawString(DeviceValue: Pointer; ALeft: Integer; ATop: Integer; ARight: Integer; ABottom: Integer; BrushType: Smallint; Style: Smallint; ImageHandle: THandle; TextRenderingHint: Smallint; FormatFlags: Integer; DeviceMode: TVIkOutPutDeviceMode)
[Delphi]   [ Boolean = ]imagekitcontrolname.PrintDraw.DrawString(DeviceValue: Pointer; const ARect: TRect; BrushType: Smallint; Style: Smallint; ImageHandle: THandle; TextRenderingHint: Smallint; FormatFlags: Integer; DeviceMode: TVIkOutPutDeviceMode)

[TVIkOutPutDeviceMode Type]

Unit
     IkInit

type
     TVIkOutPutDeviceMode = (vikScreen, vikPrinter, vikMemoryHandle);

Parameters

Name Explanation
DeviceValue The device context or the raster image data depending on the DeviceMode parameter
ALeft, ATop The x, y coordinates of the top left corner of the bounding rectangle
ARight, ABottom The x, y coordinates of the bottom right corner of the bounding rectangle
ARect The x, y coordinates of the bounding 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 vikScreen, then the output will be drawn in pixel units. If vikPrinter, the output will be drawn in 0.1mm units. If vikMemoryHandle), the output will be drawn (in pixel units) to the image data according to the DeviceValue parameter

Use either ALeft, ATop, ARight, ABottom or ARect.

Return Value

Returns True if successful. Returns False 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 (memory handle)

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 vikScreen or vikMemoryHandle, then the ALeft, ATop, ARight, ABottom, (or ARect), X1, Y1, X2, Y2 parameters are in pixel units.

If the DeviceMode parameter is vikPrinter, then the ALeft, ATop, ARight, ABottom, (or ARect), X1, Y1, X2, Y2 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 Delphi should start with $ instead of 0x.

The following constants can be used: (vikDirectionRightToLeft = 0x00000001, vikDirectionVertical = 0x00000002, vikNoFitBlackBox = 0x00000004, vikDisplayFormatControl = 0x00000020, vikNoFontFallback = 0x00000400, vikMeasureTrailingSpaces = 0x00000800, vikNoWrap = 0x00001000, vikLineLimit = 0x00002000, vikNoClip = 0x00004000).

 

Sample code:

In C++Builder

float Str_Width, Str_Height;
int charactersFitted, linesFilled, ARight, ABottom;

VImageKit1->PrintDraw->ClearProperty();
VImageKit1->PrintDraw->FontSize = 20;
VImageKit1->PrintDraw->FontName = "Arial";
VImageKit1->PrintDraw->HotkeyPrefix = 0;
VImageKit1->PrintDraw->Text = "Text";
VImageKit1->PrintDraw->MeasureString(DC, 0, 0, Str_Width, Str_Height, charactersFitted, linesFilled, 0, vikPrinterPixel);

ARight = 10 + (int)Str_Width - 1;
ABottom = 10 + (int)Str_Height - 1;
VImageKit1->PrintDraw->CharAngle = 0;
VImageKit1->PrintDraw->TextColor1 = clRed;
VImageKit1->PrintDraw->Alpha1 = 255;
VImageKit1->PrintDraw->TextColor2 = clWhite;
VImageKit1->PrintDraw->Alpha2 = 255;
//Use gradiation brush
VImageKit1->PrintDraw->DrawString(DC, 10, 10, ARight, ABottom, 4, 0, 0, 0, 0, TVIkOutPutDeviceMode(vikPrinterPixel));

In Delphi

Str_Width, Str_Height: Single;
CharactersFitted, linesFilled, TxRight, TxBottom: Integer;

VImageKit1.PrintDraw.ClearProperty();
VImageKit1.PrintDraw.FontSize := 20;
VImageKit1.PrintDraw.FontName := 'Arial';
VImageKit1.PrintDraw.HotkeyPrefix := 0;
VImageKit1.PrintDraw.Text := 'Text';
VImageKit1.PrintDraw.MeasureString(DC, 0, 0, Str_Width, Str_Height, charactersFitted, linesFilled, 0, vikPrinterPixel);

TxRight := 10 + Trunc(Str_Width) - 1;
TxBottom := 10 + Trunc(Str_Height) - 1;
VImageKit1.PrintDraw.CharAngle := 0;
VImageKit1.PrintDraw.TextColor1 := clRed;
VImageKit1.PrintDraw.Alpha1 := 255;
VImageKit1.PrintDraw.TextColor2 := clWhite;
VImageKit1.PrintDraw.Alpha2 := 255;
//Use gradiation brush
VImageKit1.PrintDraw.DrawString(DC, 10, 10, TxRight, TxBottom, 4, 0, 0, 0, 0, TVIkOutPutDeviceMode(vikPrinterPixel));

Differences between the ImageKit7/8/9

In VCL the constants contain a "v". In ActiveX, the constants are: ikScreen, ikPrinter, ikMemoryHandle, ikDirectionRightToLeft, ikDirectionVertical, ikNoFitBlackBox, ikDisplayFormatControl, ikNoFontFallback, ikMeasureTrailingSpaces, ikNoWrap, ikLineLimit, ikNoClip.
Methods that pass a TRect type have been added.

The ImageKit10 VCL is a product created by Newtone Corporation