com.groupdocs.watermark

Interfaces

Classes

Exceptions

com.groupdocs.watermark

Class TextSearchCriteria



  • public class TextSearchCriteria
    extends SearchCriteria

    Represents criteria allowing filtering by watermark text.

    This example demonstrates how to find and remove all possible watermarks containing a particular text from a document of any supported format.

    String inputFolder = "D:\\docs\\input\\";
     String outputFolder = "D:\\docs\\output\\";
     Pattern regex = Pattern.compile("CompanyName", Pattern.CASE_INSENSITIVE);
     TextSearchCriteria textSearchCriteria = new TextSearchCriteria(regex);
     File[] files = new File(inputFolder).listFiles();
     for (File file : files)
     {
         if (file.isFile())
         {
             Document doc = Document.load(file.getAbsolutePath());                   
             PossibleWatermarkCollection watermarks = doc.findWatermarks(textSearchCriteria);
             watermarks.clear();
             doc.save(outputFolder + file.getName()); 
         }
     }
     
    • Constructor Detail

      • TextSearchCriteria

        public TextSearchCriteria(Pattern pattern)

        Initializes a new instance of the TextSearchCriteria class.

        Parameters:
        pattern - The regular expression to match.
      • TextSearchCriteria

        public TextSearchCriteria(String searchString,
                          boolean isMatchCase)

        Initializes a new instance of the TextSearchCriteria class.

        Parameters:
        searchString - The exact string to search for.
        isMatchCase - True indicates case-sensitive comparison, false indicates case-insensitive comparison.
      • TextSearchCriteria

        public TextSearchCriteria(String searchString)

        Initializes a new instance of the TextSearchCriteria class.

        Parameters:
        searchString - The exact string to search for.
    • Method Detail

      • getPattern

        public final Pattern getPattern()

        Gets the search pattern.

        Returns:
        The regular expression pattern to match.