Write Text To PDF

PDF Art Text Write

Demonstrates writing text as PDF text.

Сode Snippet

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.AdvancedDrawing.Art.RoundText("round text", font)
        {
            Center = new System.Drawing.PointF(width / 2.0f, height / 2.0f),
            Bend = 0.5f,
        };

        graphics.DrawText(roundText);
    }
}

Output

TextToPDF.pdf

Download

TextToPDF.png

For AI-assisted development: Download Graphics Mill Code Samples XML Catalog