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
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
// For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-.NET
using (Document doc = Document.Load(Utilities.MapSourceFilePath(DocFilePath)))
{
TextFormattingSearchCriteria criteria = 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();
' For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-.NET
Using doc As WordsDocument = Document.Load(Of WordsDocument)(Utilities.MapSourceFilePath(FilePath))
For Each section As WordsSection In doc.Sections
For i As Object = section.Shapes.Count - 1 To 0 Step -1
For Each fragment As Object In section.Shapes(i).FormattedTextFragments
If fragment.ForegroundColor = Color.Red AndAlso fragment.Font.FamilyName = "Arial" Then
section.Shapes.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 (WordsDocument doc = Document.Load<WordsDocument>(Utilities.MapSourceFilePath(FilePath)))
{
foreach (WordsSection section in doc.Sections)
{
for (var i = section.Shapes.Count - 1; i >= 0; i--)
{
foreach (var fragment in section.Shapes[i].FormattedTextFragments)
{
if (fragment.ForegroundColor == Color.Red && fragment.Font.FamilyName == "Arial")
' For complete examples and data files, please go to https://github.com/groupdocs-watermark/GroupDocs.Watermark-for-.NET
Using doc As DiagramDocument = Document.Load(Of DiagramDocument)(Utilities.MapSourceFilePath(FilePath))
For Each page As DiagramPage In doc.Pages
For i As Object = page.Shapes.Count - 1 To 0 Step -1
For Each fragment As Object In page.Shapes(i).FormattedTextFragments
If fragment.ForegroundColor = Color.Red AndAlso fragment.Font.FamilyName = "Arial" Then
page.Shapes.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 (DiagramDocument doc = Document.Load<DiagramDocument>(Utilities.MapSourceFilePath(FilePath)))
{
foreach (DiagramPage page in doc.Pages)
{
for (var i = page.Shapes.Count - 1; i >= 0; i--)
{
foreach (var fragment in page.Shapes[i].FormattedTextFragments)
{
if (fragment.ForegroundColor == Color.Red && fragment.Font.FamilyName == "Arial")