Text rise

Docotic.Pdf Library Help > Samples > Text > Text rise
Docotic.Pdf documentation

This sample shows how to adjust baseline of text (useful for drawing superscripts or subscripts) using PdfCanvas.TextRise property.

Text rise specifies the distance to move the baseline up or down from its default location. A positive value for PdfCanvas.TextRise property moves the baseline up, a negative value moves the baseline down.

C# 
using System.Diagnostics;
using System.Drawing;

namespace BitMiracle.Docotic.Pdf.Samples
{
    public static class TextRise
    {
        public static void Main()
        {
            // NOTE: 
            // When used in trial mode, the library imposes some restrictions.
            // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            // for more information.

            string pathToFile = "TextRise.pdf";

            using (PdfDocument pdf = new PdfDocument())
            {
                const string sampleText = "Hello!";
                PdfCanvas canvas = pdf.Pages[0].Canvas;
                canvas.TextPosition = new PdfPoint(10, 50);

                canvas.TextRise = 0;
                canvas.DrawString(sampleText);
                canvas.TextRise = 5;
                canvas.DrawString(sampleText);
                canvas.TextRise = -10;
                canvas.DrawString(sampleText);

                pdf.Save(pathToFile);
            }

            Process.Start(pathToFile);
        }
    }
}
Visual Basic 
Imports System.Diagnostics
Imports System.Drawing

Imports BitMiracle.Docotic.Pdf

Namespace BitMiracle.Docotic.Pdf.Samples
    Public NotInheritable Class TextRise
        Public Shared Sub Main()
            ' NOTE: 
            ' When used in trial mode, the library imposes some restrictions.
            ' Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            ' for more information.

            Dim pathToFile As String = "TextRise.pdf"

            Using pdf As New PdfDocument()

                Const sampleText As String = "Hello!"
                Dim canvas As PdfCanvas = pdf.Pages(0).Canvas
                canvas.TextPosition = New PdfPoint(10, 50)

                canvas.TextRise = 0
                canvas.DrawString(sampleText)
                canvas.TextRise = 5
                canvas.DrawString(sampleText)
                canvas.TextRise = -10
                canvas.DrawString(sampleText)

                pdf.Save(pathToFile)
            End Using

            Process.Start(pathToFile)
        End Sub
    End Class
End Namespace