Export a File to PDF
The following example illustrates how to initialize File Content Extraction 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:
pszKeyViewDiris the path of the folder containing the File Content Extraction binaries, for exampleC:\MicroFocus\KeyviewExportSDK-12.3.0\WINDOWS_X86_64\bin.pszTempFolderis the path to a folder which can be used to store temporary files.pszInFileNameis the name of the input file.pszOutFileNameis the name of the PDF file to create. If the output file already exists it is overwritten if possible. The output PDF cannot be in the working directory.
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 pszLicense,
const char* const pszInFileName,
const char* const pszOutFileName)
{
KVPDFContext context = NULL;
KVPDFOptions sOptions = {0};
BOOL bSuccess = FALSE;
KVStructInit(&sOptions);
if (sInterface.fpInit(
pszKeyViewDir, pszTempFolder, pszLicense, &context
).eErrorCode == KVERR_Success)
{
bSuccess = sInterface.fpConvertFileToFile(
context, pszInFileName, pszOutFileName, sOptions
).eErrorCode == KVERR_Success;
sInterface.fpShutDown(&context);
}
return bSuccess;
}