Skip to content

PDF Compliance Sample: Configuration and Run Guide

This guide explains the environment requirements and configuration needed to run the compliance sample in a Java environment. For feature details, see PDF Compliance.

System Requirements

  • Platforms: Windows, Linux (x86 and x64), Mac
  • Languages: C, C++, Java, C#, Python, Objective-C
  • License: A license key that includes the Compliance module
  • SDK versions:
    • Foxit PDF SDK (C++, Java, C#, Objective-C) 6.4+
    • Foxit PDF SDK (C) 7.4+
    • Foxit PDF SDK (Python) 8.3+

The versions above are the minimum SDK versions that first introduced the features described in this guide for each listed language. Refer to the package documentation and release notes for the latest versions and platform differences.

Obtaining Compliance Resource Files

  • Request a trial through the Foxit Developer Hub, or contact your Foxit technical support team and sales representatives to obtain the compliance resource package.

Sample Run Guide

Sample location:

  • The compliance sample is located in the \examples\simple_demo\compliance directory.

Build the Compliance Resource Directory

Before running the compliance sample, you must build a compliance resource directory and pass its path to ComplianceEngine.initialize to initialize the compliance engine.

The platform-specific instructions below assume you have extracted the compliance resource package Res_Compliance_***.zip to the following directories:

  • compliance/win
  • compliance/linux
  • compliance/mac

Windows:

  1. Create a compliance resource directory, for example D:/compliance_resources.
  2. Copy the ect, lang, and var directories from compliance/win into D:/compliance_resources.
  3. Copy the appropriate library files based on the target platform architecture:
    • 32-bit systems: copy all files from compliance/win/lib/x86.
    • 64-bit systems: copy all files from compliance/win/lib/x64.

Linux:

  1. Create a compliance resource directory, for example /root/Desktop/compliance_resources.
  2. Copy the ect, lang, and var directories from compliance/linux into /root/Desktop/compliance_resources.
  3. Copy the appropriate library files based on the target platform architecture:
    • 32-bit systems: copy all files from compliance/linux/lib/x86.
    • 64-bit systems: copy all files from compliance/linux/lib/x64.

Tip: Before running the sample on Linux, add the compliance resource directory to the system shared library search path; otherwise, ComplianceEngine.initialize will fail. For example, you can add it temporarily with: export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/root/Desktop/compliance_resources

Mac:

On Mac, you can use the compliance/mac resource folder directly as the compliance resource directory.

NOTE

  • For Mac Java environments, copy the pdfEngineLight.dylib file from the var\legacy directory in the resource package into compliance/mac to replace the existing file.
  • The Mac Java language library does not support multithreaded operations.

Configure the Sample

Configure the sample in \examples\simple_demo\compliance\compliance.java. The configuration below uses the Windows Java library as an example.

Specify the compliance resource directory:

In compliance.java, set the path to the compliance resource directory to initialize the compliance engine.

Java
// "compliance_resource_folder_path" is the path of compliance resource folder. 
String compliance_resource_folder_path = "D:/compliance_resources";

NOTE

  • If you use a Foxit PDF SDK trial license, you do not need to license the compliance engine library separately.
  • If you use a production license, contact the Foxit sales team for a dedicated unlock code to initialize the compliance engine library: ComplianceEngine.initialize(compliance_resource_folder_path, compliance_engine_unlockcode).

(Optional) Set the compliance engine language:

Use ComplianceEngine.setLanguage to set the engine language. The default language is English. Other supported languages include Czech, Danish, Dutch, French, Finnish, German, Italian, Norwegian, Polish, Portuguese, Spanish, Swedish, Chinese-Simplified, Chinese-Traditional, Japanese, and Korean. The following example sets the language to Simplified Chinese:

Java
// Set languages. If not set language to ComplianceEngine, "English" will be used as default.
ComplianceEngine.setLanguage("Chinese-Simplified");

(Optional) Set the compliance engine temporary folder:

Use ComplianceEngine.setTempFolderPath to set a temporary folder for files generated during validation or conversion. If not set, the system default temporary folder is used. Example:

Java
// Set custom temp folder path for ComplianceEngine. 
ComplianceEngine.setTempFolderPath("D/compliance_temp");

Run the Sample

Navigate to \examples\simple_demo\compliance and run RunDemo.bat. The console displays relevant output:

This sample:

  • Validates whether \examples\simple_demo\input_files\AboutFoxit.pdf conforms to the PDF/A-1a standard and converts it to a PDF/A-1a-compliant file.
  • Converts \examples\simple_demo\input_files\AF_ImageXObject_FormXObject.pdf to PDF-1.4 and PDF-1.7 versions, respectively.

Output documents are saved in \examples\simple_demo\output_files\compliance.