Dim caption As String = "Example: SaveAsHTML"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Load the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If gdpictureImaging.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim oStream As System.IO.FileStream = New System.IO.FileStream("OCR_result.html", System.IO.FileMode.Create)
'Save the result.
If gdpictureOCR.SaveAsHTML(resID, oStream, True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR result has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsHTML() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
oStream.Dispose()
Else
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpictureImaging.GetStat.ToString, caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: SaveAsHTML";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Load the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
System.IO.FileStream oStream = new System.IO.FileStream("OCR_result.html", System.IO.FileMode.Create);
//Save the result.
if (gdpictureOCR.SaveAsHTML(resID, oStream, true) == GdPictureStatus.OK)
MessageBox.Show("The OCR result has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsHTML() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
oStream.Dispose();
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpictureImaging.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}