TsgcAIDocumentExtractor › Methods › ExtractFiles

ExtractFiles Method

Extracts the data of several files that make up one document.

Syntax

function ExtractFiles(const aFileNames: TStrings): string;

Parameters

NameTypeDescription
aFileNamesconst TStringsFull paths of the files, one per line, in page order.

Return Value

The extracted data as a JSON document, the same text as LastResult.Data. (string)

Remarks

Every file is attached, in order, to one single request, so the model sees them as the pages of one document and returns one data object. Use it for an invoice scanned as one image per page. Empty lines are skipped, and a list without any file raises EsgcAIDocumentExtractor.

Raises EsgcAIDocumentExtractor when AIChat is not assigned, when the schema is empty or invalid, when there is nothing to extract, when OCRMode needs an OCR that is not assigned, and when the data does not validate and RaiseOnInvalid is True. Transport and provider errors of the chat propagate to the caller as they are, they do not reach OnChatError.

Example

oFiles := TStringList.Create;
Try
  oFiles.Add('page1.png');
  oFiles.Add('page2.png');
  vJSON := oExtractor.ExtractFiles(oFiles);
Finally
  oFiles.Free;
End;

Back to Methods