How to extract the name of the imported file to the field value?
If the challenge ahead is to extract only the filename then needed to find a way to split the achieved string. Built-in methods of FlexiCapture's interfaces don't allow to solve this task in one action.
It would be better to work with the interface IPage.
However, a huge string will be gotten. For different import methods (IMAP, Hot folder, etc) the string will be different too. As described in the article of ABBYY Support Center:
The source of an image. If the image was imported from a file, this property will contain the path to the file. If the image was received from a scanner, ImageSource will contain the name of the source. Contains an empty value if the image was imported using a custom import.
The most appropriate way - is extraction via script rule into the regular field with turned-off recognition. Use the script rule.
- Let's separate the whole string to the array of strings by "\" separator for import from the hot folder and "\\" for mailbox import.
- Write the last array element as the field value.
Here is a code snippet:
string s = Context.Document.Pages.ImageSource; //Whole source name
string words = s.Split('\\'); //Separator symbol, for the import from mailbox it should be '\"'
Context.Field("FileName").Text = words[words.Length -1]; //filename is in the end, it should be N-1th element
Note: The method doesn't work on web stations.