VintaSoft Imaging .NET SDK 14.0: Документация для .NET разработчика
Vintasoft.Imaging.Text Namespace / TextRegion Class / GetLineSubregion Methods / GetLineSubregion(PointF) Method
Синтаксис Example Требования Смотрите также
В этом разделе
    GetLineSubregion(PointF) Метод (TextRegion)
    В этом разделе
    Возвращает текстовую область, содержащую строку в указанной точке.
    Синтаксис
    'Declaration
    
    Public Overloads Function GetLineSubregion( _
    ByVal point
    Местоположение линии.
    As System.Drawing.PointF _
    ) As TextRegion
    public TextRegion GetLineSubregion(
    System.Drawing.PointF point
    )
    public: TextRegion* GetLineSubregion(
    System.Drawing.PointF point
    )
    public:
    TextRegion^ GetLineSubregion(
    System.Drawing.PointF point
    )

    Parameters

    point
    Местоположение линии.

    Return Value

    Текстовая область, содержащая строку в указанной точке.
    Пример

    Вот C#/VB.NET код, который демонстрирует, как получить текстовую строку PDF страницы.

    
    ''' <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;
    }
    
    

    Требования

    Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    Смотрите также