Class PdfCleaner

java.lang.Object
com.itextpdf.pdfcleanup.PdfCleaner

public final class PdfCleaner extends Object
Main entry point for cleaning a PDF document. This class contains a series of static methods that accept PDF file as a InputStream or already opened PdfDocument and performs erasing of data in regions specified by input arguments. The output can either be preserved in passed PdfDocument with possibility to post-process the document, or in an OutputStream in a form of a complete PDF file.

The important difference between overloads with InputStream/OutputStream parameters and PdfDocument parameter is in the consumption of product license limits.

  • Method Details

    • cleanUp

      public static void cleanUp (InputStream inputPdf, OutputStream outputPdf, List<PdfCleanUpLocation> cleanUpLocations) throws IOException
      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.
      Parameters:
      inputPdf - the pdf document InputStream to which cleaned up applies
      outputPdf - the cleaned up pdf document OutputStream
      cleanUpLocations - list of locations to be cleaned up
      Throws:
      IOException - if an I/O error occurs
    • cleanUp

      public static void cleanUp (InputStream inputPdf, OutputStream outputPdf, List<PdfCleanUpLocation> cleanUpLocations, CleanUpProperties properties) throws IOException
      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.
      Parameters:
      inputPdf - the pdf document InputStream to which cleaned up applies
      outputPdf - the cleaned up pdf document OutputStream
      cleanUpLocations - list of locations to be cleaned up
      properties - additional properties for cleanUp
      Throws:
      IOException - if an I/O error occurs
    • cleanUp

      public static void cleanUp (com.itextpdf.kernel.pdf.PdfDocument pdfDocument, List<PdfCleanUpLocation> cleanUpLocations) throws IOException
      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.
      Parameters:
      pdfDocument - a document to which cleaned up applies
      cleanUpLocations - list of locations to be cleaned up
      Throws:
      IOException - if an I/O error occurs
    • cleanUp

      public static void cleanUp (com.itextpdf.kernel.pdf.PdfDocument pdfDocument, List<PdfCleanUpLocation> cleanUpLocations, CleanUpProperties properties) throws IOException
      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.
      Parameters:
      pdfDocument - a document to which cleaned up applies
      cleanUpLocations - list of locations to be cleaned up
      properties - additional properties for cleanUp
      Throws:
      IOException - if an I/O error occurs
    • autoSweepCleanUp

      public static void autoSweepCleanUp (InputStream inputPdf, OutputStream outputPdf, ICleanupStrategy strategy) throws IOException
      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.
      Parameters:
      inputPdf - the pdf document InputStream to which cleaned up applies
      outputPdf - the cleaned up pdf document OutputStream
      strategy - cleanup strategy to be used
      Throws:
      IOException - if an I/O error occurs
    • autoSweepCleanUp

      public static void autoSweepCleanUp (InputStream inputPdf, OutputStream outputPdf, ICleanupStrategy strategy, List<PdfCleanUpLocation> additionalCleanUpLocations) throws IOException
      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.
      Parameters:
      inputPdf - the pdf document InputStream to which cleaned up applies
      outputPdf - the cleaned up pdf document OutputStream
      strategy - cleanup strategy to be used
      additionalCleanUpLocations - list of additional locations to be cleaned up
      Throws:
      IOException - if an I/O error occurs
    • autoSweepCleanUp

      public static void autoSweepCleanUp (InputStream inputPdf, OutputStream outputPdf, ICleanupStrategy strategy, CleanUpProperties properties) throws IOException
      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.
      Parameters:
      inputPdf - the pdf document InputStream to which cleaned up applies
      outputPdf - the cleaned up pdf document OutputStream
      strategy - cleanup strategy to be used
      properties - additional properties for cleanUp
      Throws:
      IOException - if an I/O error occurs
    • autoSweepCleanUp

      public static void autoSweepCleanUp (InputStream inputPdf, OutputStream outputPdf, ICleanupStrategy strategy, List<PdfCleanUpLocation> additionalCleanUpLocations, CleanUpProperties properties) throws IOException
      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.
      Parameters:
      inputPdf - the pdf document InputStream to which cleaned up applies
      outputPdf - the cleaned up pdf document OutputStream
      strategy - cleanup strategy to be used
      additionalCleanUpLocations - list of additional locations to be cleaned up
      properties - additional properties for cleanUp
      Throws:
      IOException - if an I/O error occurs
    • autoSweepCleanUp

      public static void autoSweepCleanUp (com.itextpdf.kernel.pdf.PdfDocument pdfDocument, ICleanupStrategy strategy) throws IOException
      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.
      Parameters:
      pdfDocument - a document to which cleaned up applies
      strategy - cleanup strategy to be used
      Throws:
      IOException - if an I/O error occurs
    • autoSweepCleanUp

      public static void autoSweepCleanUp (com.itextpdf.kernel.pdf.PdfDocument pdfDocument, ICleanupStrategy strategy, CleanUpProperties properties) throws IOException
      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.
      Parameters:
      pdfDocument - a document to which cleaned up applies
      strategy - cleanup strategy to be used
      properties - additional properties for cleanUp
      Throws:
      IOException - if an I/O error occurs
    • autoSweepCleanUp

      public static void autoSweepCleanUp (com.itextpdf.kernel.pdf.PdfDocument pdfDocument, ICleanupStrategy strategy, List<PdfCleanUpLocation> additionalCleanUpLocations) throws IOException
      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.
      Parameters:
      pdfDocument - a document to which cleaned up applies
      strategy - cleanup strategy to be used
      additionalCleanUpLocations - list of additional locations to be cleaned up
      Throws:
      IOException - if an I/O error occurs
    • autoSweepCleanUp

      public static void autoSweepCleanUp (com.itextpdf.kernel.pdf.PdfDocument pdfDocument, ICleanupStrategy strategy, List<PdfCleanUpLocation> additionalCleanUpLocations, CleanUpProperties properties) throws IOException
      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.
      Parameters:
      pdfDocument - a document to which cleaned up applies
      strategy - cleanup strategy to be used
      additionalCleanUpLocations - list of additional locations to be cleaned up
      properties - additional properties for cleanUp
      Throws:
      IOException - if an I/O error occurs
    • autoSweepCleanUp

      public static void autoSweepCleanUp (com.itextpdf.kernel.pdf.PdfPage pdfPage, ICleanupStrategy strategy) throws IOException
      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.
      Parameters:
      pdfPage - the PdfPage to which cleaned up applies
      strategy - cleanup strategy to be used
      Throws:
      IOException - if an I/O error occurs
    • autoSweepCleanUp

      public static void autoSweepCleanUp (com.itextpdf.kernel.pdf.PdfPage pdfPage, ICleanupStrategy strategy, List<PdfCleanUpLocation> additionalCleanUpLocations) throws IOException
      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.
      Parameters:
      pdfPage - the PdfPage to which cleaned up applies
      strategy - cleanup strategy to be used
      additionalCleanUpLocations - list of additional locations to be cleaned up
      Throws:
      IOException - if an I/O error occurs
    • autoSweepCleanUp

      public static void autoSweepCleanUp (com.itextpdf.kernel.pdf.PdfPage pdfPage, ICleanupStrategy strategy, CleanUpProperties properties) throws IOException
      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.
      Parameters:
      pdfPage - the PdfPage to which cleaned up applies
      strategy - cleanup strategy to be used
      properties - additional properties for cleanUp
      Throws:
      IOException - if an I/O error occurs
    • autoSweepCleanUp

      public static void autoSweepCleanUp (com.itextpdf.kernel.pdf.PdfPage pdfPage, ICleanupStrategy strategy, List<PdfCleanUpLocation> additionalCleanUpLocations, CleanUpProperties properties) throws IOException
      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.
      Parameters:
      pdfPage - the PdfPage to which cleaned up applies
      strategy - cleanup strategy to be used
      additionalCleanUpLocations - list of additional locations to be cleaned up
      properties - additional properties for cleanUp
      Throws:
      IOException - if an I/O error occurs
    • cleanUpRedactAnnotations

      public static void cleanUpRedactAnnotations (InputStream inputPdf, OutputStream outputPdf) throws IOException
      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.
      Parameters:
      inputPdf - the pdf document InputStream to which cleaned up applies
      outputPdf - the cleaned up pdf document OutputStream
      Throws:
      IOException - if an I/O error occurs
    • cleanUpRedactAnnotations

      public static void cleanUpRedactAnnotations (InputStream inputPdf, OutputStream outputPdf, CleanUpProperties properties) throws IOException
      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.
      Parameters:
      inputPdf - the pdf document InputStream to which cleaned up applies
      outputPdf - the cleaned up pdf document OutputStream
      properties - additional properties for cleanUp
      Throws:
      IOException - if an I/O error occurs
    • cleanUpRedactAnnotations

      public static void cleanUpRedactAnnotations (com.itextpdf.kernel.pdf.PdfDocument pdfDocument) throws IOException
      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.
      Parameters:
      pdfDocument - a document to which cleaned up applies
      Throws:
      IOException - if an I/O error occurs
    • cleanUpRedactAnnotations

      public static void cleanUpRedactAnnotations (com.itextpdf.kernel.pdf.PdfDocument pdfDocument, CleanUpProperties properties) throws IOException
      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.
      Parameters:
      pdfDocument - a document to which cleaned up applies
      properties - additional properties for cleanUp
      Throws:
      IOException - if an I/O error occurs
    • cleanUpRedactAnnotations

      public static void cleanUpRedactAnnotations (InputStream inputPdf, OutputStream outputPdf, List<PdfCleanUpLocation> additionalCleanUpLocations) throws IOException
      Cleans the document by erasing regions defined by redact annotations and additional cleanup locations inside the document. Note, use methods with InputStream/OutputStream params if you don't want to consume itext-core product license limits.
      Parameters:
      inputPdf - the pdf document InputStream to which cleaned up applies
      outputPdf - the cleaned up pdf document OutputStream
      additionalCleanUpLocations - list of locations to be cleaned up
      Throws:
      IOException - if an I/O error occurs
    • cleanUpRedactAnnotations

      public static void cleanUpRedactAnnotations (com.itextpdf.kernel.pdf.PdfDocument pdfDocument, List<PdfCleanUpLocation> additionalCleanUpLocations) throws IOException
      Cleans the document by erasing regions defined by redact annotations and additional cleanup locations inside the document. Note, use methods with InputStream/OutputStream params if you don't want to consume itext-core product license limits.
      Parameters:
      pdfDocument - a document to which cleaned up applies
      additionalCleanUpLocations - list of locations to be cleaned up
      Throws:
      IOException - if an I/O error occurs
    • cleanUpRedactAnnotations

      public static void cleanUpRedactAnnotations (InputStream inputPdf, OutputStream outputPdf, List<PdfCleanUpLocation> additionalCleanUpLocations, CleanUpProperties properties) throws IOException
      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.
      Parameters:
      inputPdf - the pdf document InputStream to which cleaned up applies
      outputPdf - the cleaned up pdf document OutputStream
      additionalCleanUpLocations - list of locations to be cleaned up
      properties - additional properties for cleanUp
      Throws:
      IOException - if an I/O error occurs
    • cleanUpRedactAnnotations

      public static void cleanUpRedactAnnotations (com.itextpdf.kernel.pdf.PdfDocument pdfDocument, List<PdfCleanUpLocation> additionalCleanUpLocations, CleanUpProperties properties) throws IOException
      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.
      Parameters:
      pdfDocument - a document to which cleaned up applies
      additionalCleanUpLocations - list of locations to be cleaned up
      properties - additional properties for cleanUp
      Throws:
      IOException - if an I/O error occurs