A watermark is a superimposed image or text used to display in documents for various purposes. Sometimes, you may need to replace or edit the inserted watermark with a new text or image. This article will be focusing on how to find and replace watermark text or images using a REST API.

The following topics shall be covered in this article:

Watermark REST API and .NET SDK

GroupDocs.Watermark Cloud Product Family

For search and replace watermark, I will be using the .NET SDK of GroupDocs.Watermark Cloud API. It allows you to programmatically add, remove, search and replace watermarks from images and documents of supported formats. Currently, it also provides Java SDK as well for the Cloud API.

The GroupDocs.Watermark Cloud SDK for .NET can be installed to your Visual Studio project from the NuGet Package manager as shown below:

Find and Replace Watermark using a Rest API

You may also install the NuGet Package using the following command in the Package Manager console:

Install-Package GroupDocs.Watermark-Cloud

Please get your Client ID and Client Secret from the dashboard before you start following the steps and available code examples. Add your ID and Secret in the code as demonstrated below:

Find and Replace Text Watermark using a REST API

You can find and replace watermark text from your PDF documents by following the simple steps mentioned below:

Upload the PDF Document

First of all, upload the PDF document containing the watermark to the Cloud using any of the following methods:

  • Using the dashboard
  • Upload the file using Upload File API from the browser
  • Upload programmatically using the code example given below:

As the result, the PDF file will be uploaded to Cloud Storage and will be available in the files section of your dashboard.

Find and Replace Text Watermark

The following code snippet shows how to find and replace a text watermark from an uploaded PDF file using a REST API.

Find and Replace Text Watermark using REST API

You may also set font, text size, foreground and background colors for the watermark text using the following code sample:

Download the Updated File

The above code samples will save the PDF file with a new watermark text or image on the cloud. You can download it using the following code sample:

Find and Replace Watermark Image using a REST API

The simple code example given below demonstrates how to find and replace the watermark image using a REST API. Please follow the steps mentioned earlier to upload and download a file.

Find and Replace Watermark Image using REST API

Conclusion

In conclusion, you have learned how to search and replace the text or image watermark from a PDF document on the cloud with .NET Watermark REST API using C#. Moreover, you also learned how to programmatically upload the files on the cloud and then download them from the cloud. Furthermore, you can learn various other useful features of GroupDocs.Watermark Cloud API from the documentation. In case of any ambiguity, feel free to contact support.

See Also