Package com.itextpdf.text.pdf.pdfcleanup
Class PdfCleanUpProcessor
- java.lang.Object
-
- com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpProcessor
-
public class PdfCleanUpProcessor extends java.lang.ObjectRepresents the main mechanism for cleaning a PDF document.- Since:
- 5.5.4
-
-
Field Summary
Fields Modifier and Type Field Description static doublearcToleranceUsed as the criterion of a good approximation of rounded line joins and line caps.private java.util.Map<java.lang.Integer,java.util.List<Rectangle>>clippingRectsprivate intcurrentXObjNumprivate static java.lang.StringFILL_COLORstatic booleanfillCleanedAreastatic doublefloatMultiplierWhen a document with line arts is being cleaned up, there are lot of calculations with floating point numbers.private java.util.Map<java.lang.Integer,java.util.List<PdfCleanUpLocation>>pdfCleanUpLocationsprivate PdfStamperpdfStamperprivate java.util.Map<java.lang.Integer,java.util.Set<java.lang.String>>redactAnnotIndirRefsprivate static java.lang.StringSTROKE_COLORprivate static java.lang.StringXOBJ_NAME_PREFIX
-
Constructor Summary
Constructors Constructor Description PdfCleanUpProcessor(PdfStamper pdfStamper)Creates aPdfCleanUpProcessorobject.PdfCleanUpProcessor(java.util.List<PdfCleanUpLocation> pdfCleanUpLocations, PdfStamper pdfStamper)Creates aPdfCleanUpProcessorobject based on the givenListofPdfCleanUpLocations representing regions to be erased from the document.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddColoredRectangle(PdfContentByte canvas, PdfCleanUpLocation cleanUpLocation)voidcleanUp()Cleans the document by erasing all the areas which are either provided or extracted from redaction annotations.private voidcleanUpPage(int pageNum, java.util.List<PdfCleanUpLocation> cleanUpLocations)private voidcolorCleanedLocations(PdfContentByte canvas, java.util.List<PdfCleanUpLocation> cleanUpLocations)private PdfCleanUpRegionFiltercreateFilter(java.util.List<PdfCleanUpLocation> cleanUpLocations)private voiddeleteRedactAnnots(int pageNum)Deletes redact annotations from the page and substitutes them with either OverlayText or RO object if it's needed.private voiddrawOverlayText(PdfContentByte canvas, java.util.List<Rectangle> textRectangles, PdfString overlayText, PdfString otDA, PdfNumber otQ, PdfBoolean otRepeat)private java.util.List<PdfCleanUpLocation>extractLocationsFromRedactAnnot(int page, int annotIndex, PdfDictionary annotDict)Extracts locations from the concrete annotation.private voidextractLocationsFromRedactAnnots()Extracts locations from the redact annotations contained in the document.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.private PdfNamegenerateNameForXObj(PdfDictionary pageDict)private java.lang.StringgetParentIndRefStr(PdfDictionary dict)private intgetXObjNum(PdfName xobjName)private voidinsertFormXObj(PdfContentByte canvas, PdfDictionary pageDict, PdfStream formXObj, java.util.List<Rectangle> clippingRects, Rectangle annotRect)private java.util.Map<java.lang.Integer,java.util.List<PdfCleanUpLocation>>organizeLocationsByPage(java.util.Collection<PdfCleanUpLocation> pdfCleanUpLocations)(package private) java.util.Map<java.lang.String,java.util.List>parseDAParam(PdfString DA)private FontretrieveFontFromAcroForm(PdfName fontName, PdfNumber size)private voidsaveRedactAnnotIndirRef(int page, java.lang.String indRefStr)private voidsetFillColor(PdfContentByte canvas, java.util.List fillColorArgs)private voidsetStrokeColor(PdfContentByte canvas, java.util.List strokeColorArgs)private java.util.List<Rectangle>translateQuadPointsToRectangles(PdfArray quadPoints)
-
-
-
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
-
STROKE_COLOR
private static final java.lang.String STROKE_COLOR
- See Also:
- Constant Field Values
-
FILL_COLOR
private static final java.lang.String FILL_COLOR
- See Also:
- Constant Field Values
-
currentXObjNum
private int currentXObjNum
-
pdfStamper
private PdfStamper pdfStamper
-
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 aPdfCleanUpProcessorobject based on the givenListofPdfCleanUpLocations representing regions to be erased from the document.- Parameters:
pdfCleanUpLocations- list of locations to be cleaned up {@see PdfCleanUpLocation}pdfStamper- APdfStamperobject representing the document which redaction applies to.
-
PdfCleanUpProcessor
public PdfCleanUpProcessor(PdfStamper pdfStamper)
Creates aPdfCleanUpProcessorobject. Regions to be erased from the document are extracted from the redact annotations contained inside the given document.- Parameters:
pdfStamper- APdfStamperobject representing the document which redaction applies to.
-
-
Method Detail
-
cleanUp
public void cleanUp() throws java.io.IOException, DocumentExceptionCleans the document by erasing all the areas which are either provided or extracted from redaction annotations.- Throws:
java.io.IOExceptionDocumentException
-
cleanUpPage
private void cleanUpPage(int pageNum, java.util.List<PdfCleanUpLocation> cleanUpLocations) throws java.io.IOException, DocumentException- Throws:
java.io.IOExceptionDocumentException
-
createFilter
private PdfCleanUpRegionFilter createFilter(java.util.List<PdfCleanUpLocation> cleanUpLocations)
-
colorCleanedLocations
private void colorCleanedLocations(PdfContentByte canvas, java.util.List<PdfCleanUpLocation> cleanUpLocations)
-
addColoredRectangle
private void addColoredRectangle(PdfContentByte canvas, PdfCleanUpLocation cleanUpLocation)
-
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, DocumentExceptionDeletes redact annotations from the page and substitutes them with either OverlayText or RO object if it's needed.- Throws:
java.io.IOExceptionDocumentException
-
insertFormXObj
private void insertFormXObj(PdfContentByte canvas, PdfDictionary pageDict, PdfStream formXObj, java.util.List<Rectangle> clippingRects, Rectangle annotRect) throws java.io.IOException
- Throws:
java.io.IOException
-
drawOverlayText
private void drawOverlayText(PdfContentByte canvas, java.util.List<Rectangle> textRectangles, PdfString overlayText, PdfString otDA, PdfNumber otQ, PdfBoolean otRepeat) throws DocumentException, java.io.IOException
- Throws:
DocumentExceptionjava.io.IOException
-
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)
-
generateNameForXObj
private PdfName generateNameForXObj(PdfDictionary pageDict)
-
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)
-
-