Export a File to PDF

The following example illustrates how to initialize KeyView by using fpInit(), use the fpConvertFileToFile() file method, and then shutdown using fpShutdown().

This example uses the KVPDFGetInterface function pointer, fpGetInterface(). For details of how to load the kvpdf library and obtain this pointer, see Get a Session Context.

In this example:

All strings must be null-terminated.

For more details about the functions used, see C API Reference.

#include "kvpdf.h"

BOOL exportFileToPDF(
    KVPDFInterface sInterface,
    const char* const pszKeyViewDir,
    const char* const pszTempFolder,
    const char* const pszInFileName,
    const char* const pszOutFileName)
{
    KVPDFContext context = NULL;
    KVPDFOptions sOptions = {0};
    BOOL bSuccess = FALSE;

    KVStructInit(&sOptions);

    if (sInterface.fpInit(
            pszKeyViewDir, pszTempFolder, &context
        ).eErrorCode == KVERR_Success)
    {
        bSuccess = sInterface.fpConvertFileToFile(
            context, pszInFileName, pszOutFileName, sOptions
        ).eErrorCode == KVERR_Success;
        
        sInterface.fpShutDown(&context);
    }

    return bSuccess;
}