Skip to content

PDF Compliance ​

Foxit PDF SDK provides verification and conversion so PDFs can meet a specified version or archival / print / engineering-exchange standard. Full sample projects are in the product package under examples/simple_demo/compliance and in the Compliance sample configuration and run guide. For class and method details, see API Reference.

What you can do ​

GoalSupported scopeEntry point
PDF version standardizationPDF 1.3–1.7. When converting to 1.3, if the source document contains transparency, the result is PDF 1.4PDFCompliance
Long-term archival PDF/APDF/A-1a/1b, 2a/2b/2u, 3a/3b/3u; from 12.0, also PDF/A-4e and 4fPDFACompliance
Engineering exchange PDF/EPDF/E-1PDFECompliance
Print exchange PDF/XPDF/X-1a, 3, 4, 4pPDFXCompliance
Analyze / fix by profile and produce a reportPreflight profile keys (for example, convert to PDF/A-2b)Preflight

PDF/A disables features that are unsuitable for long-term archiving (such as font linking only, encryption, JavaScript, and audio/video). Both verification and conversion return ResultInformation, which you can query for matched items and fix-up data. Each hit (HitData) includes dict_key (the dictionary key of the hit rule).

Initialization ​

Before use, prepare the path to the Compliance resource package. Trial license keys generally do not need an extra unlock code; production licenses require an unlock code from sales, which you pass to ComplianceEngine::Initialize.

cpp
using namespace foxit::addon::compliance;

Library::Initialize(sn, key);
ErrorCode err = ComplianceEngine::Initialize(compliance_resource_folder_path, compliance_engine_unlockcode);
// For trial, you may pass an empty string as the unlocking code.

// … call verification / conversion / Preflight …

ComplianceEngine::Release();
Library::Release();

Multithreading: from v10.0, call ComplianceEngine::InitializeThreadContext before using compliance APIs. Mac Java does not currently support multithreading. For more information, see the multithreading safety guide.

Verify whether a document meets a standard ​

The following example uses PDF/A-1a; for PDF/X or PDF/E, swap in the corresponding class and version enum.

c++
#include "include/addon/compliance/fs_pdfa.h"
using namespace foxit::addon::compliance;
…
PDFACompliance pdfa_compliance;
ResultInformation verify_result = pdfa_compliance.Verify(
    PDFACompliance::e_VersionPDFA1a, src_pdf_path, 0, -1, NULL);
C
#include "include/fs_pdfa_c.h"
…
FS_PDFACOMPLIANCE_HANDLE pdfa = NULL;
FSDK_PDFACompliance_Create(&pdfa);
FS_RESULTINFORMATION_HANDLE verify_result = NULL;
FSDK_PDFACompliance_Verify(pdfa, e_FSVersionPDFA1a, src_pdf_path, 0, -1, NULL, &verify_result);
java
import com.foxit.sdk.addon.compliance.PDFACompliance;
…
PDFACompliance pdfa = new PDFACompliance();
ResultInformation verifyResult = pdfa.verify(
    PDFACompliance.e_VersionPDFA1a, srcPdfPath, 0, -1, null);
py
from FoxitPDFSDKPython3 import *
…
pdfa = PDFACompliance()
verify_result = pdfa.Verify(PDFACompliance.e_VersionPDFA1a, src_pdf_path, 0, -1, None)
js
const FSDK = require("@foxitsoftware/foxit-pdf-sdk-node");
…
let pdfa = new FSDK.PDFACompliance();
let verify_result = pdfa.Verify(FSDK.PDFACompliance.e_VersionPDFA1a, src_pdf_path, 0, -1, null);
csharp
using foxit.addon.compliance;
…
using (PDFACompliance pdfa = new PDFACompliance())
{
    ResultInformation verify_result = pdfa.Verify(
        PDFACompliance.Version.e_VersionPDFA1a, src_pdf_path, 0, -1, null);
}
go
import . "foxit.com/fsdk"
…
pdfa := NewPDFACompliance()
verifyResult := pdfa.Verify(PDFAComplianceE_VersionPDFA1a, srcPdfPath, 0, -1, nil)

