NumChars Property

Returns the number of characters in the recognized text. Read-only Long.

expression.NumChars

*expression   * Required. An expression that returns a Layout object.

Remarks

The NumChars property returns the number of characters recognized by optical character recognition (OCR). If NumChars is zero (0), the page does not contain text or the OCR engine has failed to find any text on the page.

In East Asian languages, each character counts as a word. As a result, in recognized text consisting exclusively of East Asian characters, the NumChars and NumWords properties return the same value.

Example

The following example loads a document, performs OCR on the first page, and then displays information (including the number of characters) about the page's OCR layout.

Sub TestLayoutProperties()

  Dim miDoc As MODI.Document
  Dim miLayout As MODI.Layout
  Dim strLayoutInfo As String
  
  Set miDoc = New MODI.Document
  miDoc.Create "C:\document1.tif"
  
  miDoc.Images(0).OCR
  
  Set miLayout = miDoc.Images(0).Layout
  strLayoutInfo = _
    "Language: " & miLayout.Language & vbCrLf & _
    "Number of characters: " & miLayout.NumChars & vbCrLf & _
    "Number of fonts: " & miLayout.NumFonts & vbCrLf & _
    "Number of words: " & miLayout.NumWords & vbCrLf & _
    "Beginning of text: " & Left(miLayout.Text, 50) & vbCrLf & _
    "First word of text: " & miLayout.Words(0).Text
  MsgBox strLayoutInfo, vbInformation + vbOKOnly, _
    "Layout Information"
  
  Set miLayout = Nothing
  Set miDoc = Nothing

End Sub

Applies to | Layout Object