When it comes to the Kofax Release I want to convert each scanned document to a byte array. Within my ReleaseDoc
method I first want to check if the file is a PDF file or TIFF file.
The user is able to setup a bool value in the ReleaseSetup
that leads to 'use PDF file if you have to decide between multiple file types'.
I just created a snipped that tries to convert the file to a byte array.
How can I check if I have to use a PDF or a image file within my ReleaseDoc
method?
It doesn't matter if the PDF file has three pages because it is a single file. But it matters if there are three TIFF files that need to get converted to one byte array. How can I achieve this?
To sum up I need within my method only a way to extract the name and the byte array from the document.
public KfxReturnValue ReleaseDoc()
{
try
{
string fileName = string.Empty;
string filePath = string.Empty;
bool isPDFFile = false; // how to check it?
if (isPDFFile)
{
filePath = documentData.KofaxPDFPath;
fileName = documentData.KofaxPDFFileName;
}
else
{
ImageFiles files = documentData.ImageFiles;
if (files.Count == 1)
{
fileName = files[0].FileName;
filePath = documentData.ImageFilePath;
}
else
{
// Create one document out of multiple TIFF files?
// fileName = ...
// filePath = ...
}
}
byte[] binaryFile = File.ReadAllBytes(filePath);
// use fileName and binaryFile
return KfxReturnValue.KFX_REL_SUCCESS;
}
catch (Exception e)
{
// Handle exception
return KfxReturnValue.KFX_REL_ERROR;
}
}