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.
| Examples | Description | Platform Library / Framework |
|---|---|---|
| extensions_demo | Print manager samples | C++ / .Net |
| simple_demo | A large collection of code samples demonstrating PDF API usage. C++ samples are the most comprehensive. | All SDK libraries |
| view_demo | A UI sample that demonstrates how to implement a basic PDF reader using the APIs | C++ / .Net |
| QT view_demo | A Qt-based UI sample that demonstrates how to implement a basic PDF reader using the APIs | Linux 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.
| Sample | Direct Run Supported | Dependencies |
|---|---|---|
| office2pdf | No | Foxit Conversion SDK resource package, or Foxit dedicated pdf2office resource package |
| pdf2office | No | Foxit Conversion SDK resource package |
| LibreOffice2pdf | No | Foxit multithreaded dedicated LibreOffice resource package |
| dwg2pdf | No | dwg2pdf resource package |
| html2pdf | No | html2pdf resource package |
| compliance and preflight | No | compliance resource package |
| ocr | No | ocr resource package |
| ofd | No | ofd resource package |
| signature | Partial | OpenSSL source package |
| paging_seal_signature | Partial | OpenSSL source package |
| security | Partial | OpenSSL 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
.bator.shfiles 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 allorRunAllDemo.bat all x86. - On Linux and Mac, run
RunAllDemo.sh all.
Run a Specific Sample
- On Windows, run
RunDemo.bat demo_nameorRunDemo.bat demo_name x86. For example,RunDemo.bat bookmark x86runs 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.
- Install
foxit.cerby double-clicking it to launch the certificate import wizard, then selectInstall certificate… > Next > Next > Finish. - Install
foxit_all.pfxby double-clicking it to launch the certificate import wizard, then selectNext > Next > (enter the private key password "123456" in the text box), then click Next > Next > Finish. - 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
- Copy the OpenSSL folder into the
includefolder so the OpenSSL header files referenced by the sample can be found. - Copy the
libeay32.liblibrary into thelibfolder. - Follow the simple demo run steps above to run this sample.
Linux / Mac
- Copy the OpenSSL folder into the
includefolder so the OpenSSL header files referenced by the sample can be found. - Copy the
libssl.aandlibcrypto.alibraries into thelibfolder. - 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
cryptographyandpyopensslbefore 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
- Supported on Windows, Linux x86/x64, and Mac
- Before running the html2pdf demo, download the resource package. For more details, see HTML to PDF Sample: Configuration and Run Guide.
Output Preview demo
- Supported on Windows, Linux x86/x64, and Mac x64
- Before running the output preview demo, set the folder path that contains the default ICC profile files. For more details, see Output Preview Sample: Configuration and Run Guide.
Office to PDF demo (third-party engine)
- Supported on Windows and Linux x86/x64
- For instructions on running the office2pdf sample, see Office to PDF Sample: Configuration and Run Guide.
Office to PDF demo (Foxit proprietary conversion engine)
- Supported on Windows and Linux
- Before running the office2pdf demo, download the resource package. For more details, see Foxit Office to PDF Sample: Configuration and Run Guide.
PDF to Office demo (Foxit proprietary conversion engine)
- Supported on Windows
- Before running the pdf2office demo, download the resource package. For more details, see PDF to Office Sample: Configuration and Run Guide.
DWG to PDF demo
- Supported on Windows, Linux x86/x64, and Mac x64
- Before running the dwg2pdf demo, download the resource package. For more details, see DWG to PDF Sample: Configuration and Run Guide.