This short guide describes how to remove watermark from PDF using C#. It contains all the resources required to establish the environment, a step-by-step procedure to write the application, and a runnable sample code to remove watermark text from PDF using C#. You will also learn to work with different types of artifacts on a page and filter the artifacts of the required types.
Steps to Delete Watermark from PDF using C#
- Establish the environment to add Aspose.PDF for .NET into your project to remove the watermark
- Load the source PDF file into the Document class object to delete the watermark
- Parse through all the artifacts on each page of the document and create a list of watermark-type artifacts
- Once the list is populated with the desired artifacts, delete all the watermarks
- Save the resultant PDF file after removing the watermarks
These steps explain the procedure to remove watermark from PDF document using C# by identifying the important resources, classes, methods, and properties required while writing this application. During the process, the source PDF file is loaded into the Document class object, and then all of its pages are parsed. For each page, its artifacts are checked for the type watermark and saved in a list for removal at the end.
Code to Remove Watermark from PDF using C#
This code demonstrates the process to write a water mark remover in PDF using C#. It uses the Page.Artifacts collection to identify the Watermark type artifacts by comparing the Subtype property with the enumerator value Artifact.ArtifactSubtype.Watermark. Once all the watermark artifacts are collected in a list, this list is parsed and respective watermarks are deleted from each page separately.
This quick tutorial has guided us to erase watermark from PDF using C#. If you want to learn the process to add a watermark, refer to the article on how to add watermark to PDF in C#.