use of com.itextpdf.io.source.ByteArrayOutputStream in project i7j-pdfsweep by itext.
the class CleanupLicenseEventsTest method autoSweepHighlightSendsCoreEventsTest.
@Test
public void autoSweepHighlightSendsCoreEventsTest() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfDocument document = new PdfDocument(new PdfReader(INPUT_PATH + "fontCleanup.pdf"), new PdfWriter(baos));
String oldProducer = document.getDocumentInfo().getProducer();
CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();
strategy.add(new RegexBasedCleanupStrategy("leonard"));
PdfAutoSweepTools autoSweep = new PdfAutoSweepTools(strategy);
autoSweep.highlight(document);
document.close();
List<ConfirmEvent> events = handler.getEvents();
Assert.assertEquals(1, events.size());
Assert.assertEquals(ITextCoreProductEvent.PROCESS_PDF, events.get(0).getEvent().getEventType());
try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(new ByteArrayInputStream(baos.toByteArray())))) {
String expectedProdLine = createExpectedProducerLine(new ConfirmedEventWrapper[] { getCoreEvent() }, oldProducer);
Assert.assertEquals(expectedProdLine, pdfDocument.getDocumentInfo().getProducer());
}
}
use of com.itextpdf.io.source.ByteArrayOutputStream in project i7j-pdfsweep by itext.
the class CleanupLicenseEventsTest method cleanUpRedactAnnotationsWithNullLocationSendsCoreAndCleanUpEventTest.
@Test
public void cleanUpRedactAnnotationsWithNullLocationSendsCoreAndCleanUpEventTest() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfDocument document = new PdfDocument(new PdfReader(INPUT_PATH + "absentICentry.pdf"), new PdfWriter(baos));
String oldProducer = document.getDocumentInfo().getProducer();
List<PdfCleanUpLocation> cleanUpLocations = null;
PdfCleaner.cleanUpRedactAnnotations(document, cleanUpLocations, new CleanUpProperties());
document.close();
List<ConfirmEvent> events = handler.getEvents();
Assert.assertEquals(2, events.size());
Assert.assertEquals(ITextCoreProductEvent.PROCESS_PDF, events.get(0).getEvent().getEventType());
Assert.assertEquals(PdfSweepProductEvent.CLEANUP_PDF, events.get(1).getEvent().getEventType());
try (PdfDocument pdfDocument = new PdfDocument(new PdfReader(new ByteArrayInputStream(baos.toByteArray())))) {
String expectedProdLine = createExpectedProducerLine(new ConfirmedEventWrapper[] { getCoreEvent(), getCleanUpEvent() }, oldProducer);
Assert.assertEquals(expectedProdLine, pdfDocument.getDocumentInfo().getProducer());
}
}
Aggregations