Add single-line text to PDF

Generate PDF, Manipulate PDF


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


C# code sample

1 Document document = new Document(); 2 Page page = new Page( PageSize.Letter ); 3 document.Pages.Add(page); 4 5 // Create a text shape to draw text 6 TextShape textShape = new TextShape(50, 750, "Hello World!", new TallComponents.PDF.Fonts.Font(), 16); 7 8 // Add the text to the page 9 page.Overlay.Add(textShape);

VB.NET code sample

1 Dim document As New Document() 2 Dim page As New Page(PageSize.Letter) 3 document.Pages.Add(page) 4 5 ' Create a text shape to draw text 6 Dim textShape As New TextShape(50, 750, "Hello World!", New TallComponents.PDF.Fonts.Font(), 16) 7 8 ' Add the text to the page 9 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):

C# code sample

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

VB.NET code sample

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