GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / SearchAndAddRedactionRegions 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 resulting region color. Use the value between 0 and 255.
The amount of green color to be used for the resulting region color. Use the value between 0 and 255.
The amount of blue color to be used for the resulting region color. Use the value between 0 and 255.
The transparency value of the resulting region color. 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
SearchAndAddRedactionRegions Method (GdPicturePDF)
In This Topic
Searches for all occurrences of a given regular expression pattern within the currently loaded PDF document and adds redaction region for every occurrence found.
Syntax
'Declaration
 
Public Function SearchAndAddRedactionRegions( _
   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 SearchAndAddRedactionRegions( 
   string Pattern,
   bool CaseSensitive,
   byte Red,
   byte Green,
   byte Blue,
   byte Alpha,
   ref int Occurrences
)
public function SearchAndAddRedactionRegions( 
    Pattern: String;
    CaseSensitive: Boolean;
    Red: Byte;
    Green: Byte;
    Blue: Byte;
    Alpha: Byte;
   var  Occurrences: Integer
): GdPictureStatus; 
public function SearchAndAddRedactionRegions( 
   Pattern : String,
   CaseSensitive : boolean,
   Red : byte,
   Green : byte,
   Blue : byte,
   Alpha : byte,
   Occurrences : int
) : GdPictureStatus;
public: GdPictureStatus SearchAndAddRedactionRegions( 
   string* Pattern,
   bool CaseSensitive,
   byte Red,
   byte Green,
   byte Blue,
   byte Alpha,
   ref int Occurrences
) 
public:
GdPictureStatus SearchAndAddRedactionRegions( 
   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 resulting region color. Use the value between 0 and 255.
Green
The amount of green color to be used for the resulting region color. Use the value between 0 and 255.
Blue
The amount of blue color to be used for the resulting region color. Use the value between 0 and 255.
Alpha
The transparency value of the resulting region color. 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 redact all occurrences of text string in PDF document.
Using gdpicturePDF As New GdPicturePDF
   gdpicturePDF.LoadFromFile("input.pdf")
   Dim occurrences As Integer = 0
   gdpicturePDF.SearchAndAddRedactionRegions("Sensitive text string", True, 0, 0, 0, 255, occurrences)
   If occurrences > 0 Then
       gdpicturePDF.ApplyRedaction()
   End If
   gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
    gdpicturePDF.LoadFromFile("input.pdf");
    int occurrences = 0;
    gdpicturePDF.SearchAndAddRedactionRegions("Sensitive text string", true, 0, 0, 0, 255, ref occurrences);
    if (occurrences > 0)
    {
        gdpicturePDF.ApplyRedaction();
    }
    gdpicturePDF.SaveToFile("output.pdf");
}
See Also