Class PdfCleanUpProcessor
java.lang.Object
com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpProcessor
Represents the main mechanism for cleaning a PDF document.
- Since:
- 5.5.4
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic doubleUsed as the criterion of a good approximation of rounded line joins and line caps.private intprivate static final Stringstatic booleanstatic doubleWhen a document with line arts is being cleaned up, there are lot of calculations with floating point numbers.private Map<Integer, List<PdfCleanUpLocation>> private PdfStamperprivate static final Stringprivate static final String -
Constructor Summary
ConstructorsConstructorDescriptionPdfCleanUpProcessor(PdfStamper pdfStamper) Creates aPdfCleanUpProcessorobject.PdfCleanUpProcessor(List<PdfCleanUpLocation> pdfCleanUpLocations, PdfStamper pdfStamper) Creates aPdfCleanUpProcessorobject based on the givenListofPdfCleanUpLocations representing regions to be erased from the document. -
Method Summary
Modifier and TypeMethodDescriptionprivate 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, List<PdfCleanUpLocation> cleanUpLocations) private voidcolorCleanedLocations(PdfContentByte canvas, List<PdfCleanUpLocation> cleanUpLocations) private PdfCleanUpRegionFiltercreateFilter(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, List<Rectangle> textRectangles, PdfString overlayText, PdfString otDA, PdfNumber otQ, PdfBoolean otRepeat) private List<PdfCleanUpLocation> extractLocationsFromRedactAnnot(int page, int annotIndex, PdfDictionary annotDict) Extracts locations from the concrete annotation.private voidExtracts locations from the redact annotations contained in the document.private 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 Stringprivate intgetXObjNum(PdfName xobjName) private voidinsertFormXObj(PdfContentByte canvas, PdfDictionary pageDict, PdfStream formXObj, List<Rectangle> clippingRects, Rectangle annotRect) private Map<Integer, List<PdfCleanUpLocation>> organizeLocationsByPage(Collection<PdfCleanUpLocation> pdfCleanUpLocations) private FontretrieveFontFromAcroForm(PdfName fontName, PdfNumber size) private voidsaveRedactAnnotIndirRef(int page, String indRefStr) private voidsetFillColor(PdfContentByte canvas, List fillColorArgs) private voidsetStrokeColor(PdfContentByte canvas, List strokeColorArgs) translateQuadPointsToRectangles(PdfArray quadPoints)
-
Field Details
-
floatMultiplier
public static double floatMultiplierWhen 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 arcToleranceUsed as the criterion of a good approximation of rounded line joins and line caps. -
XOBJ_NAME_PREFIX
- See Also:
-
STROKE_COLOR
- See Also:
-
FILL_COLOR
- See Also:
-
currentXObjNum
private int currentXObjNum -
pdfStamper
-
pdfCleanUpLocations
-
redactAnnotIndirRefs
-
clippingRects
-
-
Constructor Details
-
PdfCleanUpProcessor
Creates aPdfCleanUpProcessorobject based on the givenListofPdfCleanUpLocations representing regions to be erased from the document.- Parameters:
pdfCleanUpLocations- list of locations to be cleaned uppdfStamper- APdfStamperobject representing the document which redaction applies to.
-
PdfCleanUpProcessor
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 Details
-
cleanUp
Cleans the document by erasing all the areas which are either provided or extracted from redaction annotations.- Throws:
IOExceptionDocumentException
-
cleanUpPage
private void cleanUpPage(int pageNum, List<PdfCleanUpLocation> cleanUpLocations) throws IOException, DocumentException - Throws:
IOExceptionDocumentException
-
createFilter
-
colorCleanedLocations
private void colorCleanedLocations(PdfContentByte canvas, List<PdfCleanUpLocation> cleanUpLocations) -
addColoredRectangle
-
organizeLocationsByPage
private Map<Integer, List<PdfCleanUpLocation>> organizeLocationsByPage(Collection<PdfCleanUpLocation> pdfCleanUpLocations) -
extractLocationsFromRedactAnnots
private void extractLocationsFromRedactAnnots()Extracts locations from the redact annotations contained in the document. -
extractLocationsFromRedactAnnots
Extracts locations from the redact annotations contained in the document and applied to the given page. -
saveRedactAnnotIndirRef
-
extractLocationsFromRedactAnnot
private 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
-
deleteRedactAnnots
Deletes redact annotations from the page and substitutes them with either OverlayText or RO object if it's needed.- Throws:
IOExceptionDocumentException
-
insertFormXObj
private void insertFormXObj(PdfContentByte canvas, PdfDictionary pageDict, PdfStream formXObj, List<Rectangle> clippingRects, Rectangle annotRect) throws IOException - Throws:
IOException
-
drawOverlayText
private void drawOverlayText(PdfContentByte canvas, List<Rectangle> textRectangles, PdfString overlayText, PdfString otDA, PdfNumber otQ, PdfBoolean otRepeat) throws DocumentException, IOException - Throws:
DocumentExceptionIOException
-
retrieveFontFromAcroForm
-
parseDAParam
- Throws:
IOException
-
getParentIndRefStr
-
generateNameForXObj
-
getXObjNum
-
setFillColor
-
setStrokeColor
-