Filter SDK Java Programming Guide
After setting up your chosen File Content Extraction SDK, you can start a new session and filter text in just a few lines of code, as demonstrated by the following code snippets. To get started with our APIs, and explore other features including format detection, subfile extraction, and access to metadata, see Getting Started.
KVFltInterfaceEx filter;
KVErrorCode error = KV_GetFilterInterfaceEx(&filter, KVFLTINTERFACE_REVISION);
if(error == KVError_Success)
{
KVFilterSession session = NULL;
KVFilterInitOptions options;
KVStructInit(&options);
error = filter.fpInit("/path/to/keyview/bin", license, &options, &session);
if(error == KVError_Success)
{
KVDocument document = NULL;
error = filter.fpOpenDocumentFromFile(session, "InputFile.docx", &document);
if(error == KVError_Success)
{
filter.fpFilterToFile(document, "OutputFile.txt");
}
filter.fpCloseDocument(document);
}
filter.fpShutdown(session);
}
auto session = keyview::Session{license, "/path/to/keyview/bin"};
auto myinput = keyview::io::InputFile{ std::string("InputFile.docx") };
auto myoutput = keyview::io::OutputFile{ std::string("OutputFile.txt") };
auto doc = session.open(myinput);
doc.filter(myoutput);
using (Session session = new Session("/path/to/keyview/bin", license))
{
using (Document myDoc = session.Open("InputFile.docx"))
{
myDoc.Filter("OutputFile.txt");
}
}
Filter objFilter = new Filter(license, Filter.CHARSET_UTF8, 0);
objFilter.setFilterDirectory("/path/to/keyview/bin");
objFilter.setInputSource("InputFile.docx");
objFilter.filterTo("OutputFile.txt");
import keyview.filter as kv
with kv.FilterSession("/path/to/keyview/bin", license) as session:
with session.open("InputFile.docx") as doc:
doc.filter("OutputFile.txt")