-2

I could only find code using C#, but maybe someone can translate this into vb.net or assist with VB.NET code could that could help me. I'm only a beginner that worked with VB.net. I went to leadtools forums, but there is no example for what i want and most of the examples is written in only in C#

    void HiliteWord(AnnContainer container, IOcrPage page, OcrWord word)
{
    // Get bounds of word as LeadRectD
    LeadRectD bounds = word.Bounds.ToRectangle(page.DpiX, page.DpiY).ToLeadRectD();
    // Convert to annotation coordinates
    bounds = container.Mapper.RectToContainerCoordinates(bounds);
    // Create the annotation
    AnnHiliteObject hilite = new AnnHiliteObject();
    hilite.Points.Clear();
    hilite.Points.Add(bounds.TopLeft);
    hilite.Points.Add(bounds.TopRight);
    hilite.Points.Add(bounds.BottomRight);
    hilite.Points.Add(bounds.BottomLeft);
    // Add to container
    container.Children.Add(hilite);
}
  • 1
    Have a look at http://converter.telerik.com/ This site will allow you to paste your code and click the convert button - Add it to your bookmarks – David Wilson Aug 22 '18 at 13:44
  • By the way.. Welcome to Stack Overflow. Its really important to ask questions properly here. Have a look at [ask] and [mcve]. As it stands, your question is off-topic because this isn't for asking about code translation. It's for questions regarding specific issues with existing code. Don't let negative votes or votes to close put you off though. Thanks – David Wilson Aug 22 '18 at 13:46

1 Answers1

0

As David said in his comments, you can convert c# to vb.net using an online converter. Also, just so you know, the LEADTOOLS SDK has chat, emails, and forums as support options if you need assistance with the SDK:

https://www.leadtools.com/support/supportoptions

I ran the above code in the converter that David linked and this was the output which is correct and will work in your application:

Private Sub HiliteWord(ByVal container As AnnContainer, ByVal page As IOcrPage, ByVal word As OcrWord)
    Dim bounds As LeadRectD = word.Bounds.ToRectangle(page.DpiX, page.DpiY).ToLeadRectD()
    bounds = container.Mapper.RectToContainerCoordinates(bounds)
    Dim hilite As AnnHiliteObject = New AnnHiliteObject()
    hilite.Points.Clear()
    hilite.Points.Add(bounds.TopLeft)
    hilite.Points.Add(bounds.TopRight)
    hilite.Points.Add(bounds.BottomRight)
    hilite.Points.Add(bounds.BottomLeft)
    container.Children.Add(hilite)
End Sub
hcham1
  • 1,799
  • 2
  • 16
  • 27