With SautinSoft.Pdf you can write rich text in PDF from your C# or VB.NET application.
Rich text can be represented by the PdfFormattedText class:
The following example shows how to easily create a PDF document and write rich text on its first page.
Complete code
using System;
using SautinSoft.Pdf;
using System.IO;
using SautinSoft.Pdf.Content;
class Program
{
/// <remarks>
/// Details: https://sautinsoft.com/products/pdf/help/net/developer-guide/create-pdf.php
/// </remarks>
static void Main()
{
// Before starting this example, please get a free 30-day trial key:
// https://sautinsoft.com/start-for-free/
// Apply the key here:
// PdfDocument.SetLicense("...");
PdfDocument document = new PdfDocument();
if (document != null)
{
Console.WriteLine("File created successfully!");
}
}
}
The fonts used in the above examples are system fonts and must be placed in the directory specified by the operating system. To use non-system fonts (from a custom directory or embedded in an assembly), see the private font example.
The text in the example above is formatted to an infinite width. The following example shows how to format the text to a finite width and draw the text in various positions using the text size information, in various alignments.
If you need a new code example or have a question: email us at support@sautinsoft.com or ask at Online Chat (right-bottom corner of this page) or use the Form below: