Watermarks are normally used to avoid any illegal use of confidential documents. When confidentiality is no more needed, you better remove the watermarks from such documents. There can be text and image-based watermarks in a document. Today, we will have a look at how to remove watermarks from PDF documents using C#.

Remove Watermark from PDF documents

.NET API to Remove PDF Watermarks

GroupDocs.Watermark showcases .NET API to deal with watermarks within documents and images of different file formats. If you are making a watermark removal app, It provides you some useful ways to:

  • Remove all watermarks from PDF
  • Delete watermarks with particular text formatting
  • Remove hyperlink watermarks

Let’s learn how a C# developer can remove watermarks from PDF using GroupDocs.Watermark for .NET API in different ways.

Remove All Watermarks from PDF document using C#

The API gives you the power to easily find and then remove a particular watermark and all the watermarks from a document. The following code removes all the watermarks from a PDF document using C#.

  • Load the PDF file using Watermarker.
  • Fetch all the possible watermarks as a collection using search.
  • Traverse the whole collection and remove every watermark or the one that meets your criterion.
  • Save the updated PDF with no more watermarks on it.

The following C# code removes all the watermarks from a PDF document.

Remove Watermark from PDF with particular Text Formatting using C#

Using API you can search and remove the watermarks on the basis of text formatting. You can provide a search criterion containing name, font, size, color, etc and the API will find the watermarks with matching properties. The following code snippet demonstrates how to search and remove watermarks from a PDF file with a specific text formatting using C#.

  • Load the PDF file using Watermarker.
  • Define the search criterion using TextFormattingSearchCriteria.
  • Mention all the required formatting properties.
  • Perform Search() and get all the possible watermarks as a collection by providing the defined criteria.
  • Remove all the searched watermarks using the Clear() method.
  • Save the updated PDF having no watermark with the defined properties.

The following C# code removes the watermarks in a PDF document having the specified text formatting.

The document watermarking .NET API allows you to search and remove hyperlinks in a document of any supported document format. The following steps allow removing hyperlink watermarks from a PDF document within the .NET application using C#.

  • Load the PDF file using Watermarker.
  • Fetch all the possible watermarks as a collection using search.
  • Traverse the whole collection and remove every watermark or the one that meets your criterion.
  • Save the updated PDF with no more watermarks on it.

The following C# code sample shows how to find and remove hyperlink watermarks with a particular URL from a PDF document.

Conclusion

To conclude, today we learned to remove different watermarks from the PDF documents using C#. I believe that you will now be more confident to build your own .NET application for finding and removing text watermarks as well as image watermarks from PDF documents. Additionally, you can add features of removing watermarks with specified formatting and hyperlink watermarks.

Besides, you can learn more about GroupDocs.Watermark for .NET from its documentation. For queries, contact us via the forum.

See Also