GetAvailableLanguage Method (GdPictureOCR)
In This Topic
Returns a name of the specific known language dictionary available in the currently defined resource folder according to the index you have specified. You can use the
GetAvailableLanguageCount method to determine the number of all available language dictionaries. The index is simply an integer value within the interval from 0 to
GetAvailableLanguageCount-1.
Syntax
'Declaration
Public Function GetAvailableLanguage( _
ByVal As Integer _
) As OCRLanguage
public OCRLanguage GetAvailableLanguage(
int
)
public function GetAvailableLanguage(
: Integer
): OCRLanguage;
public function GetAvailableLanguage(
: int
) : OCRLanguage;
public: OCRLanguage GetAvailableLanguage(
int
)
public:
OCRLanguage GetAvailableLanguage(
int
)
Parameters
- LanguageIdx
- The language dictionary index. It must be an integer value between 0 and GetAvailableLanguageCount-1.
Return Value
A member of the OCRLanguage enumeration. A specified language dictionary.
Please always use the GetStat method to determine if this method has been successful.
Example
How to find out if the required language dictionary is available in the current resource folder.
Dim caption As String = "Example: GetAvailableLanguage"
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 lang As OCRLanguage = 0
Dim found As Boolean = False
For idx As Integer = 0 To count - 1
lang = gdpictureOCR.GetAvailableLanguage(idx)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
found = (lang = OCRLanguage.English)
If found Then Exit For
Else
MessageBox.Show("The GetAvailableLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then MessageBox.Show("The number of available languages: " + count.ToString() + vbCrLf + "English: " + found.ToString(), caption)
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: GetAvailableLanguage";
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)
{
OCRLanguage lang = 0;
Boolean found = false;
for (int idx = 0; idx < count; idx++)
{
lang = gdpictureOCR.GetAvailableLanguage(idx);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
found = (lang == OCRLanguage.English);
if (found) break;
}
else
{
MessageBox.Show("The GetAvailableLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
break;
}
}
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
MessageBox.Show("The number of available languages: " + count.ToString() + "\nEnglish: " + found.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);
}
Example
How to find out if the required language dictionary is available in the current resource folder.
Dim caption As String = "Example: GetAvailableLanguage"
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 lang As OCRLanguage = 0
Dim found As Boolean = False
For idx As Integer = 0 To count - 1
lang = gdpictureOCR.GetAvailableLanguage(idx)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
found = (lang = OCRLanguage.English)
If found Then Exit For
Else
MessageBox.Show("The GetAvailableLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then MessageBox.Show("The number of available languages: " + count.ToString() + vbCrLf + "English: " + found.ToString(), caption)
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: GetAvailableLanguage";
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)
{
OCRLanguage lang = 0;
Boolean found = false;
for (int idx = 0; idx < count; idx++)
{
lang = gdpictureOCR.GetAvailableLanguage(idx);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
found = (lang == OCRLanguage.English);
if (found) break;
}
else
{
MessageBox.Show("The GetAvailableLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
break;
}
}
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
MessageBox.Show("The number of available languages: " + count.ToString() + "\nEnglish: " + found.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