GdPicture.NET.14.API
GdPicture14 Namespace / GdPictureOCR Class / GetAvailableLanguages() Method
Example





In This Topic
GetAvailableLanguages() Method
In This Topic
Returns a name list of all known language dictionaries available in the currently defined resource folder.
Syntax
'Declaration
 
Public Function GetAvailableLanguages() As IList(Of OCRLanguage)
public IList<OCRLanguage> GetAvailableLanguages()
public function GetAvailableLanguages(): IList; 
public function GetAvailableLanguages() : IList;
public: IList<OCRLanguage>* GetAvailableLanguages(); 
public:
IList<OCRLanguage>^ GetAvailableLanguages(); 

Return Value

The name list of all known language dictionaries available in the current resource folder.

Please always use the GdPictureOCR.GetStat method to determine if this method has been successful.

Remarks
Please ensure that you have correctly set up your prefered resource folder for OCR dictionaries.

It is recommend to use the GdPictureOCR.GetStat method to identify the specific reason for the method's failure, if any.

Example
How to find out all available languages in the specified resource folder.
Dim caption As String = "Example: GetAvailableLanguages"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
    'Specify your resource folder for OCR dictionaries.
    gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
    Dim count As Integer = gdpictureOCR.GetAvailableLanguageCount()
    If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
        If count > 0 Then
            Dim list As IList(Of OCRLanguage) = gdpictureOCR.GetAvailableLanguages()
            If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
                Dim languages As String = list.ElementAt(0).ToString()
                Dim lang As OCRLanguage = 0
                For idx As Integer = 1 To count - 1
                    lang = list.ElementAt(idx)
                    languages = languages + ", " + lang.ToString()
                Next
                MessageBox.Show("The number of available languages: " + count.ToString() + vbCrLf + "Languages:" + vbCrLf + languages, caption)
            Else
                MessageBox.Show("The GetAvailableLanguages() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
            End If
        Else
            MessageBox.Show("No languages are available in this resource folder: " + gdpictureOCR.ResourcesFolder, caption)
        End If
    Else
        MessageBox.Show("The GetAvailableLanguageCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
    End If
End Using
string caption = "Example: GetAvailableLanguages";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
    //Specify your resource folder for OCR dictionaries.
    gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
 
    int count = gdpictureOCR.GetAvailableLanguageCount();
    if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
    {
        if (count > 0)
        {
            IList<OCRLanguage> list = gdpictureOCR.GetAvailableLanguages();
            if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
            {
                string languages = list.ElementAt(0).ToString();
                OCRLanguage lang = 0;
                for (int idx = 1; idx < count; idx++)
                {
                    lang = list.ElementAt(idx);
                    languages = languages + ", " + lang.ToString();
                }
                MessageBox.Show("The number of available languages: " + count.ToString() + "\nLanguages:\n" + languages, caption);
            }
            else
            {
                MessageBox.Show("The GetAvailableLanguages() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
            }
        }
        else
            MessageBox.Show("No languages are available in this resource folder: " + gdpictureOCR.ResourcesFolder, caption);
    }
    else
    {
        MessageBox.Show("The GetAvailableLanguageCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
    }
}
See Also