Skip to main content
Version: Version 1.8

Get started with C

This guide walks you through the steps to use a sample project, and then explains how to integrate the Toolbox add-on into your application with the C programming language.

Request trial or full license

Unlike the Pdftools SDK or the Pdftools SDK Shell Tool, the Toolbox add-on requires a license key for both evaluation and full use. To request a license key, follow these steps:

  1. Reach out to the sales team through the Contact page and mark the Toolbox add-on as the product of your interest for a trial license.

If you already have a license key and you need to copy it, review Find the license key.

Getting started with a sample project

Learn how to use the Toolbox add-on using a C sample project and extract all images and image masks from a PDF document.

Prerequisites

This sample project uses GCC toolset 4.8+ and CMake version 3.16 or higher.

Compile and run the sample

  1. Download a sample project, and then unzip the file.

  2. Locate your license key. For more information, review Find the license key.

  3. In the toolboximageextraction.c file, replace the string "insert-license-key-here" with your license key:

    GOTO_CLEANUP_IF_FALSE_PRINT_ERROR(Ptx_Sdk_Initialize(_T("insert-license-key-here"), NULL),
    _T("Failed to set license key. %s (ErrorCode: 0x%08x).\n"), szErrorBuff,
    Ptx_GetLastError());

    Use the license key in the same format as you copied it. Include the less-than (<) and greater-than (>) signs.

  4. In the command line, navigate to the root directory of the unzipped sample project, and then run the following command:

    cmake .
  5. Build the sample:

    cmake --build .
  6. To extract all images and image masks from the sample PDF file ImageCollection.pdf to the output directory /tmp/images, run:

    ./toolboximageextraction ImageCollection.pdf /tmp/images

The code sample takes:

  • The input and output files represented as a file name, a file path with the file name, or the output directory.
  • Both file paths (input and output) can be relative or absolute.

Review the following snippet with a placeholder and compare it to the last step of the previous procedure:

./toolboximageextraction INPUT_FILE OUTPUT_FILE
note

You can apply a similar procedure described in this tutorial for other code samples. For more information, see Code samples page.

Integrate the Toolbox add-on into your application

Integrate and initialize the Toolbox add-on into your application by following the instructions in the next sections.

Add the Toolbox add-on to your project

  1. Click the download link to get the latest version of the Toolbox add-on for C in a zip archive.

  2. Unzip the file on your machine into a local directory recommended for your operating system. For example:

    C:\Program Files\PDF Tools AG\

    Included subdirectories are:

    SubdirectoryDescription
    libRuntime executable binaries and runtime import libraries:
    • win-x86\PdfTools_Toolbox.dll and win-x86\PdfTools_Toolbox.lib for 32-bit Windows.
    • win-x64\PdfTools_Toolbox.dll and win-x64\PdfTools_Toolbox.lib for 64-bit Windows.
    • win-arm64\PdfTools_Toolbox.dll and win-arm64\PdfTools_Toolbox.lib for 64-bit Windows ARM.
    includeHeader files to add to your C or C++ project. The main header PdfTools_Toolbox.h includes all the other headers.
  3. Optional: The native libraries must be available in your compiler's library path. This step is only required if your build process doesn't resolve it automatically:

    Add the lib\win-x64, lib\win-arm64 or lib\win-x86 subdirectory to the %PATH% environment variable.

Initialize the SDK

The Toolbox add-on always requires a license key to operate (unlike the Pdftools SDK).

Getting a license key

Without a valid license key the Toolbox add-on returns an error. Get in touch with the Pdftools sales team through the Contact page to get a full license.

To initialize the Toolbox add-on with your license key, follow these steps:

  1. Locate your license key. For more information, review Find the license key.

  2. Before you call any function of the Toolbox add-on, first call the Ptx_Sdk_Initialize function:

    GOTO_CLEANUP_IF_FALSE_PRINT_ERROR(Ptx_Sdk_Initialize(_T("insert-license-key-here"), NULL),
    _T("Failed to set license key. %s (ErrorCode: 0x%08x).\n"), szErrorBuff,
    Ptx_GetLastError());

    Replace insert-license-key-here with the value of your license key. Use the license key in the same format as you copied it. Include the less-than (<) and greater-than (>) signs.

To get a code sample with the Ptx_Sdk_Initialize function that you can use as a reference for your code, follow these steps:

  1. On the Code samples page, download and unzip a C code sample. For example: Download Extract all images and image masks from a PDF sample.
  2. Unzip the file, and then find the Ptx_Sdk_Initialize function in the C file of the sample. For example: Extract all images and image masks from a PDF includes the Ptx_Sdk_Initialize method in the toolboximageextraction.c file.
  3. Replace the insert-license-key-here with your license key.

Uninitialize the SDK

After processing files with the Toolbox add-on, call the Uninitialize function to unload the library correctly:

// Uninitialize library
Ptx_Uninitialize();

Implement your use case

  • Find more use cases and sample projects on the Toolbox add-on Code samples page.
  • For more technical information about the Toolbox add-on for C, consult the C technical notes.