use of com.itextpdf.commons.actions.confirmations.ConfirmEvent in project i7j-pdfsweep by itext.
the class CleanupLicenseEventsTest method cleanUpRedactAnnotationsWithAdditionalLocationSendsCoreAndCleanUpEventTest.
@Test
public void cleanUpRedactAnnotationsWithAdditionalLocationSendsCoreAndCleanUpEventTest() 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 = new ArrayList<PdfCleanUpLocation>();
PdfCleanUpLocation lineLoc = new PdfCleanUpLocation(1, new Rectangle(100, 560, 200, 30), ColorConstants.GREEN);
cleanUpLocations.add(lineLoc);
PdfCleaner.cleanUpRedactAnnotations(document, cleanUpLocations);
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());
}
}
use of com.itextpdf.commons.actions.confirmations.ConfirmEvent in project i7j-pdfsweep by itext.
the class CleanupLicenseEventsTest method cleanUpRedactAnnotationsWithSteamPramsSendsCleanUpEventTest.
@Test
public void cleanUpRedactAnnotationsWithSteamPramsSendsCleanUpEventTest() throws Exception {
InputStream inputStream = new FileInputStream(INPUT_PATH + "absentICentry.pdf");
OutputStream outputStream = new FileOutputStream(OUTPUT_PATH + "cleanUpRedactAnnotationsWithSteamPramsSendsCleanUpEventTest.pdf");
List<PdfCleanUpLocation> cleanUpLocations = new ArrayList<PdfCleanUpLocation>();
PdfCleanUpLocation lineLoc = new PdfCleanUpLocation(1, new Rectangle(100, 560, 200, 30), ColorConstants.GREEN);
cleanUpLocations.add(lineLoc);
PdfCleaner.cleanUpRedactAnnotations(inputStream, outputStream, cleanUpLocations);
List<ConfirmEvent> events = handler.getEvents();
Assert.assertEquals(1, events.size());
Assert.assertEquals(PdfSweepProductEvent.CLEANUP_PDF, events.get(0).getEvent().getEventType());
}
use of com.itextpdf.commons.actions.confirmations.ConfirmEvent in project i7j-pdfsweep by itext.
the class CleanupLicenseEventsTest method cleanUpRedactAnnotationsSendsCoreAndCleanUpEventTest.
@Test
public void cleanUpRedactAnnotationsSendsCoreAndCleanUpEventTest() 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 = new ArrayList<PdfCleanUpLocation>();
PdfCleanUpLocation lineLoc = new PdfCleanUpLocation(1, new Rectangle(100, 560, 200, 30), ColorConstants.GREEN);
cleanUpLocations.add(lineLoc);
PdfCleaner.cleanUpRedactAnnotations(document, 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());
}
}
use of com.itextpdf.commons.actions.confirmations.ConfirmEvent in project i7j-pdfsweep by itext.
the class CleanupLicenseEventsTest method autoSweepCleanUpSendsCoreAndCleanUpEventsTest.
@Test
public void autoSweepCleanUpSendsCoreAndCleanUpEventsTest() throws Exception {
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"));
PdfCleaner.autoSweepCleanUp(document, strategy);
String oldProducer = document.getDocumentInfo().getProducer();
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());
}
}
use of com.itextpdf.commons.actions.confirmations.ConfirmEvent in project i7j-pdfsweep by itext.
the class CleanupLicenseEventsTest method autoCleanWithStreamParamsSendsCleanUpEventTest.
@Test
public void autoCleanWithStreamParamsSendsCleanUpEventTest() throws Exception {
String input = INPUT_PATH + "fontCleanup.pdf";
String output = OUTPUT_PATH + "autoCleanWithStreamParamsSendsCleanUpEventTest.pdf";
CompositeCleanupStrategy strategy = new CompositeCleanupStrategy();
strategy.add(new RegexBasedCleanupStrategy("leonard"));
PdfCleaner.autoSweepCleanUp(new FileInputStream(input), new FileOutputStream(output), strategy);
List<ConfirmEvent> events = handler.getEvents();
Assert.assertEquals(1, events.size());
Assert.assertEquals(PdfSweepProductEvent.CLEANUP_PDF, events.get(0).getEvent().getEventType());
try (PdfDocument outDoc = new PdfDocument(new PdfReader(output));
PdfDocument inputDoc = new PdfDocument(new PdfReader(input))) {
String expectedProdLine = createExpectedProducerLine(new ConfirmedEventWrapper[] { getCleanUpEvent() }, inputDoc.getDocumentInfo().getProducer());
Assert.assertEquals(expectedProdLine, outDoc.getDocumentInfo().getProducer());
}
}
Aggregations