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:
pszKeyViewDir
is the path of the folder containing the KeyView binaries, for exampleC:\MicroFocus\KeyviewExportSDK-12.3.0\WINDOWS_X86_64\bin
.pszTempFolder
is the path to a folder which can be used to store temporary files.pszInFileName
is the name of the input file.pszOutFileName
is 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 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; }