Search code examples
c#asp.net-web-api2kofax

Kofax TotalAgility Send a PDF Document to Jobs Queue (KTA)


I'm at a loss with the KTA SDK. My intention is to pass a scanned document in PDF format with a few headers to KTA's jobs queue. As I'm still going through the documentation, my best guess right now is to use the Document class as a DTO then I need to call a method to pass that Document as a parameter:

...

[HttpPost]
public HttpResponseMessage Upload()
{
  var httpRequest = System.Web.HttpContext.Current.Request;

  var DocType = httpRequest.Headers["X-DocType"];
  var Pages = httpRequest.Headers["X-DocPages"];
  var Title = httpRequest.Headers["X-DocTitle"];

  Agility.Sdk.Model.Capture.Document doc = new Agility.Sdk.Model.Capture.Document();
  // doc.DocumentType = DocType; // Type DocumentTypeSummary
  doc.NumberOfPages = Convert.ToInt32(Pages);
  doc.FileName = Title;

...
  • I'm just wondering if I'm on the right track in doing this?
  • My other question is where can we store data from a custom header? In this example, I need to store custom header called Comments and AccountNumber.
  • Lastly, what service needs to be called to send this document to KTA jobs queue? Would CaptureDocumentService be the right one?

I'd greatly appreciate any help on this.


Solution

  • Start with the details laid out in the Sample App example. It shows what to add to your app.config, but what it doesn’t call out explicitly enough is that you should change the SdkServicesLocation value for your environment. You will simply call the functions in the services within the TotalAgility.Sdk namespaces and it will handle the webservice calls.

    The CaptureDocumentService might be part of what you need, and there is a set of samples dedicated to the functions on that service. It refers to the Sample Processes folder, which by default is here:

    C:\Program Files\Kofax\TotalAgility\Sample Processes\Capture SDK Sample Package
    

    However what you will definitely need are the functions on the JobService. There are different functions with different options, but CreateJobWithDocuments is probably what you want to start with. You can see that this is creating document(s) and a job together in one step.

    There is similarity with the parameters on CaptureDocumentService.CreateDocument3, so you might cross-reference with that to best understand the parameters. The difference is that CreateDocument3 just creates a document in the abstract: you want to actually use it as an input to create a job, so use the combined function.

    Finally, to pass fields in, you will be setting RuntimeField objects as part of the RuntimeDocument objects going into your CreateJobWithDocuments call.