use of com.itextpdf.commons.actions.contexts.IMetaInfo in project i7j-pdfsweep by itext.
the class PdfCleaner method autoSweepCleanUp.
/**
* Perform cleanup of areas of interest based on a given cleanup strategy.
* Note, use methods with InputStream/OutputStream params if you don't want to consume itext-core product license
* limits.
*
* @param inputPdf the pdf document InputStream to which cleaned up applies
* @param outputPdf the cleaned up pdf document OutputStream
* @param strategy cleanup strategy to be used
* @param additionalCleanUpLocations list of additional locations to be cleaned up
* @param properties additional properties for cleanUp
*
* @throws IOException if an I/O error occurs
*/
public static void autoSweepCleanUp(InputStream inputPdf, OutputStream outputPdf, ICleanupStrategy strategy, List<PdfCleanUpLocation> additionalCleanUpLocations, CleanUpProperties properties) throws IOException {
StampingProperties stampingProperties = new StampingProperties();
IMetaInfo propertiesMetaInfo = properties.getMetaInfo();
stampingProperties.setEventCountingMetaInfo(propertiesMetaInfo == null ? new CleanUpToolMetaInfo() : propertiesMetaInfo);
try (PdfReader reader = new PdfReader(inputPdf);
PdfWriter writer = new PdfWriter(outputPdf);
PdfDocument pdfDocument = new PdfDocument(reader, writer, stampingProperties)) {
autoSweepCleanUp(pdfDocument, strategy, additionalCleanUpLocations, properties);
}
}
use of com.itextpdf.commons.actions.contexts.IMetaInfo in project i7j-pdfsweep by itext.
the class PdfCleaner method cleanUp.
/**
* Cleans the document by erasing all the areas which are provided.
* Note, use methods with InputStream/OutputStream params if you don't want to consume itext-core product license
* limits.
*
* @param inputPdf the pdf document InputStream to which cleaned up applies
* @param outputPdf the cleaned up pdf document OutputStream
* @param cleanUpLocations list of locations to be cleaned up
* @param properties additional properties for cleanUp
*
* @throws IOException if an I/O error occurs
*/
public static void cleanUp(InputStream inputPdf, OutputStream outputPdf, List<PdfCleanUpLocation> cleanUpLocations, CleanUpProperties properties) throws IOException {
StampingProperties stampingProperties = new StampingProperties();
IMetaInfo propertiesMetaInfo = properties.getMetaInfo();
stampingProperties.setEventCountingMetaInfo(propertiesMetaInfo == null ? new CleanUpToolMetaInfo() : propertiesMetaInfo);
try (PdfReader reader = new PdfReader(inputPdf);
PdfWriter writer = new PdfWriter(outputPdf);
PdfDocument pdfDocument = new PdfDocument(reader, writer, stampingProperties)) {
cleanUp(pdfDocument, cleanUpLocations, properties);
}
}
use of com.itextpdf.commons.actions.contexts.IMetaInfo in project i7j-pdfsweep by itext.
the class PdfCleaner method cleanUpRedactAnnotations.
/**
* Cleans the document by erasing regions defined by redact annotations inside the document.
* Note, use methods with InputStream/OutputStream params if you don't want to consume itext-core product license
* limits.
*
* @param inputPdf the pdf document InputStream to which cleaned up applies
* @param outputPdf the cleaned up pdf document OutputStream
* @param additionalCleanUpLocations list of locations to be cleaned up
* @param properties additional properties for cleanUp
*
* @throws IOException if an I/O error occurs
*/
public static void cleanUpRedactAnnotations(InputStream inputPdf, OutputStream outputPdf, List<PdfCleanUpLocation> additionalCleanUpLocations, CleanUpProperties properties) throws IOException {
StampingProperties stampingProperties = new StampingProperties();
IMetaInfo propertiesMetaInfo = properties.getMetaInfo();
stampingProperties.setEventCountingMetaInfo(propertiesMetaInfo == null ? new CleanUpToolMetaInfo() : propertiesMetaInfo);
try (PdfReader reader = new PdfReader(inputPdf);
PdfWriter writer = new PdfWriter(outputPdf);
PdfDocument pdfDocument = new PdfDocument(reader, writer, stampingProperties)) {
cleanUpRedactAnnotations(pdfDocument, additionalCleanUpLocations, properties);
}
}
Aggregations