public virtual void TentativeCleanUpTest() { String input = INPUT_PATH + "Lipsum.pdf"; String output = OUTPUT_PATH + "tentativeCleanUp.pdf"; String cmp = INPUT_PATH + "cmp_tentativeCleanUp.pdf"; CompositeCleanupStrategy strategy = new CompositeCleanupStrategy(); strategy.Add(new RegexBasedCleanupStrategy("(D|d)olor").SetRedactionColor(ColorConstants.GREEN)); PdfDocument pdf = new PdfDocument(new PdfReader(input), new PdfWriter(output).SetCompressionLevel(0)); // sweep PdfAutoSweepTools autoSweep = new PdfAutoSweepTools(strategy); autoSweep.TentativeCleanUp(pdf); pdf.Close(); // compare CompareByContent(cmp, output, OUTPUT_PATH, "diff_tentativeCleanUp_"); }
public virtual void AutoSweepTentativeCleanUpSendsCoreEventTest() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfDocument document = new PdfDocument(new PdfReader(INPUT_PATH + "fontCleanup.pdf"), new PdfWriter(baos)); CompositeCleanupStrategy strategy = new CompositeCleanupStrategy(); strategy.Add(new RegexBasedCleanupStrategy("leonard")); PdfAutoSweepTools autoSweep = new PdfAutoSweepTools(strategy); autoSweep.TentativeCleanUp(document); String oldProducer = document.GetDocumentInfo().GetProducer(); document.Close(); IList <ConfirmEvent> events = handler.GetEvents(); NUnit.Framework.Assert.AreEqual(1, events.Count); NUnit.Framework.Assert.AreEqual(ITextCoreProductEvent.PROCESS_PDF, events[0].GetEvent().GetEventType()); using (PdfDocument pdfDocument = new PdfDocument(new PdfReader(new MemoryStream(baos.ToArray())))) { String expectedProdLine = CreateExpectedProducerLine(new ConfirmedEventWrapper[] { GetCoreEvent() }, oldProducer ); NUnit.Framework.Assert.AreEqual(expectedProdLine, pdfDocument.GetDocumentInfo().GetProducer()); } }