I tried to use iTextSharp 5.5.9 to redact PDF files. The problem is when I redact a large rectangle field on a PDF, it can not save the file. This is the code:
PdfReader reader1 = new PdfReader(new FileStream(DesFile, FileMode.Open));
Stream fs = new FileStream(DesFile, FileMode.Open);
PdfStamper stamper = new PdfStamper(reader1, fs);
List<PdfCleanUpLocation> cleanUpLocations = new List<PdfCleanUpLocation>();
cleanUpLocations.Add(new PdfCleanUpLocation(1, new Rectangle(77f,77f,600f,600f), BaseColor.GRAY));
PdfCleanUpProcessor cleaner = new PdfCleanUpProcessor(cleanUpLocations, stamper);
cleaner.CleanUp();
stamper.Close();
reader1.Close();
I use the http://sox.sourceforge.net/sox.pdf to test, if I change the Rectangle to
new Rectangle(77f,77f,200f,200f)
It will work well... But when I change back the larger Rectangle:
new Rectangle(77f,77f,600f,600f)
It stops working. Please help!