public virtual void CleanUpRedactAnnotationsWithAdditionalLocationSendsCoreAndCleanUpEventTest()
        {
            ByteArrayOutputStream baos     = new ByteArrayOutputStream();
            PdfDocument           document = new PdfDocument(new PdfReader(INPUT_PATH + "absentICentry.pdf"), new PdfWriter(baos
                                                                                                                            ));
            String oldProducer = document.GetDocumentInfo().GetProducer();
            IList <iText.PdfCleanup.PdfCleanUpLocation> cleanUpLocations = new List <iText.PdfCleanup.PdfCleanUpLocation
                                                                                     >();

            iText.PdfCleanup.PdfCleanUpLocation lineLoc = new iText.PdfCleanup.PdfCleanUpLocation(1, new Rectangle(100
                                                                                                                   , 560, 200, 30), ColorConstants.GREEN);
            cleanUpLocations.Add(lineLoc);
            PdfCleaner.CleanUpRedactAnnotations(document, cleanUpLocations);
            document.Close();
            IList <ConfirmEvent> events = handler.GetEvents();

            NUnit.Framework.Assert.AreEqual(2, events.Count);
            NUnit.Framework.Assert.AreEqual(ITextCoreProductEvent.PROCESS_PDF, events[0].GetEvent().GetEventType());
            NUnit.Framework.Assert.AreEqual(PdfSweepProductEvent.CLEANUP_PDF, events[1].GetEvent().GetEventType());
            using (PdfDocument pdfDocument = new PdfDocument(new PdfReader(new MemoryStream(baos.ToArray())))) {
                String expectedProdLine = CreateExpectedProducerLine(new ConfirmedEventWrapper[] { GetCoreEvent(), GetCleanUpEvent
                                                                                                       () }, oldProducer);
                NUnit.Framework.Assert.AreEqual(expectedProdLine, pdfDocument.GetDocumentInfo().GetProducer());
            }
        }
        private void CleanUp(String input, String output, IList <iText.PdfCleanup.PdfCleanUpLocation> cleanUpLocations
                             )
        {
            PdfDocument pdfDocument = new PdfDocument(new PdfReader(input), new PdfWriter(output));

            if (cleanUpLocations == null)
            {
                PdfCleaner.CleanUpRedactAnnotations(pdfDocument);
            }
            else
            {
                PdfCleaner.CleanUp(pdfDocument, cleanUpLocations);
            }
            pdfDocument.Close();
        }
        public virtual void CleanUpRedactAnnotationsWithSteamPramsSendsCleanUpEventTest()
        {
            Stream inputStream  = new FileStream(INPUT_PATH + "absentICentry.pdf", FileMode.Open, FileAccess.Read);
            Stream outputStream = new FileStream(OUTPUT_PATH + "cleanUpRedactAnnotationsWithSteamPramsSendsCleanUpEventTest.pdf"
                                                 , FileMode.Create);
            IList <iText.PdfCleanup.PdfCleanUpLocation> cleanUpLocations = new List <iText.PdfCleanup.PdfCleanUpLocation
                                                                                     >();

            iText.PdfCleanup.PdfCleanUpLocation lineLoc = new iText.PdfCleanup.PdfCleanUpLocation(1, new Rectangle(100
                                                                                                                   , 560, 200, 30), ColorConstants.GREEN);
            cleanUpLocations.Add(lineLoc);
            PdfCleaner.CleanUpRedactAnnotations(inputStream, outputStream, cleanUpLocations);
            IList <ConfirmEvent> events = handler.GetEvents();

            NUnit.Framework.Assert.AreEqual(1, events.Count);
            NUnit.Framework.Assert.AreEqual(PdfSweepProductEvent.CLEANUP_PDF, events[0].GetEvent().GetEventType());
        }
        public virtual void CleanUpRedactAnnotationsWithStreamArgumentsSendsCleanUpEventTest()
        {
            String @in    = INPUT_PATH + "absentICentry.pdf";
            String @out   = OUTPUT_PATH + "cleanUpRedactAnnotationsWithStreamArgumentTest.pdf";
            Stream file   = new FileStream(@in, FileMode.Open, FileAccess.Read);
            Stream output = new FileStream(@out, FileMode.Create);

            PdfCleaner.CleanUpRedactAnnotations(file, output);
            IList <ConfirmEvent> events = handler.GetEvents();

            NUnit.Framework.Assert.AreEqual(1, events.Count);
            NUnit.Framework.Assert.AreEqual(PdfSweepProductEvent.CLEANUP_PDF, events[0].GetEvent().GetEventType());
            using (PdfDocument pdfDocument = new PdfDocument(new PdfReader(@out))) {
                using (PdfDocument inputDoc = new PdfDocument(new PdfReader(@in))) {
                    String expectedProdLine = CreateExpectedProducerLine(new ConfirmedEventWrapper[] { GetCleanUpEvent() }, inputDoc
                                                                         .GetDocumentInfo().GetProducer());
                    NUnit.Framework.Assert.AreEqual(expectedProdLine, pdfDocument.GetDocumentInfo().GetProducer());
                }
            }
        }