Some test text!

menu
search

Get started with .NET Framework 4.0+

Welcome to PDFTron. Currently, .NET Framework for the PDFTron SDK is only supported on Windows.

Get started with .NET Framework 4.0+

This guide will help you run PDFTron samples and integrate a free trial of the PDFTron SDK into .NET Framework applications on Windows. Your free trial includes unlimited trial usage and support from solution engineers.

linkPrerequisites

  • Visual Studio

    Make sure that the .NET Desktop Development workload is part of your installation.

    This guide will use Visual Studio 2017.

  • PDFTron SDK for .NET Framework 4.0+

linkInitial setup

Extract the folder from the .zip file.

This article uses PDFNET_BASE as the path into the PDFNetDotNet4 folder that you extracted.

PDFNET_BASE = path/to/extraction/folder/PDFNetDotNet4/

linkRun the samples

Navigate to the location of extracted contents. Find and enter the Samples folder (PDFNET_BASE/Samples). Here you can find sample code for a large number of features supported by the PDFTron SDK.

  1. Open Samples_20XX.sln in Visual Studio. Choose an appropriate version for your Visual Studio installation.
  2. Find the sample you want to run and set it as the Startup Project for the solution.
  3. Run the project.

linkIntegrate into your application

This is called the "PDFTron Hello World" application. It is easy to integrate the rest of PDFTron SDK if you are able to open, save and close a PDFDoc.

  1. Create a new .NET Framework console application project in Visual Studio for your preferred language. You can find them under the Visual C# or Visual Basic category.
  2. Navigate into your project's folder. By default, the path should be similar to: C:/Users/User_Name/source/repos/myApp

    Copy the Lib folder from PDFNET_BASE to your project folder (the folder which contains your .csproj or .vbproj file).

  3. Find the Solution Explorer to the right. Right-click on References and select the Add reference option. This opens a Reference Manager dialog.

    Click on Browse... at the bottom of the dialog. Navigate to the copied Lib folder and add PDFNetLoader.dll to the references.

    Also add the appropriate version of PDFNet.dll from the x86 folder as another reference (path/to/your/project/folder/Lib/PDFNet/x86/PDFNet.dll). This version will allow the application to run on both 32-bit and 64-bit OS.

  4. Select PDFNet.dll and set its Copy Local property to False.

  5. Right click on your project and select Properties. In the left pane, select the Build Events tab. Under Post-Build Events, add the following code snippet:

    xcopy $(ProjectDir)Lib\PDFNet $(TargetDir)PDFNet /S /I /Y

linkThe Code

Replace the contents of Program.cs or Module1.vb with:

// Default namespaces
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

// Majority of PDFTron SDK can be used with these namespaces
using pdftron;
using pdftron.Common;
using pdftron.SDF;
using pdftron.PDF;

namespace myAppCS
{
    class Program
    {
        // Required for AnyCPU implementation.
        private static PDFNetLoader loader = PDFNetLoader.Instance();

        static void Main(string[] args)
        {
            // Initialize PDFNet before using any PDFTron related
            // classes and methods (some exceptions can be found in API)
            PDFNet.Initialize();

            // Using PDFNet related classes and methods, must catch or throw PDFNetException
            try
            {
                using (PDFDoc doc = new PDFDoc())
                {
                    doc.InitSecurityHandler();

                    // An example of creating a new page and adding it to
                    // doc's sequence of pages
                    Page newPg = doc.PageCreate();
                    doc.PagePushBack(newPg);

                    // Save as a linearized file which is most popular 
                    // and effective format for quick PDF Viewing.
                    doc.Save("linearized_output.pdf", SDFDoc.SaveOptions.e_linearized);

                    System.Console.WriteLine("Done. Results saved in linearized_output.pdf");
                }
            }
            catch (PDFNetException e)
            {
                System.Console.WriteLine(e.);
            }
        }
    }
}

Build and run the project using the Start button in Visual Studio.

You should find the "linearized_output.pdf" in your project folder with a blank page.

linkNext step

GuidesAPI docsSamples

linkTroubleshooting

Setting a startup project
Find out how to set a startup project

Get the answers you need: Support

close

Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.

PDFTron Receives USD$71 Million Growth Investment Led By Silversmith Capital Partners

Learn More
close