I want to programatically redact a PDF file using my C# code. I know that it is hard. Is it possible using itextsharp ? or what is the alternative.
As the OP clarified in comments to the Question:
the marked/removed text should not appear in print / view of the pdf
Thus, here a simple solution which is merely painting a black rectangle over the text. The text beneath won't appear in print and wont be immediately visible in a PDF viewer. But it will be there, still, and can be extracted e.g. by copy & paste.
Furthermore, as I am more at home with Java, I provide code in Java for iText. It should be easy to port to iTextSharp, though, replacing getX by GetX or X, setX by SetX or X, and method() by Method() and using some .Net stream instead of the FileOutputStream:
PdfReader reader = new PdfReader("source.pdf");
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("target.pdf"));
PdfContentByte content = stamper.getOverContent(1);
content.setColorFill(BaseColor.BLACK);
// Do this for every rectangle given as x, y, width, heigth
content.rectangle(100f, 600f, 200f, 100f);
// Done
content.fill();
stamper.close();
reader.close();
Redaction capabilities have recently been added to iTextSharp 5.5.5. See also this thread and change log