Search in sources :

Example 1 with IMetaInfo

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);
    }
}
Also used : IMetaInfo(com.itextpdf.commons.actions.contexts.IMetaInfo) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) StampingProperties(com.itextpdf.kernel.pdf.StampingProperties) PdfReader(com.itextpdf.kernel.pdf.PdfReader) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument)

Example 2 with IMetaInfo

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);
    }
}
Also used : IMetaInfo(com.itextpdf.commons.actions.contexts.IMetaInfo) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) StampingProperties(com.itextpdf.kernel.pdf.StampingProperties) PdfReader(com.itextpdf.kernel.pdf.PdfReader) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument)

Example 3 with IMetaInfo

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);
    }
}
Also used : IMetaInfo(com.itextpdf.commons.actions.contexts.IMetaInfo) PdfWriter(com.itextpdf.kernel.pdf.PdfWriter) StampingProperties(com.itextpdf.kernel.pdf.StampingProperties) PdfReader(com.itextpdf.kernel.pdf.PdfReader) PdfDocument(com.itextpdf.kernel.pdf.PdfDocument)

Aggregations

IMetaInfo (com.itextpdf.commons.actions.contexts.IMetaInfo)3 PdfDocument (com.itextpdf.kernel.pdf.PdfDocument)3 PdfReader (com.itextpdf.kernel.pdf.PdfReader)3 PdfWriter (com.itextpdf.kernel.pdf.PdfWriter)3 StampingProperties (com.itextpdf.kernel.pdf.StampingProperties)3