Docotic.Pdf Library Help > Getting Started

This article explains some of the basics to get you up and running to process PDF files in your WinForms, console or ASP.NET applications with Docotic.Pdf library.

Installing the Docotic.Pdf library

Installing from NuGet

The easiest way to get started is to install the BitMiracle.Docotic.Pdf package from NuGet.

Installing manually

  1. Download the latest release of the Docotic.Pdf library from our site. The library is distributed as a ZIP package.

    The ZIP package contains three versions of the library:

    • version for .NET 4.0 and later frameworks
    • version for .NET Standard 2.0 and later frameworks
    • version for .NET Standard 1.3 framework.

    The ZIP package also contains help file, all sample projects, scripts for adding the library to Global Assembly Cache (GAC) and removing it from the GAC, and the file with the license agreement.

  2. Extract the downloaded ZIP package to a location of your choice.

  3. Optionally, open Windows PowerShell as administrator and execute gac-install.ps1 script. This will add the library to Global Assembly Cache (GAC).

Running samples

Docotic.Pdf samples are located in the Samples folder of the ZIP package. Open SamplesCSharp solution file if you want to use sample code written in C# language. For a VB.NET version please open the SamplesVB.NET solution file.

The same sample code can be cloned or downloaded from our samples repository on GitHub.

Please take a time to review the samples. It should help you to add PDF processing features to your application.

Using Docotic.Pdf in your WinForms, console or ASP.NET application

  1. Open Visual Studio IDE. Create a new project or open existing one.

  2. Open the Add Reference dialog and add a reference to BitMiracle.Docotic.Pdf.dll.

    • The Extensions list will contain the BitMiracle.Docotic.Pdf assembly if you did add the library to GAC
    • Alternatively, you can browse to the location where you extracted the ZIP package and pick the DLL from there.
    Add reference dialog

    Please note that you can also add a NuGet reference to BitMiracle.Docotic.Pdf.

    When used in console application, Docotic.Pdf library may also require a reference to the System.Drawing assembly to be added.

  3. To avoid typing full references to the dll, it is best to add following using statement to the already existing ones in your source file

    C#
    using BitMiracle.Docotic.Pdf;
    VB
    Imports BitMiracle.Docotic.Pdf
  4. Add the following method to your application source code

    C#
    private static void helloPdf()
    {
    // replace string.Empty with your license key
    BitMiracle.Docotic.LicenseManager.AddLicenseData(string.Empty);
    
    using (PdfDocument pdf = new PdfDocument())
    {
    // draws "Hello world" on the first page
    PdfPage firstPage = pdf.Pages[0];
    firstPage.Canvas.DrawString(20, 20, "Hello world!");
    
    string outputName = "hello.pdf";
    // in ASP.NET application please use following line instead:
    // string outputName = Server.MapPath("hello.pdf");
    
    pdf.Save(outputName);
    }
    
    // opens saved document in default PDF viewer
    System.Diagnostics.Process.Start(outputName);
    }
    VB
    Private Shared Sub helloPdf()
    ' replace string.Empty with your license key
    BitMiracle.Docotic.LicenseManager.AddLicenseData(String.Empty)
    
    Using pdf As New PdfDocument()
    ' draws "Hello world" on the first page
    Dim firstPage As PdfPage = pdf.Pages(0)
    firstPage.Canvas.DrawString(20, 20, "Hello world!")
    
    Dim outputName As String = "hello.pdf"
    ' in ASP.NET application please use following line instead:
    ' string outputName = Server.MapPath("hello.pdf");
    
    pdf.Save(outputName)
    End Using
    
    ' opens saved document in default PDF viewer
    System.Diagnostics.Process.Start(outputName)
    End Sub
  5. Call helloPdf() method from your code. This should produce hello.pdf file and open it in default PDF viewer.

    Hello, PDF!

Conclusion

Now you should be able to develop PDF-related features in your applications using Docotic.Pdf library. This is only the beginning, however. We encourage you to read through the documentation accompanying the library and review samples. You might also want to check out the Bit Miracle blog .