Class PdfCleanUpProcessor


  • public class PdfCleanUpProcessor
    extends java.lang.Object
    Represents the main mechanism for cleaning a PDF document.
    Since:
    5.5.4
    • Field Detail

      • floatMultiplier

        public static double floatMultiplier
        When a document with line arts is being cleaned up, there are lot of calculations with floating point numbers. All of them are translated into fixed point numbers by multiplying by this coefficient. Vary it to adjust the preciseness of the calculations.
      • fillCleanedArea

        public static boolean fillCleanedArea
      • arcTolerance

        public static double arcTolerance
        Used as the criterion of a good approximation of rounded line joins and line caps.
      • XOBJ_NAME_PREFIX

        private static final java.lang.String XOBJ_NAME_PREFIX
        See Also:
        Constant Field Values
      • currentXObjNum

        private int currentXObjNum
      • pdfCleanUpLocations

        private java.util.Map<java.lang.Integer,​java.util.List<PdfCleanUpLocation>> pdfCleanUpLocations
      • redactAnnotIndirRefs

        private java.util.Map<java.lang.Integer,​java.util.Set<java.lang.String>> redactAnnotIndirRefs
      • clippingRects

        private java.util.Map<java.lang.Integer,​java.util.List<Rectangle>> clippingRects
    • Constructor Detail

      • PdfCleanUpProcessor

        public PdfCleanUpProcessor​(java.util.List<PdfCleanUpLocation> pdfCleanUpLocations,
                                   PdfStamper pdfStamper)
        Creates a PdfCleanUpProcessor object based on the given List of PdfCleanUpLocations representing regions to be erased from the document.
        Parameters:
        pdfCleanUpLocations - list of locations to be cleaned up {@see PdfCleanUpLocation}
        pdfStamper - APdfStamper object representing the document which redaction applies to.
      • PdfCleanUpProcessor

        public PdfCleanUpProcessor​(PdfStamper pdfStamper)
        Creates a PdfCleanUpProcessor object. Regions to be erased from the document are extracted from the redact annotations contained inside the given document.
        Parameters:
        pdfStamper - APdfStamper object representing the document which redaction applies to.
    • Method Detail

      • cleanUp

        public void cleanUp()
                     throws java.io.IOException,
                            DocumentException
        Cleans the document by erasing all the areas which are either provided or extracted from redaction annotations.
        Throws:
        java.io.IOException
        DocumentException
      • organizeLocationsByPage

        private java.util.Map<java.lang.Integer,​java.util.List<PdfCleanUpLocation>> organizeLocationsByPage​(java.util.Collection<PdfCleanUpLocation> pdfCleanUpLocations)
      • extractLocationsFromRedactAnnots

        private void extractLocationsFromRedactAnnots()
        Extracts locations from the redact annotations contained in the document.
      • extractLocationsFromRedactAnnots

        private java.util.List<PdfCleanUpLocation> extractLocationsFromRedactAnnots​(int page,
                                                                                    PdfDictionary pageDict)
        Extracts locations from the redact annotations contained in the document and applied to the given page.
      • saveRedactAnnotIndirRef

        private void saveRedactAnnotIndirRef​(int page,
                                             java.lang.String indRefStr)
      • extractLocationsFromRedactAnnot

        private java.util.List<PdfCleanUpLocation> extractLocationsFromRedactAnnot​(int page,
                                                                                   int annotIndex,
                                                                                   PdfDictionary annotDict)
        Extracts locations from the concrete annotation. Note: annotation can consist not only of one area specified by the RECT entry, but also of multiple areas specified by the QuadPoints entry in the annotation dictionary.
      • translateQuadPointsToRectangles

        private java.util.List<Rectangle> translateQuadPointsToRectangles​(PdfArray quadPoints)
      • deleteRedactAnnots

        private void deleteRedactAnnots​(int pageNum)
                                 throws java.io.IOException,
                                        DocumentException
        Deletes redact annotations from the page and substitutes them with either OverlayText or RO object if it's needed.
        Throws:
        java.io.IOException
        DocumentException
      • retrieveFontFromAcroForm

        private Font retrieveFontFromAcroForm​(PdfName fontName,
                                              PdfNumber size)
      • parseDAParam

        java.util.Map<java.lang.String,​java.util.List> parseDAParam​(PdfString DA)
                                                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • getParentIndRefStr

        private java.lang.String getParentIndRefStr​(PdfDictionary dict)
      • getXObjNum

        private int getXObjNum​(PdfName xobjName)
      • setFillColor

        private void setFillColor​(PdfContentByte canvas,
                                  java.util.List fillColorArgs)
      • setStrokeColor

        private void setStrokeColor​(PdfContentByte canvas,
                                    java.util.List strokeColorArgs)