Convert to a standards-compliant PDF ​

Again using PDF/A-1a as the example.

c++
ResultInformation convert_result = pdfa_compliance.ConvertPDFFile(
    src_pdf_path, saved_pdf_path, PDFACompliance::e_VersionPDFA1a, NULL);
C
FS_RESULTINFORMATION_HANDLE convert_result = NULL;
FSDK_PDFACompliance_ConvertPDFFile(pdfa, src_pdf_path, saved_pdf_path,
    e_FSVersionPDFA1a, NULL, &convert_result);
java
ResultInformation convertResult = pdfa.convertPDFFile(
    srcPdfPath, savedPdfPath, PDFACompliance.e_VersionPDFA1a, null);
py
convert_result = pdfa.ConvertPDFFile(src_pdf_path, saved_pdf_path, PDFACompliance.e_VersionPDFA1a, None)
js
let convert_result = pdfa.ConvertPDFFile(src_pdf_path, saved_pdf_path, FSDK.PDFACompliance.e_VersionPDFA1a, null);
csharp
ResultInformation convert_result = pdfa.ConvertPDFFile(
    src_pdf_path, saved_pdf_path, PDFACompliance.Version.e_VersionPDFA1a, null);
go
convertResult := pdfa.ConvertPDFFile(srcPdfPath, savedPdfPath, PDFAComplianceE_VersionPDFA1a, nil)

PDF/A-4e / PDF/A-4f ​

From version 12.0, PDF/A-4e and PDF/A-4f are also supported. Upgrade the matching Compliance resource package for this release as well.

  • Verification: PDFACompliance::e_VersionPDFA4e, e_VersionPDFA4f
  • Conversion: e_VersionPDFA4eWithoutFBC, e_VersionPDFA4fWithoutFBC (use the WithoutFBC variants on the conversion side)
cpp
ResultInformation convert_result = pdfa_compliance.ConvertPDFFile(
    src_pdf_path, saved_pdf_path, PDFACompliance::e_VersionPDFA4eWithoutFBC, NULL);
ResultInformation verify_result = pdfa_compliance.Verify(
    PDFACompliance::e_VersionPDFA4e, saved_pdf_path, 0, -1, NULL);

Preflight: analyze, fix, and report ​

Preflight analyzes by configuration key (preflight_key; enumerate with GetItemKeysArray), optionally auto-fixes, and generates a report.

From version 12.0, Analyze / AnalyzeAndFixup return ResultInformation. For the return-type change when upgrading from an earlier version, see Release notes · Preflight.

Group-item localization callback ​

Implement PreflightGroupLocalCallback only when group item names or comments need localized text, and pass it to Preflight::SetPreflightGroupLocalCallback. No change is required if you do not use this. Implement:

cpp
virtual void Release() = 0;
virtual WString GetGroupItemLocalName(const WString& key) = 0;
virtual WString GetGroupItemLocalComment(const WString& key) = 0;

The following example converts to PDF/A-2b (pppp_ConverttoPDFA2b).

c++
#include "include/addon/compliance/fs_pdfcompliance.h"
using namespace foxit::addon::compliance;
…
Preflight preflight;
PreflightSettingData setting_data;
setting_data.operate_type = PreflightSettingData::e_OperateTypeProfiles;
setting_data.preflight_key = L"pppp_ConverttoPDFA2b";
setting_data.src_pdf_path = L"input.pdf";
setting_data.saved_pdf_path = L"output_compliant.pdf";

ResultInformation result;
if (preflight.CanFixup("pppp_ConverttoPDFA2b"))
  result = preflight.AnalyzeAndFixup(setting_data, NULL);
else
  result = preflight.Analyze(setting_data, NULL);

