GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / SearchAndHighlight Method
The regular expression pattern to search for.
Set this parameter to true if you want to apply case-sensitive search, otherwise set it to false.
The amount of red color to be used for the highlight annotation. Use the value between 0 and 255.
The amount of green color to be used for highlight annotation. Use the value between 0 and 255.
The amount of blue color to be used for the highlight annotation. Use the value between 0 and 255.
The transparency value of the highlight annotation. Use the value between 0 (full transparency) and 255 (full opacity).
Output parameter. If the method has been successfully followed, then the parameter will return number of occurrences found.
Example





In This Topic
SearchAndHighlight Method (GdPicturePDF)
In This Topic
Searches for all occurrences of a given regular expression pattern within the currently loaded PDF document and highlights every occurrence found usign Highlight text markup annotation.
Syntax
'Declaration
 
Public Function SearchAndHighlight( _
   ByVal Pattern As String, _
   ByVal CaseSensitive As Boolean, _
   ByVal Red As Byte, _
   ByVal Green As Byte, _
   ByVal Blue As Byte, _
   ByVal Alpha As Byte, _
   ByRef Occurrences As Integer _
) As GdPictureStatus
public GdPictureStatus SearchAndHighlight( 
   string Pattern,
   bool CaseSensitive,
   byte Red,
   byte Green,
   byte Blue,
   byte Alpha,
   ref int Occurrences
)
public function SearchAndHighlight( 
    Pattern: String;
    CaseSensitive: Boolean;
    Red: Byte;
    Green: Byte;
    Blue: Byte;
    Alpha: Byte;
   var  Occurrences: Integer
): GdPictureStatus; 
public function SearchAndHighlight( 
   Pattern : String,
   CaseSensitive : boolean,
   Red : byte,
   Green : byte,
   Blue : byte,
   Alpha : byte,
   Occurrences : int
) : GdPictureStatus;
public: GdPictureStatus SearchAndHighlight( 
   string* Pattern,
   bool CaseSensitive,
   byte Red,
   byte Green,
   byte Blue,
   byte Alpha,
   ref int Occurrences
) 
public:
GdPictureStatus SearchAndHighlight( 
   String^ Pattern,
   bool CaseSensitive,
   byte Red,
   byte Green,
   byte Blue,
   byte Alpha,
   int% Occurrences
) 

Parameters

Pattern
The regular expression pattern to search for.
CaseSensitive
Set this parameter to true if you want to apply case-sensitive search, otherwise set it to false.
Red
The amount of red color to be used for the highlight annotation. Use the value between 0 and 255.
Green
The amount of green color to be used for highlight annotation. Use the value between 0 and 255.
Blue
The amount of blue color to be used for the highlight annotation. Use the value between 0 and 255.
Alpha
The transparency value of the highlight annotation. Use the value between 0 (full transparency) and 255 (full opacity).
Occurrences
Output parameter. If the method has been successfully followed, then the parameter will return number of occurrences found.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.

We strongly recommend always checking this status first.

Remarks
This method is only allowed for use with non-encrypted documents.
Example
How to highlight all occurrences of text string in PDF document.
Using gdpicturePDF As New GdPicturePDF
   gdpicturePDF.LoadFromFile("input.pdf")
   Dim occurrences As Integer = 0
   gdpicturePDF.SearchAndHighlight("Sensitive text string", True, 0, 0, 0, 255, occurrences)
   gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
    gdpicturePDF.LoadFromFile("input.pdf");
    int occurrences = 0;
    gdpicturePDF.SearchAndHighlight("Sensitive text string", true, 0, 0, 0, 255, ref occurrences);
    gdpicturePDF.SaveToFile("output.pdf");
}
See Also