Some test text!

menu

Manually integrating PDFNetC PDF library for UWP

This SDK is made for those developing UWP apps and require a pure C++ PDF SDK that only uses the allowed Win32 and COM API's to pass the Windows App Certification in order to be published on Microsoft Store.

This guide will help you run PDFTron samples and integrate a free trial of the PDFTron SDK into C++ applications on Windows. Your free trial includes full support from solution engineers..

linkPrerequisites

  • Visual Studio

    Make sure that the Desktop development with C++ workload is part of your installation.

    This guide will use Visual Studio 2019 and the x64-bit SDK version.

  • PDFTron's PDF library for UWP:

No trial license key required.
The trial of PDFTron SDK works without a license key. A commercial license key is required for use in a production environment. Please fill out our licensing form if you do not have a valid license key.
Keep your commercial license key confidential.
License keys are uniquely generated. Please make sure that it is not publicly available (e.g. in your public GitHub).

linkInitial setup

Extract the folder from the .zip file.

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

PDFNET_BASE = path/to/extraction/folder/PDFNetC64UWP/

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.

Find Samples_VC20XX.sln inside the Samples folder and open it with Visual Studio. Choose the appropriate solution based on your Visual Studio installation.

Run a specific sample

  1. Find the sample you want to run and set it as the Startup project.

    If you're running into issues, see the Troubleshooting section.

  2. Run the project.

Run all samples

  1. Make sure that the target type for the debugger is set to the right type for your machine and your PDFTron SDK Download. Click on Local Windows Debugger to run all the samples.

Right Machine Type and Run

Note: For ARM64 target it will be necessary to setup the Remote Debugger.

linkIntegrate into your application

This section will help you build 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.

Before writing the application, some dependencies needed to be with Visual Studio.

  1. Create a new C++ Console Project for Windows called myapp
  2. Add PDFNET_BASE\Lib\PDFNetC.lib to Additional Dependencies under Librarian
  3. Add PDFNET_BASE\Headers to the project's Additional Include Directories in the C/C++ General Settings.
  4. Copy the PDFNET_BASE\Lib\PDFNetC.dll file to the project's output directory. Verify that the right version of PDFNetC.dll was added from the path used to add the reference.

The Troubleshooting section has more detailed instructions for newcomers to Visual Studio.

linkThe Code

Replace the contents of myapp.cpp with:

``` cpp

#include <iostream>

// Important for PDF related manipulations
#include <PDF/PDFNet.h>
#include <PDF/PDFDoc.h>

// Important for document filesystem interaction and more
#include <SDF/ObjSet.h>

using namespace pdftron;
using namespace PDF;
using namespace SDF;


int main()
{
    try
    {
        // This is required before any PDFTron related 
        // classes and methods can be properly used
        PDFNet::Initialize();

        PDFDoc doc;

        // Create a new page and push it into
        // the page sequence of the document.
        Page page = doc.PageCreate();
        doc.PagePushBack(page);

        // Save the document as a linearized PDF which is the most
        // popular and effective fast viewing format
        doc.Save("linearized_output.pdf", SDFDoc::e_linearized);
    }
    catch (pdftron::Common::Exception& ex)
    {
        std::cout << ex.GetMessage() << std::endl;
    }
    return 0;
}
```

You can use the Local Windows Debugger button to build the solution and run the main function when targeting x64.

Once the code has been run, you can find a new document called linearized_output.pdf in the output directory of your project.

linkTroubleshooting

Trouble setting dependencies
Set dependencies for the PDFTron SDK in a startup project with Visual Studio.

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.

Join our upcoming webinar to find out about built-in, full-functioning document capabilities directly in Salesforce.

Save your seat
close