Skip to content

Samples

All Foxit PDF SDK samples (listed in the table below) are located in the examples folder. Supported samples vary by platform and language library.

ExamplesDescriptionPlatform Library / Framework
extensions_demoPrint manager samplesC++ / .Net
simple_demoA large collection of code samples demonstrating PDF API usage. C++ samples are the most comprehensive.All SDK libraries
view_demoA UI sample that demonstrates how to implement a basic PDF reader using the APIsC++ / .Net
QT view_demoA Qt-based UI sample that demonstrates how to implement a basic PDF reader using the APIsLinux C++

examples/simple_demo/input_files contains test documents used by all samples. For samples that produce output files (PDF, text, or image files), output is generated in a folder named after the sample under examples/simple_demo/output_files/.

Sample Dependencies

Most samples under \examples\simple_demo can be run directly, but some have additional dependencies. Read the dependency notes in the table below carefully.

SampleDirect Run SupportedDependencies
office2pdfNoFoxit Conversion SDK resource package, or Foxit dedicated pdf2office resource package
pdf2officeNoFoxit Conversion SDK resource package
LibreOffice2pdfNoFoxit multithreaded dedicated LibreOffice resource package
dwg2pdfNodwg2pdf resource package
html2pdfNohtml2pdf resource package
compliance and preflightNocompliance resource package
ocrNoocr resource package
ofdNoofd resource package
signaturePartialOpenSSL source package
paging_seal_signaturePartialOpenSSL source package
securityPartialOpenSSL source package

NOTE

  • OpenSSL source package: The SDK Java sample directory already includes it, and the DotNet library has it built in. Users of these two libraries do not need to download it separately.
  • Other dependency resource packages: Request a trial through the Foxit Developer Hub, or contact your Foxit technical support team and sales representatives.

Run Preparation

Development Environment Setup

To compile and run SDK sample projects successfully, configure the development environment for your language:

  • Foxit Linux C/C++, Mac C++ SDK: CMake ≥ 3.1, x86/x64 gcc ≥ 5.4, arm gcc ≥ 8.3
  • Foxit Java SDK: JDK version ≥ 1.8.
  • Foxit .NETCore x64 SDK: .NET Core runtime version ≥ 2.1.
  • Foxit .NET Framework SDK: .NET Framework ≥ 4.0.
  • Foxit Python SDK: Python 2.7, Python 3.6–3.10, and Python 3.11+ builds using the ABI3 interface.
  • Foxit Node.js SDK: Node.js version 10–22.
  • Foxit Go SDK: Go version ≥ 1.18.

System Requirements

For operating system versions, compiler requirements, and related details, select your platform:

Run Samples

Sample run methods vary slightly across platforms and language libraries.

  • Windows C/C++ and .NET libraries: Because the SDK does not provide command-line runners such as .bat or .sh files directly, use an IDE (such as Visual Studio) or sample-specific scripts to compile and run sample projects.
  • Other SDK language libraries: Use the SDK-provided command-line runners, sample-specific scripts, or an IDE to run samples.
  • Linux/Mac C++ libraries: You can also compile and run samples with CMake and Make.

The sections below describe how to run samples using command-line scripts. For running samples with an IDE, refer to the documentation for your development framework or language library.

Simple demo

Samples under \examples\simple_demo, except those with additional dependencies and Python sample projects, can be run directly using .bat or .sh files when command-line runners are included. For running Python samples, see Foxit PDF SDK Python Library.

Run All Samples

  • On Windows, run RunAllDemo.bat all or RunAllDemo.bat all x86.
  • On Linux and Mac, run RunAllDemo.sh all.

Run a Specific Sample

  • On Windows, run RunDemo.bat demo_name or RunDemo.bat demo_name x86. For example, RunDemo.bat bookmark x86 runs only the bookmark sample.
  • On Linux and Mac, run RunDemo.sh demo_name.

Security demo

On Linux or Mac, see Signature demo below to run this sample. On Windows, follow these steps:

Before running the security demo, install the foxit.cer and foxit_all.pfx certificates from the \examples\simple_demo\input_files folder.

  1. Install foxit.cer by double-clicking it to launch the certificate import wizard, then select Install certificate… > Next > Next > Finish.
  2. Install foxit_all.pfx by double-clicking it to launch the certificate import wizard, then select Next > Next > (enter the private key password "123456" in the text box), then click Next > Next > Finish.
  3. Follow the simple demo run steps above to run this sample.

Signature demo / paging_seal_signature

Before running the signature demo, ensure OpenSSL is installed. Download the OpenSSL source package from the OpenSSL website, or contact our support team. After obtaining the source package, extract it and perform the following steps:

Windows

  1. Copy the OpenSSL folder into the include folder so the OpenSSL header files referenced by the sample can be found.
  2. Copy the libeay32.lib library into the lib folder.
  3. Follow the simple demo run steps above to run this sample.

Linux / Mac

  1. Copy the OpenSSL folder into the include folder so the OpenSSL header files referenced by the sample can be found.
  2. Copy the libssl.a and libcrypto.a libraries into the lib folder.
  3. Follow the simple demo run steps above to run this sample.

NOTE

  • OpenSSL 1.1.1-stable has been verified to work with the signature sample. You can replace it with another version, but additional changes may be required.
  • Python developers on Linux/Mac must install cryptography and pyopenssl before running the Security, signature, and paging_seal_signature samples. See the Python documentation for details.

OCR demo

  • Supported on Windows and Linux x64
  • Before running the OCR demo, build a resource directory, download the resource package, and place the required resources in that directory. For more details, see OCR Sample: Configuration and Run Guide.

Compliance and Preflight demo

  • Supported on Windows, Linux x86/x64, and Mac
  • Before running the compliance demo, build a resource directory, download the resource package, and place the required resources in that directory. For more details, see PDF Compliance Sample: Configuration and Run Guide.

HTML to PDF demo

Output Preview demo

Office to PDF demo (third-party engine)

Office to PDF demo (Foxit proprietary conversion engine)

PDF to Office demo (Foxit proprietary conversion engine)

DWG to PDF demo