Create PDF files in C# and VB.NET

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:

  • Append text and line breaks.
  • Set various formatting options, such as alignment, font (family, style, weight, stretch, and size), language, color, and opacity.
  • Set the maximum width of text or the maximum width of each line of text, and line height.
  • Set the text formatting mode (implementation of the text layout and text shaping).
  • Get the formatted text width and height.

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:
    /// </remarks>
    static void Main()
        // Before starting this example, please get a free 30-day trial key:

        // 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 or ask at Online Chat (right-bottom corner of this page) or use the Form below:

Questions and suggestions from you are always welcome!

We are developing .Net components since 2002. We know PDF, DOCX, RTF, HTML, XLSX and Images formats. If you need any assistance with creating, modifying or converting documents in various formats, we can help you. We will write any code example for you absolutely free.