PDF .NET Library Logo
Home Products Code Library Online Demos Support Forum Buy About Us  
Code Library

How to create text in PDF using the TextOut Method

The code sample below creates a PDF document with a URL on it.

c# sample:

PDFDocument doc = new PDFDocument("sample.pdf");

doc.CurrentPage.Body.SetActiveFont("Arial", PDFFontStyles.Underline, 12, Charset.ANSI_CHARSET, Color.Blue);

doc.CurrentPage.Body.TextOut(10, 10, 0, "Please visit us.");

float width = (float)doc.CurrentPage.Body.GetTextWidth("Please visit us.");

float fontSize = (float)doc.CurrentPage.Body.GetFontSize();

doc.CurrentPage.Body.AddUrl(new RectangleF(10,10, 10 + width, fontSize), "http://www.pdf-technologies.com");

doc.Save();

Back to PDF Code Library