Skip to content

Instantly share code, notes, and snippets.

' For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-.NET
Using doc = Document.Load(Utilities.MapSourceFilePath(DocFilePath))
' Search for hyperlinks only.
doc.SearchableObjects.PdfSearchableObjects = PdfSearchableObjects.Hyperlinks
' The code for working with found watermarks goes here.
Dim watermarks = doc.FindWatermarks()
End Using
// For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-.NET
using (var doc = Document.Load(Utilities.MapSourceFilePath(DocFilePath)))
{
// Search for hyperlinks only.
doc.SearchableObjects.PdfSearchableObjects = PdfSearchableObjects.Hyperlinks;
var watermarks = doc.FindWatermarks();
// The code for working with found watermarks goes here.
}
' For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-.NET
Document.DefaultSearchableObjects = New SearchableObjects() With { _
.WordsSearchableObjects = WordsSearchableObjects.Hyperlinks Or WordsSearchableObjects.Text, _
.CellsSearchableObjects = CellsSearchableObjects.HeadersFooters, _
.SlidesSearchableObjects = SlidesSearchableObjects.SlidesBackgrounds Or SlidesSearchableObjects.Shapes, _
.DiagramSearchableObjects = DiagramSearchableObjects.None, _
.PdfSearchableObjects = PdfSearchableObjects.All _
}
For Each file As Object In Directory.GetFiles("D:\files")
// For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-.NET
Document.DefaultSearchableObjects = new SearchableObjects
{
WordsSearchableObjects = WordsSearchableObjects.Hyperlinks | WordsSearchableObjects.Text,
CellsSearchableObjects = CellsSearchableObjects.HeadersFooters,
SlidesSearchableObjects = SlidesSearchableObjects.SlidesBackgrounds | SlidesSearchableObjects.Shapes,
DiagramSearchableObjects = DiagramSearchableObjects.None,
PdfSearchableObjects = PdfSearchableObjects.All
};
' For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-.NET
Dim publicKey As String = "[Your Dynabic.Metered public key]"
Dim privateKey As String = "[Your Dynabic.Metered private key]"
Dim metered As New Metered()
metered.SetMeteredKey(publicKey, privateKey)
' Use the library in licensed mode
// For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-.NET
string publicKey = "[Your Dynabic.Metered public key]";
string privateKey = "[Your Dynabic.Metered private key]";
Metered metered = new Metered();
metered.SetMeteredKey(publicKey, privateKey);
// Use the library in licensed mode
// For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-.NET
using (PdfDocument doc = Document.Load<PdfDocument>(Utilities.MapSourceFilePath(FilePath)))
{
foreach (PdfPage page in doc.Pages)
{
for (var i = page.XObjects.Count - 1; i >= 0; i--)
{
foreach (var fragment in page.XObjects[i].FormattedTextFragments)
{
if (fragment.ForegroundColor == Color.Red)
' For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-.NET
Using doc As PdfDocument = Document.Load(Of PdfDocument)(Utilities.MapSourceFilePath(FilePath))
For Each page As PdfPage In doc.Pages
For i As Object = page.XObjects.Count - 1 To 0 Step -1
For Each fragment As Object In page.XObjects(i).FormattedTextFragments
If fragment.ForegroundColor = Color.Red Then
page.XObjects.RemoveAt(i)
Exit For
End If
Next
// For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-.NET
using (PdfDocument doc = Document.Load<PdfDocument>(Utilities.MapSourceFilePath(FilePath)))
{
foreach (PdfPage page in doc.Pages)
{
for (var i = page.XObjects.Count - 1; i >= 0; i--)
{
foreach (var fragment in page.XObjects[i].FormattedTextFragments)
{
if (fragment.ForegroundColor == Color.Red)
' For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-.NET
Using doc As Document = Document.Load(Utilities.MapSourceFilePath(DocFilePath))
Dim criteria As New TextFormattingSearchCriteria()
criteria.ForegroundColorRange = New ColorRange()
criteria.ForegroundColorRange.MinHue = -5
criteria.ForegroundColorRange.MaxHue = 10
criteria.ForegroundColorRange.MinBrightness = 0.01F
criteria.ForegroundColorRange.MaxBrightness = 0.99F
criteria.BackgroundColorRange = New ColorRange()
criteria.BackgroundColorRange.IsEmpty = True