Sample Client |
The primary entry point to the API module is the Processor class. This class is used to run the report miner processing engine using a model definition file, a report file that you wish to process against the model and, optionally, a plugin DLL file that you have developed to control the processing engine. The sample code below illustrates a console application which runs the processing engine and prints the extracted data to the console.
/*------------------------------------------------------------------- A simple Windows console application that runs a Opait Report Miner model against a PDF file with an optional plugin DLL. The output is formatted and printed to the console screen. --------------------------------------------------------------------*/ using System; using Opait.ReportMiner.Api; namespace ReportMinerClient { class Program { const string Syntax = "Syntax: Client -m <model> [-r <report>] [-p <plugin>]"; // Logs all messages to the console screen. static void Log(string message) { Console.WriteLine(message); } static void Main(string[] args) { string model = null; string report = null; string plugin = null; // Parse the command line arguments. for (var i = 0; i < args.Length - 1; i += 2) { switch (args[i].ToLower()) { case "-m": model = args[i + 1]; break; case "-r": report = args[i + 1]; break; case "-p": plugin = args[i + 1]; break; default: Log(Syntax); return; } } // Model is the only required argument. if (model == null) { Log(Syntax); return; } // Create an instance of the report miner processor. using (var processor = new Processor()) { // Run the processor to extract records from the PDF file. var records = processor.ParseRecords(model, report, plugin); // Format and display global fields, if any. Log(processor.FormatGlobalFields()); // Format and display each extracted record. foreach (var record in records) Log(processor.FormatRecord(record)); } } } }