Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.12.21
Working with Zones
Take the following steps to add code to the existing project that demonstrates how to work with pages in an OCR document:
  1. Start with the program you created in Working with Pages.
  2. Drag and drop three buttons in Form1. Leave all the buttons names as the default "button7, button8, button9 ", then change the following properties of button7:
    PropertyValue
    TextFind Zones
  3. Change the following properties of button8:
    PropertyValue
    TextZones Count
  4. Change the following properties of button9:
    PropertyValue
    TextVerify Zone
  5. Switch to Form1 code view (Right-click Form1 in the solution explorer then select View Code ) and add the following code to the button7 control’s click procedure:

    [Visual Basic]

    
    Private Sub button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button7.Click
       Try
          ' Find all the zones of the first page of RasterDocument object
          rasterDocument.EnableZoneForceSingleColumn = True
          rasterDocument.ShowZoneGridlines = True
          rasterDocument.FindZones(0, Rectangle.Empty)
          MessageBox.Show("Automatic zones method finds all available zones into the specified pages successfully")
       Catch ex As Exception
          ' Error
          MessageBox.Show("Error: " + ex.Message + " in finding available zone in the specified page")
       End Try
    End Sub
    
    [C#]
    
    private void button7_Click(object sender, System.EventArgs e)
    {
       try
       {
          // Find all the zones of the first page of RasterDocument object
          rasterDocument.EnableZoneForceSingleColumn = true;
          rasterDocument.ShowZoneGridlines = true;
          rasterDocument.FindZones(0, Rectangle.Empty);
          MessageBox.Show("Automatic zones method finds all available zones into the specified pages successfully");
       }
       catch(Exception ex)
       {
          //Error
          MessageBox.Show("Error: " + ex.Message + " in finding available zone in the specified page");
       }
    }
    
  6. Add the following code to the button8 control’s click procedure:

    [Visual Basic]

     
    Private Sub button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button8.Click
       ' Print the number of zones in the first page
       MessageBox.Show("Total zones count = " & rasterDocument.GetZoneCount(0))
    End Sub
    
    [C#]
    
    private void button8_Click(object sender, System.EventArgs e)
    {
       // Print the number of zones in the first page
       MessageBox.Show("Total zones count = " + rasterDocument.GetZoneCount(0));
    }
    
  7. Add the following code to the button9 control’s click procedure:

    [Visual Basic]

    
    Private Sub button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button9.Click
       Dim zonesCount As Integer
       Dim i As Integer
       
       zonesCount = rasterDocument.GetZoneCount(0)
       For i = 0 To zonesCount - 1
          ' Get The zones information of the first page of RasterDocument object
          rasterDocumentZoneData = rasterDocument.GetZone(0, i)
          rasterDocumentZoneData.Flags = (rasterDocumentZoneData.Flags And (Not RasterDocumentZoneFlags.DoNotUseVerificationEvent))
          
          Try
             ' Update the zones information of the first page of RasterDocument object
             rasterDocument.UpdateZone(0, i, rasterDocumentZoneData)
          Catch ex As Exception
             MessageBox.Show("Error: " + ex.Message + " in updating zone # " + i.ToString())
          End Try
       Next i
    End Sub
    
    [C#]
     
    private void button9_Click(object sender, System.EventArgs e)
    {
       int zonesCount;
       int i;
       
       zonesCount = rasterDocument.GetZoneCount(0);
       for (i = 0; i < zonesCount; i++)
       {
          // Get The zones information of the first page of RasterDocument object
          rasterDocumentZoneData = rasterDocument.GetZone(0, i);
          rasterDocumentZoneData.Flags = (rasterDocumentZoneData.Flags & (~RasterDocumentZoneFlags.DoNotUseVerificationEvent));
          
          try
          {
             // Update the zones information of the first page of RasterDocument object
             rasterDocument.UpdateZone(0, i, rasterDocumentZoneData);
          }
          catch(Exception ex)
          {
             MessageBox.Show("Error: " + ex.Message + " in updating zone # " + i.ToString());
          }
       }
    }
    
  8. Build, and Run the program to test it.
  9. Save this project to use for testing other code samples.