Package com.itextpdf.text.pdf.pdfcleanup
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 double
Used as the criterion of a good approximation of rounded line joins and line caps.private int
private static final String
static boolean
static double
When a document with line arts is being cleaned up, there are lot of calculations with floating point numbers.private Map<Integer,
List<PdfCleanUpLocation>> private PdfStamper
private static final String
private static final String
-
Constructor Summary
ConstructorsConstructorDescriptionPdfCleanUpProcessor
(PdfStamper pdfStamper) Creates aPdfCleanUpProcessor
object.PdfCleanUpProcessor
(List<PdfCleanUpLocation> pdfCleanUpLocations, PdfStamper pdfStamper) Creates aPdfCleanUpProcessor
object based on the givenList
ofPdfCleanUpLocation
s representing regions to be erased from the document. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addColoredRectangle
(PdfContentByte canvas, PdfCleanUpLocation cleanUpLocation) void
cleanUp()
Cleans the document by erasing all the areas which are either provided or extracted from redaction annotations.private void
cleanUpPage
(int pageNum, List<PdfCleanUpLocation> cleanUpLocations) private void
colorCleanedLocations
(PdfContentByte canvas, List<PdfCleanUpLocation> cleanUpLocations) private PdfCleanUpRegionFilter
createFilter
(List<PdfCleanUpLocation> cleanUpLocations) private void
deleteRedactAnnots
(int pageNum) Deletes redact annotations from the page and substitutes them with either OverlayText or RO object if it's needed.private void
drawOverlayText
(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 void
Extracts 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 PdfName
generateNameForXObj
(PdfDictionary pageDict) private String
private int
getXObjNum
(PdfName xobjName) private void
insertFormXObj
(PdfContentByte canvas, PdfDictionary pageDict, PdfStream formXObj, List<Rectangle> clippingRects, Rectangle annotRect) private Map<Integer,
List<PdfCleanUpLocation>> organizeLocationsByPage
(Collection<PdfCleanUpLocation> pdfCleanUpLocations) private Font
retrieveFontFromAcroForm
(PdfName fontName, PdfNumber size) private void
saveRedactAnnotIndirRef
(int page, String indRefStr) private void
setFillColor
(PdfContentByte canvas, List fillColorArgs) private void
setStrokeColor
(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 aPdfCleanUpProcessor
object based on the givenList
ofPdfCleanUpLocation
s representing regions to be erased from the document.- Parameters:
pdfCleanUpLocations
- list of locations to be cleaned uppdfStamper
- APdfStamper
object representing the document which redaction applies to.
-
PdfCleanUpProcessor
Creates aPdfCleanUpProcessor
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 Details
-
cleanUp
Cleans the document by erasing all the areas which are either provided or extracted from redaction annotations.- Throws:
IOException
DocumentException
-
cleanUpPage
private void cleanUpPage(int pageNum, List<PdfCleanUpLocation> cleanUpLocations) throws IOException, DocumentException - Throws:
IOException
DocumentException
-
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:
IOException
DocumentException
-
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:
DocumentException
IOException
-
retrieveFontFromAcroForm
-
parseDAParam
- Throws:
IOException
-
getParentIndRefStr
-
generateNameForXObj
-
getXObjNum
-
setFillColor
-
setStrokeColor
-