'We assume that the GdViewer1 control has been integrated into your application.
If GdViewer1.DisplayFromFile("text_to_search.txt") = GdPictureStatus.OK Then
Dim annotMgr As AnnotationManager = GdViewer1.GetAnnotationManager()
If (annotMgr IsNot Nothing) AndAlso (annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim text_to_find As String = "GdPicture"
Dim occurrence As Integer = 1
Dim left As Single = 0, top As Single = 0, width As Single = 0, height As Single = 0
Dim text_found As Boolean = False
GdViewer1.RemoveAllRegions()
While GdViewer1.SearchText(GdViewer1.CurrentPage, text_to_find, occurrence, True, left, top, width, height)
text_found = True
Dim annotRectH As GdPicture14.Annotations.AnnotationRectangleHighlighter = annotMgr.AddRectangleHighlighterAnnot(Color.Yellow, left, top, width, height)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotRectH IsNot Nothing) Then
annotRectH.Author = "GdPicture"
annotRectH.Tag = "Highligher"
End If
annotRectH.Dispose()
GdViewer1.AddRegionInches("Region" + occurrence.ToString(), left, top, width, height, ForegroundMixMode.ForegroundMixModeMASKPEN, Color.Yellow)
occurrence = occurrence + 1
End While
If text_found Then
If (annotMgr.SaveAnnotationsToPage() <> GdPictureStatus.OK) OrElse
(annotMgr.BurnAnnotationsToPage(True) <> GdPictureStatus.OK) OrElse
(annotMgr.SaveDocumentToJPEG("text_highlighted.jpg", 75) <> GdPictureStatus.OK) Then
MessageBox.Show("An error occurred when saving the file. Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddRectangleHighlighterAnnot")
End If
GdViewer1.Redraw()
Else
MessageBox.Show("The given text has not been found.", "AnnotationManager.AddRectangleHighlighterAnnot")
End If
Else
MessageBox.Show("The AnnotationManager can't be initialized.", "AnnotationManager.AddRectangleHighlighterAnnot")
End If
Else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "AnnotationManager.AddRectangleHighlighterAnnot")
End If
//We assume that the GdViewer1 control has been integrated into your application.
if (GdViewer1.DisplayFromFile("text_to_search.txt") == GdPictureStatus.OK)
{
AnnotationManager annotMgr = GdViewer1.GetAnnotationManager();
if ((annotMgr != null) && (annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
string text_to_find = "GdPicture";
int occurrence = 1;
float left = 0, top = 0, width = 0, height = 0;
bool text_found = false;
GdViewer1.RemoveAllRegions();
while (GdViewer1.SearchText(GdViewer1.CurrentPage, text_to_find, occurrence, true, ref left, ref top, ref width, ref height))
{
text_found = true;
GdPicture14.Annotations.AnnotationRectangleHighlighter annotRectH = annotMgr.AddRectangleHighlighterAnnot(Color.Yellow, left, top, width, height);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotRectH != null))
{
annotRectH.Author = "GdPicture";
annotRectH.Tag = "Highligher";
}
annotRectH.Dispose();
GdViewer1.AddRegionInches("Region" + occurrence.ToString(), left, top, width, height, ForegroundMixMode.ForegroundMixModeMASKPEN, Color.Yellow);
occurrence = occurrence + 1;
}
if (text_found)
{
if ((annotMgr.SaveAnnotationsToPage() != GdPictureStatus.OK) ||
(annotMgr.BurnAnnotationsToPage(true) != GdPictureStatus.OK) ||
(annotMgr.SaveDocumentToJPEG("text_highlighted.jpg", 75) != GdPictureStatus.OK))
MessageBox.Show("An error occurred when saving the file. Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddRectangleHighlighterAnnot");
GdViewer1.Redraw();
}
else
MessageBox.Show("The given text has not been found.", "AnnotationManager.AddRectangleHighlighterAnnot");
}
else
MessageBox.Show("The AnnotationManager can't be initialized.", "AnnotationManager.AddRectangleHighlighterAnnot");
}
else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "AnnotationManager.AddRectangleHighlighterAnnot");