PDF Library for C# and VB.NET applications

The fastest way to get started with the GemBox.Pdf library is by exploring our collection of C# and VB.NET examples. These are live examples that show supported features and APIs for achieving various PDF-related tasks with the GemBox.Pdf component.

System Requirements

GemBox.Pdf requires only .NET, it doesn't have any other dependency.
You can use it on:

  • .NET 6.0 on Windows
  • .NET Standard 2.0 (for Linux, macOS, Android, iOS, …)
  • .NET Framework 3.5 - 4.8

Hello World

The first step in using the GemBox.Pdf library is to add a reference to GemBox.Pdf.dll within your C# or VB.NET project. There are three ways to do that.

a) Add from NuGet.

You can add GemBox.Pdf as a package by using the following command from the NuGet Package Manager Console:

Install-Package GemBox.Pdf

Or you can search and add GemBox.Pdf from the NuGet Package Manager.

Adding GemBox.Pdf library from NuGet

b) Add from a DLL file.

You can download a GemBox.Pdf.dll file from this page and add a reference by browsing to it.

Adding GemBox.Pdf library from DLL

c) Add from Setup.

You can download the GemBox.Pdf Setup from this page. After installing the setup, you can add a reference to GemBox.Pdf.dll from the Global Assembly Cache (GAC).

Adding GemBox.Pdf library from GAC

The second step is to add a directive for the GemBox.Pdf namespace.

For a C# project, use: using GemBox.Pdf;
For a VB.NET project, use: Import GemBox.Pdf

Since the following example draws text to PDF page content, add a directive for the GemBox.Pdf.Content namespace.

For a C# project, use: using GemBox.Pdf.Content;
For a VB.NET project, use: Import GemBox.Pdf.Content

The third step is to set the license key to use GemBox.Pdf in one of its working modes.

To use a Free mode in a C# project, use: ComponentInfo.SetLicense("FREE-LIMITED-KEY");
To use a Free mode in a VB.NET project, use: ComponentInfo.SetLicense("FREE-LIMITED-KEY")

You can read more about GemBox.Pdf's working modes on the Evaluation and Licensing help page.

The last step is to write your application-specific PDF code, like the following example code, which shows how to create a simple PDF document with "Hello World!" text. It shows how to initialize the GemBox.Pdf document structure, add new PdfPage, draw PdfFormattedText, and then save a PdfDocument to a PDF file.

Simple PDF file created with GemBox.Pdf
Screenshot of simple PDF file created with GemBox.Pdf
using GemBox.Pdf;
using GemBox.Pdf.Content;

class Program
    static void Main()
        // If using the Professional version, put your serial key below.

        using (var document = new PdfDocument())
            // Add a page.
            var page = document.Pages.Add();

            // Write a text.
            using (var formattedText = new PdfFormattedText())
                formattedText.Append("Hello World!");

                page.Content.DrawText(formattedText, new PdfPoint(100, 700));

            document.Save("Hello World.pdf");
Imports GemBox.Pdf
Imports GemBox.Pdf.Content

Module Program

    Sub Main()

        ' If using the Professional version, put your serial key below.

        Using document = New PdfDocument()

            ' Add a page.
            Dim page = document.Pages.Add()

            ' Write a text.
            Using formattedText = New PdfFormattedText()

                formattedText.Append("Hello World!")

                page.Content.DrawText(formattedText, New PdfPoint(100, 700))
            End Using

            document.Save("Hello World.pdf")
        End Using
    End Sub
End Module

GemBox.Pdf library simplifies PDF page content operations by compiling them into elements of text, paths, and external objects (images and forms). These elements are added to PDF page content when drawing PdfFormattedText.

Adding new textual content to a PDF document is supported via PdfFormattedText, such as in these Writing examples.

If you want to create complex PDF documents, use GemBox.Document, GemBox.Spreadsheet, and GemBox.Presentation, which all have PDF exporting capability.

See also

Next steps

GemBox.Pdf is a .NET component that enables developers to read, merge and split PDF files or execute low-level object manipulations from .NET applications in a simple and efficient way.

Download Buy