Browse our Products

If so you can download any of the below versions for testing. The product will function as normal except for an evaluation limitation. At the time of purchase we provide a license file via email that will allow the product to work in its full capacity. If you would also like an evaluation license to test without any restrictions for 30 days, please follow the directions provided here.

 

GroupDocs.Watermark for .NET 23.7

Download   Support Forum 

File Details

  • Downloads:
  • 1
  • File Size:
  • 133.82MB
  • Date Added:
  • 4/7/2023

Description

This contains the MSI installer of GroupDocs.Watermark for .NET

File Details

Improved Watermark Removal Handling in API

It was observed that in some cases the watermark was not being removed from a document. So this release offers a fix to that issue. Now your C#, .NET Apps can easily earse watermarks with using Watermark API.

Complete Watermark Remover C# Code Example using API

The following example demonstrates that now you can remove requried watermarks from a PDF document using the GroupDocs.Watermark API.

string inputFilePath = "Input.pdf";
string outputFilePath = "Output.pdf";

using (Watermarker watermarker = new Watermarker(File.OpenRead(path)))
{
    var pdfContent = watermarker.GetContent<PdfContent>();
    var searchCriteria = new VectorSearchCriteria();
    var watermarkColor = ColorTranslator.FromHtml("#a9aaae");
    var fromSystemColor = GroupDocs.Watermark.Watermarks.Color.FromArgb(watermarkColor.A, watermarkColor.R, 
    	watermarkColor.G, watermarkColor.B);

    var criteriaVectorColorRange = new ColorRange(fromSystemColor)
    {
        MinBrightness = 0.1f,
        MaxBrightness = 0.7f
    };

    searchCriteria.VectorColorRange = criteriaVectorColorRange;

    var possibleWatermarkCollection = pdfContent.Search(searchCriteria);
                
    possibleWatermarkCollection.Clear();

    watermarker.Save(outputFilePath);
}

Source

Summary of Watermak Removal Code Steps

1. Load the PDF file into the Watermarker object. This is done by passing the file path to the constructor of the Watermarker class.

2. Get the PDF content as a PdfContent object. This is done using the GetContent() method.

3. Create a VectorSearchCriteria object. This object is used to specify the criteria for searching for watermarks. In this case, we are searching for watermarks that have a color similar to the specified color.

4. Set the VectorColorRange property of the VectorSearchCriteria object. This property specifies the range of colors that the watermark can have. In this case, we are specifying a range of colors that are similar to the specified color.

5. Search for watermarks in the PDF content using the Search() method. This method returns a collection of PossibleWatermark objects, which represent the watermarks that were found.

6. Clear the PossibleWatermark collection. This will remove all of the watermarks from the PDF.

7. Save the PDF file using the Save() method. This will create a new PDF file without the watermarks.

Steps to programmatically search and remove watermarks using C#

Here is a more detailed explanation of each line of code:

The following two lines declare the variables that will be used to store the paths to the input and output PDF files.

string inputFilePath = "Input.pdf";
string outputFilePath = "Output.pdf";

Then we cerate a new Watermarker object and open the input PDF file. The Watermarker class is a part of the GroupDocs.Watermark API.

using (Watermarker watermarker = new Watermarker(File.OpenRead(path)))

Gets the PDF content as a PdfContent object. The PdfContent class represents the content of a PDF file.

var pdfContent = watermarker.GetContent<PdfContent>();

Create a new VectorSearchCriteria object. The VectorSearchCriteria class is used to specify the criteria for searching for watermarks.

var searchCriteria = new VectorSearchCriteria();

Get a Color object that represents the specified color. The ColorTranslator class is used to convert between different color formats.

var watermarkColor = ColorTranslator.FromHtml("#a9aaae");

Converts the Color object to a GroupDocs.Watermark.Watermarks.Color object. The GroupDocs.Watermark.Watermarks.Color class represents a color in the GroupDocs.Watermark API.

var fromSystemColor = GroupDocs.Watermark.Watermarks.Color.FromArgb(watermarkColor.A, watermarkColor.R, 
  watermarkColor.G, watermarkColor.B);

Create a new ColorRange object and set its properties. The ColorRange class represents a range of colors. In this case, we are specifying a range of colors that are similar to the specified color.

var criteriaVectorColorRange = new ColorRange(fromSystemColor)
{
  MinBrightness = 0.1f,
  MaxBrightness = 0.7f
};

Set the VectorColorRange property of the VectorSearchCriteria object to the criteriaVectorColorRange object.

searchCriteria.VectorColorRange = criteriaVectorColorRange;

Now search for watermarks in the PDF content using the VectorSearchCriteria object. The Search() method returns a collection of PossibleWatermark objects, which represent the watermarks that were found.

var possibleWatermarkCollection = pdfContent.Search(searchCriteria);

Clear the PossibleWatermark collection. This will remove all of the watermarks from the PDF.

possibleWatermarkCollection.Clear();

Lastly, saves the PDF file using the Save() method. This will create a new PDF file without the erased watermarks.

watermarker.Save(outputFilePath);

For a complete list of features, enhancements, and bug fixes in this release please visit, GroupDocs.Watermark for .NET 23.7.

 English