---
title: "Add text to image: Set font style, size, color | Nutrient .NET SDK"
canonical_url: "https://www.nutrient.io/guides/dotnet/editor/add-text-to-image/"
md_url: "https://www.nutrient.io/guides/dotnet/editor/add-text-to-image.md"
last_updated: "2026-06-09T10:26:34.524Z"
description: "Learn how to add text to PDFs and images in C#. Explore our comprehensive guide with code examples for efficient editing in .NET applications."
---

# Add text to an image using C#

### PDF

[PDF](https://www.nutrient.io/guides/dotnet/editor/add-text-to-pdf.md)

### Image

[Image](https://www.nutrient.io/guides/dotnet/editor/add-text-to-image.md)

## Adding text to images

To add simple, one-line text to an image file, use the [`DrawText`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~DrawText.html) method. It requires the parameters outlined below.

- `ImageID` — The GdPicture image ID of the loaded image.

- `Text` — The body of the text.

- `DstLeft` — The horizontal distance between the coordinate origin and the upper-left corner of the text (in pixels).

- `DstTop` — The vertical distance between the coordinate origin and the upper-left corner of the text (in pixels).

- `FontSize` — The font size in units specified by the [`FontSetUnit`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~FontSetUnit.html) method. The possible values are the following:
  - `UnitPoint`
  - `UnitInch`
  - `UnitPixel`
  - `UnitDocument` (1/300 inch)

- `FontStyle` — The font size set by the `FontStyle` enumeration. The possible values are the following:
  - `Regular`
  - `Bold`
  - `Italic`
  - `Underline`
  - `Strikeout`

- `TextColor` — The text color specified by the [`ARGB`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ARGB.html) method or the [`Color`](https://www.nutrient.io/guides/dotnet/editor/manipulation/colors/#color-object) object.

- `FontName` —The name of the font used.

- `AntiAlias` — Applies the antialiasing algorithm if set to `true`.

To add text to an image, use the following code:

### C#

```csharp

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
int imageID = gdpictureImaging.CreateGdPictureImageFromFile(@"C:\temp\source.jpg");
// Set the font size unit to points.
gdpictureImaging.FontSetUnit(UnitMode.UnitPoint);
// Add the text to the image.
gdpictureImaging.DrawText(imageID, "GdPicture.NET", 5, 5, 40, FontStyle.Regular,
    gdpictureImaging.ARGB(100, 128, 128, 128), "Arial", true);
gdpictureImaging.SaveAsJPEG(imageID, @"C:\temp\output.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);

```

### VB.NET

```vb

Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    Dim imageID As Integer = gdpictureImaging.CreateGdPictureImageFromFile("C:\temp\source.jpg")
    ' Set the font size unit to points.
    gdpictureImaging.FontSetUnit(UnitMode.UnitPoint)
    ' Add the text to the image.
    gdpictureImaging.DrawText(imageID, "GdPicture.NET", 5, 5, 40, FontStyle.Regular,
        gdpictureImaging.ARGB(100, 128, 128, 128), "Arial", True)
    gdpictureImaging.SaveAsJPEG(imageID, "C:\temp\output.jpg")
    gdpictureImaging.ReleaseGdPictureImage(imageID)
End Using

```

#### Used methods

- [`ARGB`]

- [`CreateGdPictureImageFromFile`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~CreateGdPictureImageFromFile.html)

- [`DrawText`]

- [`FontSetUnit`]

- [`ReleaseGdPictureImage`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ReleaseGdPictureImage.html)

- [`SaveAsJPEG`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~SaveAsJPEG.html)

## Adding gradient text to images

To add text with a linear gradient to an image, use the [`DrawTextGradient`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~DrawTextGradient.html) method. This method uses the same parameters as the [`DrawText`](https://www.nutrient.io/guides/dotnet/editor/add-text-to-image/#adding-text-to-images) method, but the `TextColor` parameter is replaced by the `StartColor` and `EndColor` parameters. These parameters accept either the [`ARGB`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ARGB.html) method or the [`Color`](https://www.nutrient.io/guides/dotnet/editor/manipulation/colors/#color-object) object.

To add gradient text to an image, use the following code:

### C#

```csharp

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
int imageID = gdpictureImaging.CreateGdPictureImageFromFile(@"C:\temp\source.jpg");
// Set the font size unit to points.
gdpictureImaging.FontSetUnit(UnitMode.UnitPoint);
// Add the text with a black-to-white gradient to the image.
gdpictureImaging.DrawTextGradient(imageID, "GdPicture.NET", 100, 50,
    gdpictureImaging.ARGB(255, 0, 0, 0), gdpictureImaging.ARGB(255, 255, 255, 255),
    40, FontStyle.Regular, "Arial", true);
gdpictureImaging.SaveAsJPEG(imageID, @"C:\temp\output.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);

```

### VB.NET

```vb

Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    Dim imageID As Integer = gdpictureImaging.CreateGdPictureImageFromFile("C:\temp\source.jpg")
    ' Set the font size unit to points.
    gdpictureImaging.FontSetUnit(UnitMode.UnitPoint)
    ' Add the text with a black-to-white gradient to the image.
    gdpictureImaging.DrawTextGradient(imageID, "GdPicture.NET", 100, 50,
        gdpictureImaging.ARGB(255, 0, 0, 0), gdpictureImaging.ARGB(255, 255, 255, 255),
        40, FontStyle.Regular, "Arial", True)
    gdpictureImaging.SaveAsJPEG(imageID, "C:\temp\output.jpg")
    gdpictureImaging.ReleaseGdPictureImage(imageID)
End Using

```

#### Used methods

- [`ARGB`]

- [`CreateGdPictureImageFromFile`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~CreateGdPictureImageFromFile.html)

- [`DrawTextGradient`]

- [`FontSetUnit`]

- [`ReleaseGdPictureImage`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ReleaseGdPictureImage.html)

- [`SaveAsJPEG`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~SaveAsJPEG.html)

## Adding textured text

To add textured text to an image, use one of the following methods:

- [`DrawTextTextureFromFile`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~DrawTextTextureFromFile.html) — Texture source as a file.

- [`DrawTextTextureFromGdPictureImage`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~DrawTextTextureFromGdPictureImage.html) — Texture source as a GdPicture image.

These methods use the same parameters as the [`DrawText`](https://www.nutrient.io/guides/dotnet/editor/add-text-to-image/#adding-text-to-images) method, but the `TextColor` parameter is replaced by the following:

- `TextureFilePath` in the `DrawTextTextureFromFile`. This parameter specifies the path to the file that’s used as the texture of the text.

- `ImageTexture` in the `DrawTextTextureFromGdPictureImage`. This parameter specifies the image ID of the file loaded in your project.

To add textured text to an image, use the following code:

### C#

```csharp

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
int imageID = gdpictureImaging.CreateGdPictureImageFromFile(@"C:\temp\source.jpg");
// Set the font size unit to points.
gdpictureImaging.FontSetUnit(UnitMode.UnitPoint);
// Add the text with a black-to-white gradient to the image.
gdpictureImaging.DrawTextTextureFromFile(imageID, @"C:\temp\texture.jpg",
    100, 50, 40, FontStyle.Regular, "Arial", true);
gdpictureImaging.SaveAsJPEG(imageID, @"C:\temp\output.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);

```

### VB.NET

```vb

Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    Dim imageID As Integer = gdpictureImaging.CreateGdPictureImageFromFile("C:\temp\source.jpg")
    ' Set the font size unit to points.
    gdpictureImaging.FontSetUnit(UnitMode.UnitPoint)
    ' Add the text with a black-to-white gradient to the image.
    gdpictureImaging.DrawTextTextureFromFile(imageID, "C:\temp\texture.jpg",
        100, 50, 40, FontStyle.Regular, "Arial", true)
    gdpictureImaging.SaveAsJPEG(imageID, "C:\temp\output.jpg")
    gdpictureImaging.ReleaseGdPictureImage(imageID)
End Using

```

#### Used methods

- [`CreateGdPictureImageFromFile`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~CreateGdPictureImageFromFile.html)

- [`DrawTextTextureFromFile`]

- [`FontSetUnit`]

- [`ReleaseGdPictureImage`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ReleaseGdPictureImage.html)

- [`SaveAsJPEG`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~SaveAsJPEG.html)

#### Related topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)

## Adding rotated text to images

To add text rotated at an angle to an image, use the [`DrawRotatedText`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~DrawRotatedText.html) method. It requires the parameters outlined below.

- `ImageID` — The GdPicture image ID of the loaded image.

- `Angle` — The clockwise angle at which the text is rotated (in degrees).

- `Text` — The body of the text.

- `DstLeft` — The horizontal distance between the coordinate origin and the upper-left corner of the text (in pixels).

- `DstTop` — The vertical distance between the coordinate origin and the upper-left corner of the text (in pixels).

- `FontSize` — The font size in units specified by the [`FontSetUnit`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~FontSetUnit.html) method. The possible values are the following:
  - `UnitPoint`
  - `UnitInch`
  - `UnitPixel`
  - `UnitDocument` (1/300 inch)

- `FontStyle` — The font size set by the `FontStyle` enumeration. The possible values are the following:
  - `Regular`
  - `Bold`
  - `Italic`
  - `Underline`
  - `Strikeout`

- `TextColor` — The text color specified by the [`ARGB`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ARGB.html) method or the [`Color`](https://www.nutrient.io/guides/dotnet/editor/manipulation/colors/#color-object) object.

- `FontName` — The name of the font used.

- `AntiAlias` — Applies the antialiasing algorithm if set to `true`.

To add text to an image rotated at a 90-degree angle, use the following code:

### C#

```csharp

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
int imageID = gdpictureImaging.CreateGdPictureImageFromFile(@"C:\temp\source.jpg");
// Set the font size unit to points.
gdpictureImaging.FontSetUnit(UnitMode.UnitPoint);
// Add the text to the image rotated at 90 degrees clockwise.
gdpictureImaging.DrawRotatedText(imageID, 90, "GdPicture.NET", 100, 50, 40,
    FontStyle.Regular, gdpictureImaging.ARGB(100, 128, 128, 128), "Arial", true);
gdpictureImaging.SaveAsJPEG(imageID, @"C:\temp\output.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);

```

### VB.NET

```vb

Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    Dim imageID As Integer = gdpictureImaging.CreateGdPictureImageFromFile("C:\temp\source.jpg")
    ' Set the font size unit to points.
    gdpictureImaging.FontSetUnit(UnitMode.UnitPoint)
    ' Add the text to the image rotated at 90 degrees clockwise.
    gdpictureImaging.DrawRotatedText(imageID, 90, "GdPicture.NET", 100, 50, 40,
        FontStyle.Regular, gdpictureImaging.ARGB(100, 128, 128, 128), "Arial", True)
    gdpictureImaging.SaveAsJPEG(imageID, "C:\temp\output.jpg")
    gdpictureImaging.ReleaseGdPictureImage(imageID)
End Using

```

#### Used methods

- [`ARGB`]

- [`CreateGdPictureImageFromFile`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~CreateGdPictureImageFromFile.html)

- [`DrawRotatedText`]

- [`FontSetUnit`]

- [`ReleaseGdPictureImage`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ReleaseGdPictureImage.html)

- [`SaveAsJPEG`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~SaveAsJPEG.html)

#### Related topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)

## Adding text with a background to images

To add text with a background to an image, use the following methods:

- [`DrawTextBackColor`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~DrawTextBackColor.html) adds simple text with a background.

- [`DrawRotatedTextBackColor`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~DrawRotatedTextBackColor.html) adds simple text with a background at a specified clockwise angle (in degrees).

Both of these methods accept the same parameters as the [`DrawText`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~DrawText.html) and [`DrawRotatedText`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~DrawRotatedText.html) methods, respectively. They also accept the `BackColor` parameter, which specifies the color of the background. This parameter is declared after the `TextColor` parameter.

To add white text with a black background (semitransparent) rotated at a 90-degree angle, use the following method:

### C#

```csharp

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
int imageID = gdpictureImaging.CreateGdPictureImageFromFile(@"C:\temp\source.jpg");
// Set the font size unit to points.
gdpictureImaging.FontSetUnit(UnitMode.UnitPoint);
// Declare a `Color` object for the text font.
Color textColor = Color.White;
// Add the text to the image rotated at 90 degrees clockwise with a semitransparent black background.
gdpictureImaging.DrawRotatedTextBackColor(imageID, 90, "GdPicture.NET", 100, 50, 40,
    FontStyle.Regular, textColor, gdpictureImaging.ARGB(100, 0, 0, 0), "Arial", true);
gdpictureImaging.SaveAsJPEG(imageID, @"C:\temp\output.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);

```

### VB.NET

```vb

Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    Dim imageID As Integer = gdpictureImaging.CreateGdPictureImageFromFile("C:\temp\source.jpg")
    ' Set the font size unit to points.
    gdpictureImaging.FontSetUnit(UnitMode.UnitPoint)
    ' Declare a `Color` object for the text font.
    Dim textColor As Color = Color.White
    ' Add the text to the image rotated at 90 degrees clockwise with a semitransparent black background.
    gdpictureImaging.DrawRotatedTextBackColor(imageID, 90, "GdPicture.NET", 100, 50, 40,
        FontStyle.Regular, textColor, gdpictureImaging.ARGB(100, 0, 0, 0), "Arial", True)
    gdpictureImaging.SaveAsJPEG(imageID, "C:\temp\output.jpg")
    gdpictureImaging.ReleaseGdPictureImage(imageID)
End Using

```

#### Used methods

- [`ARGB`]

- [`CreateGdPictureImageFromFile`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~CreateGdPictureImageFromFile.html)

- [`DrawRotatedTextBackColor`]

- [`FontSetUnit`]

- [`ReleaseGdPictureImage`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ReleaseGdPictureImage.html)

- [`SaveAsJPEG`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~SaveAsJPEG.html)

#### Related topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)

## Adding text boxes to images

To add a text box to an image, use the [`DrawTextBox`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~DrawTextBox.html) method. It requires the parameters outlined below.

- `ImageID` — The GdPicture image ID of the loaded image.

- `Text`— The body of the text box.

- `Left` — The horizontal distance between the coordinate origin and the upper-left corner of the text box (in pixels).

- `Top` — The vertical distance between the coordinate origin and the upper-left corner of the text box (in pixels).

- `Width` — The width of the text box (in pixels).

- `Height` — The height of the text box (in pixels).

- `FontSize` — The font size in units specified by the [`FontSetUnit`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~FontSetUnit.html) method. The possible values are the following:
  - `UnitPoint`
  - `UnitInch`
  - `UnitPixel`
  - `UnitDocument` (1/300 inch)

- `Alignment` — The horizontal text alignment specified by the `TextAlignment` enumeration. The possible values are the following:
  - `TextAlignmentCenter` aligns text to the center.
  - `TextAlignmentNear` aligns text to the left side in left-to-right writing systems. In right-to-left systems, it’s aligned to the right.
  - `TextAlignmentFar` aligns text to the right side in left-to-right writing systems. In right-to-left systems, it’s aligned to the left.

- `FontStyle` — The font size set by the `FontStyle` enumeration. The possible values are the following:
  - `Regular`
  - `Bold`
  - `Italic`
  - `Underline`
  - `Strikeout`

- `TextColor` — The text color specified by the [`ARGB`](https://www.nutrient.io/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ARGB.html) method or the [`Color`](https://www.nutrient.io/guides/dotnet/editor/manipulation/colors/#color-object) object.

- `FontName` — The name of the font used.

- `DrawBox` — The Boolean value for drawing the borders of the text box.

- `AntiAlias` — The Boolean value for applying the antialiasing algorithm.

To add a text box to an image, use the following code:

### C#

```csharp

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
int imageID = gdpictureImaging.CreateGdPictureImageFromFile(@"C:\temp\source.jpg");
// Set the font size unit to points.
gdpictureImaging.FontSetUnit(UnitMode.UnitPoint);
// Add the text to the image rotated at 90 degrees clockwise.
gdpictureImaging.DrawTextBox(imageID, "GdPicture.NET", 100, 50, 300, 200, 40,
    TextAlignment.TextAlignmentCenter, FontStyle.Regular,
    gdImage.ARGB(100, 128, 128, 128), "Arial", true, true);
gdpictureImaging.SaveAsJPEG(imageID, @"C:\temp\output.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);

```

### VB.NET

```vb

Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    Dim imageID As Integer = gdpictureImaging.CreateGdPictureImageFromFile("C:\temp\source.jpg")
    ' Set the font size unit to points.
    gdpictureImaging.FontSetUnit(UnitMode.UnitPoint)
    ' Add the text to the image rotated at 90 degrees clockwise.
    gdpictureImaging.DrawTextBox(imageID, "GdPicture.NET", 100, 50, 300, 200, 40,
        TextAlignment.TextAlignmentCenter, FontStyle.Regular,
        gdImage.ARGB(100, 128, 128, 128), "Arial", True, True)
    gdpictureImaging.SaveAsJPEG(imageID, "C:\temp\output.jpg")
    gdpictureImaging.ReleaseGdPictureImage(imageID)
End Using

```

#### Used methods

- [`ARGB`]

- [`CreateGdPictureImageFromFile`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~CreateGdPictureImageFromFile.html)

- [`DrawTextBox`]

- [`FontSetUnit`]

- [`ReleaseGdPictureImage`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~ReleaseGdPictureImage.html)

- [`SaveAsJPEG`](/api/gdpicture/GdPicture.NET.14~GdPicture14.GdPictureImaging~SaveAsJPEG.html)

#### Related topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)
---

## Related pages

- [Add an image to another image using C#](/guides/dotnet/editor/add-image-to-image.md)
- [Add an image to a PDF using C#](/guides/dotnet/editor/add-image-to-pdf.md)
- [Add a page to a PDF or a TIFF image in C# .NET](/guides/dotnet/editor/add-page.md)
- [Attach a file to a PDF in C#](/guides/dotnet/editor/attach-a-file.md)
- [Add text to PDFs in C#](/guides/dotnet/editor/add-text-to-pdf.md)
- [Merge PDFs in C#](/guides/dotnet/editor/merge-or-combine.md)
- [PDF and image editor in C#.NET](/guides/dotnet/editor.md)
- [Modify EXIF metadata using C#](/guides/dotnet/editor/metadata-exif.md)
- [Edit IPTC metadata using C#](/guides/dotnet/editor/metadata-iptc.md)
- [Split PDF pages into multiple pages in C#](/guides/dotnet/editor/split.md)
- [Read and edit PDF page label metadata using C#](/guides/dotnet/editor/metadata-pdf-page-label.md)
- [Read and edit PDF XMP metadata using C#](/guides/dotnet/editor/metadata-xmp.md)
- [Add watermarks to PDFs and images in C#](/guides/dotnet/editor/watermark.md)

