Add single-line text to PDF

TextShape allows you to add single-line text to a PDF document.

Example Of Single Line Text To Pdf

Document document = new Document();
Page page = new Page( PageSize.Letter );
document.Pages.Add(page);

// Create a text shape to draw text
TextShape textShape = new TextShape(50, 750, "Hello World!", new TallComponents.PDF.Fonts.Font(), 16);
            
// Add the text to the page
page.Overlay.Add(textShape);
Dim document As New Document()
Dim page As New Page(PageSize.Letter)
document.Pages.Add(page)

' Create a text shape to draw text
Dim textShape As New TextShape(50, 750, "Hello World!", New TallComponents.PDF.Fonts.Font(), 16)

' Add the text to the page
page.Overlay.Add(textShape)

Since it is inherited from Shape, TextShapes can be drawn onto all kinds of canvas such as Page.Overlay, Page.Underlay, Page.VisualOverlay and Page.VisualUnderlay. In addition, the location of all kinds of Shapes can only be set in constructor. After that, the only way to change the location is through transformation. The following statement shows how to move the TextShape to (30, 700):

textShape.Transform = new TallComponents.PDF.Transforms.TranslateTransform(30, 700);
textShape.Transform = New TallComponents.PDF.Transforms.TranslateTransform(30, 700)