I have been using iTextsharp to insert watermark in to a pdf & remove them. Thanks for the original posts:
Removing Watermark from a PDF using iTextSharp
Create/Read Advance PDF Report using iTextSharp in C# .NET: Part I
I am able to add the watermark successfully as described in the above posts , however removing the watermark doesn't seem to work correctly. Below is the code block that actually removes the watermark from the PRStream.
if (content.IndexOf("/OC") >= 0 && content.IndexOf(watermarkText) >= 0) {
//Remove it by giving it zero length and zero data
stream.Put(PdfName.LENGTH, new PdfNumber(0));
stream.SetData(new byte[0]);
}
In my case, I have 8 pages with in the PDF with watermarks I've just added the above code to remove, which is being executed but the PdfReader is not getting updated in the PRStream.
Has anyone successfully removed a watermark layer using iTextSharp?