VintaSoft Imaging .NET SDK 15.2: Documentation for .NET developer
Vintasoft.Imaging.Text Namespace / TextRegion Class / GetLineSubregion Methods / GetLineSubregion(PointF) Method
Syntax Example Requirements SeeAlso
In This Topic
GetLineSubregion(PointF) Method (TextRegion)
In This Topic
Returns a text region that contains a line at specified point.
Syntax
'Declaration

Public Overloads Function GetLineSubregion( _
ByVal point
Location of line.
As System.Drawing.PointF _
) As TextRegion
public TextRegion GetLineSubregion(
System.Drawing.PointF point
)

Parameters

point
Location of line.

Return Value

Text region that contains a line at specified point.
Example

This C#/VB.NET code shows how to get text line of PDF page.


''' <summary>
''' Returns the text line of PDF page.
''' </summary>
''' <param name="imageViewer">Image viewer.</param>
''' <param name="location">Point on image viewer.</param>
''' <returns>Text line of PDF page.</returns>
Public Shared Function GetLineTextPage(imageViewer As Vintasoft.Imaging.UI.ImageViewer, location As System.Drawing.PointF) As String
    Dim image As Vintasoft.Imaging.VintasoftImage = imageViewer.Image
    If image.Metadata.TextRegion Is Nothing Then
        Return ""
    End If

    ' get transform from image to Text space
    Dim fromImageToTextSpaceTransform As Vintasoft.Imaging.AffineMatrix = image.Metadata.TextRegion.GetTransformFromImageToTextSpace(image.Resolution)

    ' get transform from ImageViewer space to image space
    Dim fromImageViewerToImageSpaceTransform As Vintasoft.Imaging.AffineMatrix = imageViewer.GetTransformFromControlToImage(image)

    ' create transform from ImageViewer space to Text space
    Dim fromImageViewerToTextSpaceTransform As Vintasoft.Imaging.AffineMatrix = Vintasoft.Imaging.AffineMatrix.Multiply(fromImageViewerToImageSpaceTransform, fromImageToTextSpaceTransform)

    ' convert the point from the control coordinates to the text region coordinates
    location = Vintasoft.Imaging.PointFAffineTransform.TransformPoint(fromImageViewerToTextSpaceTransform, location)

    ' get the text line of the page
    Dim textRegion As Vintasoft.Imaging.Text.TextRegion = image.Metadata.TextRegion.GetLineSubregion(location)

    Dim textContent As String = String.Empty
    ' if text line is found
    If textRegion IsNot Nothing Then
        textContent = textRegion.TextContent
    End If

    Return textContent
End Function


/// <summary>
/// Returns the text line of PDF page.
/// </summary>
/// <param name="imageViewer">Image viewer.</param>
/// <param name="location">Point on image viewer.</param>
/// <returns>Text line of PDF page.</returns>
public static string GetLineTextPage(
    Vintasoft.Imaging.UI.ImageViewer imageViewer, 
    System.Drawing.PointF location)
{
    Vintasoft.Imaging.VintasoftImage image = imageViewer.Image;
    if (image.Metadata.TextRegion == null)
        return "";

    // get transform from image to Text space
    Vintasoft.Imaging.AffineMatrix fromImageToTextSpaceTransform = image.Metadata.TextRegion.GetTransformFromImageToTextSpace(image.Resolution);

    // get transform from ImageViewer space to image space
    Vintasoft.Imaging.AffineMatrix fromImageViewerToImageSpaceTransform = imageViewer.GetTransformFromControlToImage(image);

    // create transform from ImageViewer space to Text space
    Vintasoft.Imaging.AffineMatrix fromImageViewerToTextSpaceTransform = 
        Vintasoft.Imaging.AffineMatrix.Multiply(fromImageViewerToImageSpaceTransform, fromImageToTextSpaceTransform);

    // convert the point from the control coordinates to the text region coordinates
    location = Vintasoft.Imaging.PointFAffineTransform.TransformPoint(fromImageViewerToTextSpaceTransform, location);

    // get the text line of the page
    Vintasoft.Imaging.Text.TextRegion textRegion = 
        image.Metadata.TextRegion.GetLineSubregion(location);

    string textContent = string.Empty;
    // if text line is found
    if (textRegion != null)
        textContent = textRegion.TextContent;

    return textContent;
}

Requirements

Target Platforms: .NET 11; .NET 10; .NET 9; .NET 8; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

See Also