Description
The Bounds
property returns an object that describes the bounds of a tabular data block within an object or image to which the block belongs.
Declaration
OCRTableObj.Bounds
Read-Only Property |
A Bounds object
|
OCRTableObj | An expression, variable or parameter that specifies a reference to an OCRTable object |
Applies To
The property is applied to the following object:
Property Value
A Bounds
object that describes the rectangle containing the recognized tabular data.
Example
The following example shows how to use optical character recognition to recognize the tabular data on a web page and get the rectangle that contains the data:
JavaScript, JScript
function Main()
{
// Navigate to the tested web page
var url = "https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_border";
Browsers.Item("chrome").Run(url);
// Get the page area containing the table
var page = Sys.Browser("chrome").Page("*");
var gridArea = page.FindChild("idStr", "iframeresult", 10);
if (gridArea != null)
{
// Specify whether the table has a header
var hasHeader = true;
// Specify the preferable search area
var searchPref = spNone;
// Recognize the table content
var table = OCR.Recognize(gridArea).DetectTable(searchPref, hasHeader);
// Post an image of the screen area
// That contains the recognized table
x = table.Bounds.Left;
y = table.Bounds.Top;
width = table.Bounds.Width;
height = table.Bounds.Height;
str = "View the image of the area containing the table in the Picture panel";
Log.Picture(gridArea.Picture(x, y, width, height), str);
}
else
Log.Warning("Cannot obtain the search area.");
}
{
// Navigate to the tested web page
var url = "https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_border";
Browsers.Item("chrome").Run(url);
// Get the page area containing the table
var page = Sys.Browser("chrome").Page("*");
var gridArea = page.FindChild("idStr", "iframeresult", 10);
if (gridArea != null)
{
// Specify whether the table has a header
var hasHeader = true;
// Specify the preferable search area
var searchPref = spNone;
// Recognize the table content
var table = OCR.Recognize(gridArea).DetectTable(searchPref, hasHeader);
// Post an image of the screen area
// That contains the recognized table
x = table.Bounds.Left;
y = table.Bounds.Top;
width = table.Bounds.Width;
height = table.Bounds.Height;
str = "View the image of the area containing the table in the Picture panel";
Log.Picture(gridArea.Picture(x, y, width, height), str);
}
else
Log.Warning("Cannot obtain the search area.");
}
Python
def Main():
# Navigate to the test web page
url = "https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_border"
Browsers.Item["chrome"].Run(url)
# Get the page area containing the table
page = Sys.Browser("chrome").Page("*")
gridArea = page.FindChild("idStr", "iframeresult", 10)
if (gridArea != None):
# Specify whether the table has a header
hasHeader = True
# Specify the preferable search area
searchPref = spNone
# Recognize the table contents
table = OCR.Recognize(gridArea).DetectTable[searchPref, hasHeader]
# Post an image of the screen area
# That contains the recognized table
x = table.Bounds.Left
y = table.Bounds.Top
width = table.Bounds.Width
height = table.Bounds.Height
str = "View the image of the area containing the table in the Picture panel"
Log.Picture(gridArea.Picture(x, y, width, height), str)
else:
Log.Warning("Cannot obtain the search area.")
VBScript
Sub Main
' Navigate to the tested web page
url = "https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_border"
Browsers.Item("chrome").Run(url)
' Get the page area containing the table
Set page = Sys.Browser("chrome").Page("*")
Set gridArea = page.FindChild("idStr", "iframeresult", 10)
If Not gridArea Is Nothing Then
' Specify whether the table has a header
hasHeader = True
' Specify the preferable search area
searchPref = spNone
' Recognize the table content
Set table = OCR.Recognize(gridArea).DetectTable(searchPref, hasHeader)
' Post an image of the screen area
' That contains the recognized table
x = table.Bounds.Left
y = table.Bounds.Top
width = table.Bounds.Width
height = table.Bounds.Height
str = "View the image of the area containing the table in the Picture panel"
Call Log.Picture(gridArea.Picture(x, y, width, height), str)
Else
Log.Warning("Cannot obtain the search area.")
End If
End Sub
' Navigate to the tested web page
url = "https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_border"
Browsers.Item("chrome").Run(url)
' Get the page area containing the table
Set page = Sys.Browser("chrome").Page("*")
Set gridArea = page.FindChild("idStr", "iframeresult", 10)
If Not gridArea Is Nothing Then
' Specify whether the table has a header
hasHeader = True
' Specify the preferable search area
searchPref = spNone
' Recognize the table content
Set table = OCR.Recognize(gridArea).DetectTable(searchPref, hasHeader)
' Post an image of the screen area
' That contains the recognized table
x = table.Bounds.Left
y = table.Bounds.Top
width = table.Bounds.Width
height = table.Bounds.Height
str = "View the image of the area containing the table in the Picture panel"
Call Log.Picture(gridArea.Picture(x, y, width, height), str)
Else
Log.Warning("Cannot obtain the search area.")
End If
End Sub
DelphiScript
procedure Main();
var url, page, gridArea, hasHeader, searchPref, table, x, y, width, height, str;
begin
// Navigate to the tested web page
url := 'https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_border';
Browsers.Item('chrome').Run(url);
// Get the page area containing the table
page := Sys.Browser('chrome').Page('*');
gridArea := page.FindChild('idStr', 'iframeresult', 10);
if gridArea <> nil then
begin
// Specify whether the table has a header
hasHeader := true;
// Specify the preferable search area
searchPref := spNone;
// Recognize the table content
table := OCR.Recognize(gridArea).DetectTable(searchPref, hasHeader);
// Post an image of the screen area
// That contains the recognized table
x := table.Bounds.Left;
y := table.Bounds.Top;
width := table.Bounds.Width;
height := table.Bounds.Height;
str := 'View the image of the area containing the table in the Picture panel';
Log.Picture(gridArea.Picture(x, y, width, height), str);
end
else
Log.Warning('Cannot obtain the search area.');
end;
var url, page, gridArea, hasHeader, searchPref, table, x, y, width, height, str;
begin
// Navigate to the tested web page
url := 'https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_border';
Browsers.Item('chrome').Run(url);
// Get the page area containing the table
page := Sys.Browser('chrome').Page('*');
gridArea := page.FindChild('idStr', 'iframeresult', 10);
if gridArea <> nil then
begin
// Specify whether the table has a header
hasHeader := true;
// Specify the preferable search area
searchPref := spNone;
// Recognize the table content
table := OCR.Recognize(gridArea).DetectTable(searchPref, hasHeader);
// Post an image of the screen area
// That contains the recognized table
x := table.Bounds.Left;
y := table.Bounds.Top;
width := table.Bounds.Width;
height := table.Bounds.Height;
str := 'View the image of the area containing the table in the Picture panel';
Log.Picture(gridArea.Picture(x, y, width, height), str);
end
else
Log.Warning('Cannot obtain the search area.');
end;
C++Script, C#Script
function Main()
{
// Navigate to the tested web page
var url = "https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_border";
Browsers["Item"]("chrome")["Run"](url);
// Get the page area containing the table
var page = Sys["Browser"]("chrome")["Page"]("*");
var gridArea = page["FindChild"]("idStr", "iframeresult", 10);
if (gridArea != null)
{
// Specify whether the table has a header
var hasHeader = true;
// Specify the preferable search area
var searchPref = spNone;
// Recognize the table content
var table = OCR.Recognize(gridArea).DetectTable(searchPref, hasHeader);
// Post an image of the screen area
// That contains the recognized table
x = table["Bounds"]["Left"];
y = table["Bounds"]["Top"];
width = table["Bounds"]["Width"];
height = table["Bounds"]["Height"];
str = "View the image of the area containing the table in the Picture panel";
Log["Picture"](gridArea["Picture"](x, y, width, height), str);
}
else
Log["Warning"]("Cannot obtain the search area.");
}
{
// Navigate to the tested web page
var url = "https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_border";
Browsers["Item"]("chrome")["Run"](url);
// Get the page area containing the table
var page = Sys["Browser"]("chrome")["Page"]("*");
var gridArea = page["FindChild"]("idStr", "iframeresult", 10);
if (gridArea != null)
{
// Specify whether the table has a header
var hasHeader = true;
// Specify the preferable search area
var searchPref = spNone;
// Recognize the table content
var table = OCR.Recognize(gridArea).DetectTable(searchPref, hasHeader);
// Post an image of the screen area
// That contains the recognized table
x = table["Bounds"]["Left"];
y = table["Bounds"]["Top"];
width = table["Bounds"]["Width"];
height = table["Bounds"]["Height"];
str = "View the image of the area containing the table in the Picture panel";
Log["Picture"](gridArea["Picture"](x, y, width, height), str);
}
else
Log["Warning"]("Cannot obtain the search area.");
}