GetAvailableLanguageCount Method (GdPictureOCR)
In This Topic
Returns a number of all known language dictionaries available in the currently defined resource folder.
Syntax
'Declaration
Public Function GetAvailableLanguageCount() As Integer
public int GetAvailableLanguageCount()
public function GetAvailableLanguageCount(): Integer;
public function GetAvailableLanguageCount() : int;
public: int GetAvailableLanguageCount();
public:
int GetAvailableLanguageCount();
Return Value
The number 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.
Example
How to find out the number of all available languages in the specified resource folder.
Dim caption As String = "Example: GetAvailableLanguageCount"
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: GetAvailableLanguageCount";
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);
}
}
Example
How to find out the number of all available languages in the specified resource folder.
Dim caption As String = "Example: GetAvailableLanguageCount"
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: GetAvailableLanguageCount";
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 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