Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I added a watermark on PDF using Pdfstamper. Here is the code:
C#
for (int pageIndex = 1; pageIndex <= pageCount; pageIndex++)
{
 iTextSharp.text.Rectangle pageRectangle = reader.GetPageSizeWithRotation(pageIndex);
 PdfContentByte pdfData = stamper.GetUnderContent(pageIndex);
 pdfData.SetFontAndSize(BaseFont.CreateFont(BaseFont.HELVETICA  BaseFont.CP1252  
 BaseFont.NOT_EMBEDDED)  watermarkFontSize);
 PdfGState graphicsState = new PdfGState();
 graphicsState.FillOpacity = watermarkFontOpacity;
 pdfData.SetGState(graphicsState);
 pdfData.SetColorFill(iTextSharp.text.BaseColor.BLACK);
 pdfData.BeginText();
 pdfData.ShowTextAligned(PdfContentByte.ALIGN_CENTER  "LipikaChatterjee"  
 pageRectangle.Width / 2  pageRectangle.Height / 2  watermarkRotation);
 pdfData.EndText();
}
This works fine.
Now I want to remove this watermark from my PDF. I looked into iTextSharp but was not able to get any help. I even tried to add watermark as layer and then delete the layer but was not able to delete the content of layer from the PDF.
I looked into iText for layer removal and found a class OCGRemover but I was not able to get an equivalent class in iTextsharp.
Posted
Updated 3-Aug-13 22:26pm
v3

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900