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()); } }
public virtual void CleanUpWithStreamArgumentsSendsCleanUpEventTest() { 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)); cleanUpLocations.Add(lineLoc); String @in = INPUT_PATH + "page229.pdf"; String @out = OUTPUT_PATH + "cleanUpWithStreamArgumentTest.pdf"; Stream file = new FileStream(@in, FileMode.Open, FileAccess.Read); Stream output = new FileStream(@out, FileMode.Create); PdfCleaner.CleanUp(file, output, cleanUpLocations, new CleanUpProperties()); 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()); } } }
public virtual void CleanTextAnnotation01() { String input = inputPath + "cleanAnnotation.pdf"; String output = outputPath + "cleanAnnotation_Text01.pdf"; String cmp = inputPath + "cmp_cleanAnnotation_Text01.pdf"; IList <iText.PdfCleanup.PdfCleanUpLocation> cleanUpLocations = new List <iText.PdfCleanup.PdfCleanUpLocation >(); iText.PdfCleanup.PdfCleanUpLocation textLoc = new iText.PdfCleanup.PdfCleanUpLocation(1, new Rectangle(150 , 650, 0, 0), ColorConstants.RED); cleanUpLocations.Add(textLoc); CleanUp(input, output, cleanUpLocations); CompareByContent(cmp, output, outputPath, "diff_Annotation_text01"); }
public virtual void CleanLinkAnnotation01() { String input = inputPath + "cleanAnnotation.pdf"; String output = outputPath + "cleanAnnotation_Link01.pdf"; String cmp = inputPath + "cmp_cleanAnnotation_Link01.pdf"; IList <iText.PdfCleanup.PdfCleanUpLocation> cleanUpLocations = new List <iText.PdfCleanup.PdfCleanUpLocation >(); iText.PdfCleanup.PdfCleanUpLocation linkLoc = new iText.PdfCleanup.PdfCleanUpLocation(1, new Rectangle(235 , 740, 30, 16), ColorConstants.BLUE); cleanUpLocations.Add(linkLoc); CleanUp(input, output, cleanUpLocations); CompareByContent(cmp, output, outputPath, "diff_Annotation_link01"); }
public virtual void CleanFormAnnotations02() { String input = inputPath + "formAnnotation.pdf"; String output = outputPath + "formAnnotation02.pdf"; String cmp = inputPath + "cmp_formAnnotation02.pdf"; IList <iText.PdfCleanup.PdfCleanUpLocation> cleanUpLocations = new List <iText.PdfCleanup.PdfCleanUpLocation >(); iText.PdfCleanup.PdfCleanUpLocation highLightLoc = new iText.PdfCleanup.PdfCleanUpLocation(1, new Rectangle (20, 600, 300, 100), ColorConstants.YELLOW); cleanUpLocations.Add(highLightLoc); CleanUp(input, output, cleanUpLocations); CompareByContent(cmp, output, outputPath, "diff_form02"); }
public virtual void CleanHighlightAnnotation01() { String input = inputPath + "cleanAnnotation.pdf"; String output = outputPath + "cleanAnnotation_highlight01.pdf"; String cmp = inputPath + "cmp_cleanAnnotation_highlight01.pdf"; IList <iText.PdfCleanup.PdfCleanUpLocation> cleanUpLocations = new List <iText.PdfCleanup.PdfCleanUpLocation >(); iText.PdfCleanup.PdfCleanUpLocation highLightLoc = new iText.PdfCleanup.PdfCleanUpLocation(1, new Rectangle (105, 500, 70, 10), ColorConstants.BLACK); cleanUpLocations.Add(highLightLoc); CleanUp(input, output, cleanUpLocations); CompareByContent(cmp, output, outputPath, "diff_text_highlight01"); }
public virtual void CleanLineAnnotation02() { String input = inputPath + "lineAnnotationLeaders.pdf"; String output = outputPath + "cleanLineAnnotation02.pdf"; String cmp = inputPath + "cmp_cleanLineAnnotation02.pdf"; 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); CleanUp(input, output, cleanUpLocations); CompareByContent(cmp, output, outputPath); }
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()); }