GdPicture.NET.14
GdPicture14 Namespace / GdPictureOCR Class / SaveAsHTML Method / SaveAsHTML(String,String,Boolean) Method
A unique result identifier of the executed OCR process obtained by the RunOCR method. It specifies the OCR result you want to save.
The path to the file where the result will be saved. If the specified file already exists, it will be overwritten.
The flag indicating whether to keep line breaks or not when saving the result.
Example





In This Topic
SaveAsHTML(String,String,Boolean) Method
In This Topic
Saves the provided OCR result, identifiable by its unique ID, to a html file.
Syntax
'Declaration
 
Public Overloads Function SaveAsHTML( _
   ByVal OCRResultID As String, _
   ByVal FilePath As String, _
   ByVal KeepLineBreaks As Boolean _
) As GdPictureStatus
public GdPictureStatus SaveAsHTML( 
   string OCRResultID,
   string FilePath,
   bool KeepLineBreaks
)
public function SaveAsHTML( 
    OCRResultID: String;
    FilePath: String;
    KeepLineBreaks: Boolean
): GdPictureStatus; 
public function SaveAsHTML( 
   OCRResultID : String,
   FilePath : String,
   KeepLineBreaks : boolean
) : GdPictureStatus;
public: GdPictureStatus SaveAsHTML( 
   string* OCRResultID,
   string* FilePath,
   bool KeepLineBreaks
) 
public:
GdPictureStatus SaveAsHTML( 
   String^ OCRResultID,
   String^ FilePath,
   bool KeepLineBreaks
) 

Parameters

OCRResultID
A unique result identifier of the executed OCR process obtained by the RunOCR method. It specifies the OCR result you want to save.
FilePath
The path to the file where the result will be saved. If the specified file already exists, it will be overwritten.
KeepLineBreaks
The flag indicating whether to keep line breaks or not when saving the result.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.

We strongly recommend always checking this status first.

Example
How to save the results to html files when processing the OCR on the same image with different settings.
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
        'Set up the image you want to process.
        Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging()
        'Display the standard open file dialog 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
            'Run the first OCR process.
            'Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
            Dim result1 As String = gdpictureOCR.RunOCR()
            If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
                'Save the result.
                If gdpictureOCR.SaveAsHTML(result1, "OCR_result1.html", 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
            Else
                MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
            End If
 
            'Change OCR settings.
            gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
 
            'Run the second OCR process.
            Dim result2 As String = gdpictureOCR.RunOCR()
            If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
                'Save the result.
                If gdpictureOCR.SaveAsHTML(result2, "OCR_result2.html", 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
            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 setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.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)
    {
        //Set up 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))
        {
            //Run the first OCR process.
            //Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
            string result1 = gdpictureOCR.RunOCR();
            if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
            {
                //Save the result.
                if (gdpictureOCR.SaveAsHTML(result1, "OCR_result1.html", 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);
            }
            else
            {
                MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
            }
 
            //Change OCR settings.
            gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
 
            //Run the second OCR process.
            string result2 = gdpictureOCR.RunOCR();
            if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
            {
                //Save the result.
                if (gdpictureOCR.SaveAsHTML(result2, "OCR_result2.html", 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);
            }
            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 setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption);
        gdpictureImaging.Dispose();
    }
    else
        MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
    gdpictureOCR.ReleaseOCRResults();
}
See Also