PreflightReportSettingData report_data;
report_data.report_file_format_type = PreflightReportSettingData::e_ReportFileFormatTypePdf;
report_data.report_file_path = L"compliance_report.pdf";
report_data.to_generate_overview = true;
report_data.to_highlight_problems = true;
preflight.GenerateReport(report_data, NULL);
C
#include "include/fs_pdfcompliance_c.h"
…
FS_PREFLIGHT_HANDLE preflight = NULL;
FSDK_Preflight_Create(&preflight);
FSPreflightSettingData setting_data = {0};
setting_data.operate_type = e_FSPreflightOperateTypeProfiles;
setting_data.preflight_key = L"pppp_ConverttoPDFA2b";
setting_data.src_pdf_path = L"input.pdf";
setting_data.saved_pdf_path = L"output_compliant.pdf";
FS_BOOL can_fixup = FALSE;
FSDK_Preflight_CanFixup(preflight, L"pppp_ConverttoPDFA2b", &can_fixup);
FS_RESULTINFORMATION_HANDLE result = NULL;
if (can_fixup)
  FSDK_Preflight_AnalyzeAndFixup(preflight, &setting_data, NULL, &result);
else
  FSDK_Preflight_Analyze(preflight, &setting_data, NULL, &result);
java
import com.foxit.sdk.addon.compliance.Preflight;
import com.foxit.sdk.addon.compliance.PreflightSettingData;
…
Preflight preflight = new Preflight();
PreflightSettingData settingData = new PreflightSettingData();
settingData.setOperate_type(PreflightSettingData.e_OperateTypeProfiles);
settingData.setPreflight_key("pppp_ConverttoPDFA2b");
settingData.setSrc_pdf_path("input.pdf");
settingData.setSaved_pdf_path("output_compliant.pdf");
ResultInformation result;
if (preflight.canFixup("pppp_ConverttoPDFA2b"))
  result = preflight.analyzeAndFixup(settingData, null);
else
  result = preflight.analyze(settingData, null);
py
preflight = Preflight()
setting_data = PreflightSettingData()
setting_data.operate_type = PreflightSettingData.e_OperateTypeProfiles
setting_data.preflight_key = "pppp_ConverttoPDFA2b"
setting_data.src_pdf_path = "input.pdf"
setting_data.saved_pdf_path = "output_compliant.pdf"
if preflight.CanFixup("pppp_ConverttoPDFA2b"):
    result = preflight.AnalyzeAndFixup(setting_data, None)
else:
    result = preflight.Analyze(setting_data, None)
js
let preflight = new FSDK.Preflight();
let settingData = new FSDK.PreflightSettingData();
settingData.operate_type = FSDK.PreflightSettingData.e_OperateTypeProfiles;
settingData.preflight_key = "pppp_ConverttoPDFA2b";
settingData.src_pdf_path = "input.pdf";
settingData.saved_pdf_path = "output_compliant.pdf";
let result;
if (preflight.CanFixup("pppp_ConverttoPDFA2b"))
  result = preflight.AnalyzeAndFixup(settingData, null);
else
  result = preflight.Analyze(settingData, null);
csharp
using (Preflight preflight = new Preflight())
{
    PreflightSettingData settingData = new PreflightSettingData();
    settingData.operate_type = PreflightSettingData.OperateType.e_OperateTypeProfiles;
    settingData.preflight_key = "pppp_ConverttoPDFA2b";
    settingData.src_pdf_path = "input.pdf";
    settingData.saved_pdf_path = "output_compliant.pdf";
    ResultInformation result = preflight.CanFixup("pppp_ConverttoPDFA2b")
        ? preflight.AnalyzeAndFixup(settingData, null)
        : preflight.Analyze(settingData, null);
}
go
preflight := NewPreflight()
settingData := NewPreflightSettingData()
settingData.SetOperate_type(PreflightSettingDataE_OperateTypeProfiles)
settingData.SetPreflight_key("pppp_ConverttoPDFA2b")
settingData.SetSrc_pdf_path("input.pdf")
settingData.SetSaved_pdf_path("output_compliant.pdf")
var result ResultInformation
if preflight.CanFixup("pppp_ConverttoPDFA2b") {
    result = preflight.AnalyzeAndFixup(settingData, nil)
} else {
    result = preflight.Analyze(settingData, nil)
}