Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GroupDocsGists/bd422900b30288898658b381f14c5628 to your computer and use it in GitHub Desktop.
Save GroupDocsGists/bd422900b30288898658b381f14c5628 to your computer and use it in GitHub Desktop.
// 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)
{
page.XObjects.RemoveAt(i);
break;
}
}
}
}
doc.Save();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment