Skip to content

Samples ​

Sample project overview ​

Foxit Conversion SDK provides samples for every supported language. Samples are in the examples directory of the development package. Directory layout:

πŸ“ Sample directory structure ​

examples/
β”œβ”€β”€ simple_demo/              # Simple sample projects
β”‚   β”œβ”€β”€ input_files/          # Source Office and PDF files for testing
β”‚   β”œβ”€β”€ office2pdf/           # Office to PDF samples (Windows only)
β”‚   └── pdf2office/           # PDF to Office samples
└── └── output_files/         # Converted output; subfolders named per sample

Sample directory reference ​

SampleDescriptionPlatformsInput formatsOutput formats
office2pdfConvert Office documents to PDFWindows/Linuxdocx, xlsx, pptxPDF
pdf2officeConvert PDF to Office formatsWindows/LinuxPDFdocx, xlsx, pptx

Run preparation ​

Development environment and system support ​

Run samples ​

Overview ​

How you run samples varies slightly by platform and language:

  • Windows C/C++ and .NET: The SDK does not ship a command-line runner; use an IDE (e.g. Visual Studio) to open and run sample projects.
  • Other language packages: Use the SDK command-line runner, sample scripts, or an IDE.
  • Linux C++: Command line or build and run with CMake and Make.

Detailed guides ​

Command-line run ​

Samples under \examples\simple_demo that include a command-line runner (except Python and Node.js) can be run via .bat or .sh files.

Basic usage ​

  • Run all samples

    • Windows: RunDemo.bat all or RunDemo.bat all x86.
    • Linux: RunDemo.sh all.
  • Run a specific sample

    • Windows: RunDemo.bat demo_name or RunDemo.bat demo_name x86. For example, RunDemo.bat office2pdf x86 runs only the office2pdf sample.
    • Linux: RunDemo.sh demo_name.

    NOTE

    • Before SDK 2.1, the Java command-line runner was in each sample directory. To run a sample, cd to that directoryβ€”for example, \examples\simple_demo\pdf2office for pdf2office.

Language-specific samples ​


Node.js samples ​
  1. Install the SDK Node.js package:

    • From the project root, run:
    js
    npm i @fuxinsoft/foxit-pdf-conversion-sdk-node
  2. Run a sample:

    • cd to the sample directory, e.g. \examples\simple_demo\office2pdf or \examples\simple_demo\pdf2office
    • Run node office2pdf.js or node pdf2office.js
Python samples ​
  1. Install SDK Python library {#install-sdk-python-library}
python
pip install FoxitPDFConversionSDKPython3
  1. Configure SDK Python library {#configure-sdk-python-library}
  • For Foxit SDK Python 2.7 on Windows or Linux, copy the correct library file for your Python bitness (32 or 64).

    Windows Python 2.7:

    • x64:
      • Copy FoxitPDFConversionSDKPython2/x64_vc15/_fpdfconversionsdk.pyd to FoxitPDFConversionSDKPython2/.
    • x86:
      • Copy FoxitPDFConversionSDKPython2/x86_vc15/_fpdfconversionsdk.pyd to FoxitPDFConversionSDKPython2/.

    Linux Python 2.7:

    • x64:
      • Copy FoxitPDFConversionSDKPython2/x64_vc15/_fpdfconversionsdk.so to FoxitPDFConversionSDKPython2/.
    • x86:
      • Copy FoxitPDFConversionSDKPython2/x86_vc15/_fpdfconversionsdk.so to FoxitPDFConversionSDKPython2/.

    Alternatively, run examples/simple_demo/rundemo_python.py to copy libraries automatically.

  1. Run SDK Python samples {#run-sdk-python-demo}
  1. Run samples with the Python script

rundemo_python.py wraps configuration and dependencies for easier runs.

  • Run all samples
python
cd examples/simple_demo/
python rundemo_python.py
  • Run one sample

For example, pdf2office:

python
cd examples/simple_demo/
python rundemo_python.py pdf2office
  1. Run sample scripts directly
  • If Python and dependencies are configured, run scripts directly. Example for office2pdf:
bash
cd examples/simple_demo/office2pdf/
python -u office2pdf.py

NOTE

  • Python 2.7: see Configure Python library and match library files to your Python version.
  • Python 3: if FoxitPDFSDKPython3 is installed, you can run sample scripts directly.
Go samples ​
  1. Set environment variables
  • After downloading the Foxit PDF SDK Go package, set environment variables so the dynamic libraries can be found:

    Linux:

    • x64:
      bash
      export LD_LIBRARY_PATH=/home/user/Desktop/foxitpdfsdk_xx_x_linux_go/lib/x64:$LD_LIBRARY_PATH
    • x86:
      bash
      export LD_LIBRARY_PATH=/home/user/Desktop/foxitpdfsdk_xx_x_linux_go/lib/x86:$LD_LIBRARY_PATH

    MacOS:

    • x64:
      bash
      export DYLD_LIBRARY_PATH=/Users/user/Desktop/foxitpdfsdk_xx_x_mac_go/lib:$DYLD_LIBRARY_PATH

    NOTE

    • Replace paths with your actual SDK install location
    • Add these to your shell config (e.g. ~/.bashrc or ~/.zshrc) for persistence
    • Reopen the terminal or run source ~/.bashrc after changes
  1. Run samples

Visual Studio run ​

On Windows, building the SDK with Visual Studio creates a bin folder under \examples\simple_demo\ with .exe files. Executable names depend on the build configuration.

  1. Open the solution:

    • Under \examples\simple_demo, open the .sln for your Visual Studio version.
    • To build one sample only, open the .vcxproj in that sample folder.
  2. Build:

    • In Visual Studio: Build > Build Solution.
  3. Run: After a successful build:

    • Method 1: Run the .exe
      • Open bin and double-click the .exe.
    • Method 2: Run from Visual Studio
      • In Solution Explorer, right-click the project and choose Set as Startup Project.
      • Press F5 or Debug > Start Debugging.
  4. Output:

    • Results appear in the Visual Studio Output window or console.

    Get detailed execution logs

    Open cmd.exe, cd to \examples\simple_demo\bin, and run the .exe.

Eclipse IDE run ​

The following uses Java samples as an example.

  1. Create a Java project and add the SDK:
    • Create a new Java project in Eclipse.
    • Add the Foxit Conversion SDK Java library.
  2. Copy sample source:
    • Copy the sample .java file into the project src folder.
    • For pdf2office, copy pdf2office.java from \examples\simple_demo\pdf2office into src.
  3. Configure paths:
    • Edit output_path and input_path in the copied source as needed.
    • For default test files, use absolute paths to output_files and input_files under examples\simple_demo.
  4. Run:
    • Right-click the project and choose Run As -> Java Application.