---
title: "Write Text To PDF"
canonical: https://www.graphicsmill.com/samples/Codecs/Pdf/WriteTextToPDF_cs
product: "Graphics Mill"
source: "Codecs/Pdf/WriteTextToPDF.cs"
---

# Write Text To PDF

Demonstrates writing text as PDF text.

## Instruction

Write a C# program that demonstrates how to write text as PDF text (using embedded fonts) to a PDF file, including both plain and round text.

## Usings

```csharp
using Aurigma.GraphicsMill.Codecs;
using Aurigma.GraphicsMill.Drawing;
```

## Code Snippet

```csharp
using (var writer = new PdfWriter("TextToPDF.pdf"))
{
    int width = 350;
    int height = 200;

    using (var graphics = writer.GetGraphics())
    {
        // Text objects will be saved as a PDF text with embedded fonts.
        // The only type of text that can't be saved as text is DoublePath text.
        writer.TextOutputMode = PdfTextOutputMode.Text;

        writer.AddPage(width, height, RgbColor.White);

        var font = graphics.CreateFont("Arial", 18f);

        // Plain text
        var plainText = new PlainText("plain text", font, new SolidBrush(RgbColor.Black), 95f, 41f, TextAlignment.Center);
        graphics.DrawText(plainText);

        // Round text
        var roundText = new Aurigma.GraphicsMill.Drawing.Art.RoundText("round text", font)
        {
            Center = new System.Drawing.PointF(width / 2.0f, height / 2.0f),
            Bend = 0.5f,
        };

        graphics.DrawText(roundText);
    }
}
```

## Explanation

Below is a C# code sample that demonstrates how to write text as PDF text to a PDF file. It includes both plain text and round text, ensuring that text is stored as PDF text rather than graphics.

This code creates a PDF document containing both plain text and round text, with embedded fonts for both types of text.

## Tags

- [Art Text](<https://www.graphicsmill.com/samples/tags/art-text_md>): Creating artistic text
- [PDF](<https://www.graphicsmill.com/samples/tags/pdf_md>): Importing and exporting PDF documents
- [Write](<https://www.graphicsmill.com/samples/tags/write_md>): Writing images with codecs

## Output

- [TextToPDF.pdf](<https://www.graphicsmill.com/samples/Codecs/compiled/Debug/TextToPDF_pdf>) (download)
- [TextToPDF.png](<https://www.graphicsmill.com/samples/Codecs/compiled/Debug/TextToPDF_png>) (preview)

## Used APIs

- [Aurigma.GraphicsMill.Codecs.PdfTextOutputMode](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_PdfTextOutputMode.htm.md>)
- [Aurigma.GraphicsMill.Codecs.PdfWriter](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Codecs_PdfWriter.htm.md>)
- [Aurigma.GraphicsMill.Codecs.PdfWriter.AddPage(Single,Single,Color)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Codecs_PdfWriter_AddPage_3_edd08af9.htm.md>)
- [Aurigma.GraphicsMill.Codecs.PdfWriter.GetGraphics](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Codecs_PdfWriter_GetGraphics.htm.md>)
- [Aurigma.GraphicsMill.Codecs.PdfWriter.TextOutputMode](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Codecs_PdfWriter_TextOutputMode.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Art.ArtText.Center](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Art_ArtText_Center.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Art.RoundText](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_Art_RoundText.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Art.RoundText.Bend](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Art_RoundText_Bend.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.CreateFont(String,Single)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_CreateFont_2_1dbfa9fa.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.DrawText(Text)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_DrawText_1_f576d03f.htm.md>)
- [Aurigma.GraphicsMill.Drawing.PlainText](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_PlainText.htm.md>)
- [Aurigma.GraphicsMill.Drawing.SolidBrush](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_SolidBrush.htm.md>)
- [Aurigma.GraphicsMill.Drawing.TextAlignment](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_TextAlignment.htm.md>)
