PDF .NET Library Logo

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");


Back to PDF Code Library