Package com.itextpdf.text.pdf.pdfcleanup
Class PdfCleanUpRenderListener
- java.lang.Object
-
- com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpRenderListener
-
- All Implemented Interfaces:
ExtRenderListener
,RenderListener
class PdfCleanUpRenderListener extends java.lang.Object implements ExtRenderListener
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<PdfCleanUpContentChunk>
chunks
private static java.awt.Color
CLEANED_AREA_FILL_COLOR
private boolean
clipPath
private int
clippingRule
private java.util.Stack<PdfCleanUpContext>
contextStack
private Path
currentFillPath
private Path
currentStrokePath
private PdfCleanUpRegionFilter
filter
private Path
newClippingPath
private PdfStamper
pdfStamper
private int
strNumber
private Path
unfilteredCurrentPath
-
Constructor Summary
Constructors Constructor Description PdfCleanUpRenderListener(PdfStamper pdfStamper, PdfCleanUpRegionFilter filter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beginTextBlock()
Called when a new text block is beginning (i.e.private void
cleanImage(java.awt.image.BufferedImage image, java.util.List<Rectangle> areasToBeCleaned)
void
clearChunks()
void
clipPath(int rule)
Called when the current path should be set as a new clipping path.private void
closeOutputStream(java.io.OutputStream os)
void
endTextBlock()
Called when a text block has ended (i.e.private Path
filterCurrentPath(Matrix ctm, boolean stroke, int fillingRule, float lineWidth, int lineCapStyle, int lineJoinStyle, float miterLimit, LineDashPattern lineDashPattern)
java.util.List<PdfCleanUpContentChunk>
getChunks()
int
getClippingRule()
PdfCleanUpContext
getContext()
Path
getCurrentFillPath()
Path
getCurrentStrokePath()
private java.util.List<Rectangle>
getImageAreasToBeCleaned(ImageRenderInfo renderInfo)
private byte[]
getJPGBytes(java.awt.image.BufferedImage image)
Path
getNewClipPath()
boolean
isClipped()
void
modifyPath(PathConstructionRenderInfo renderInfo)
Called when the current path is being modified.void
popContext()
private byte[]
processImage(byte[] imageBytes, java.util.List<Rectangle> areasToBeCleaned)
void
registerNewContext(PdfDictionary resources, PdfContentByte canvas)
void
renderImage(ImageRenderInfo renderInfo)
Called when image should be renderedPath
renderPath(PathPaintingRenderInfo renderInfo)
Called when the current path should be rendered.void
renderText(TextRenderInfo renderInfo)
Called when text should be renderedvoid
setClipped(boolean clipPath)
-
-
-
Field Detail
-
CLEANED_AREA_FILL_COLOR
private static final java.awt.Color CLEANED_AREA_FILL_COLOR
-
pdfStamper
private PdfStamper pdfStamper
-
filter
private PdfCleanUpRegionFilter filter
-
chunks
private java.util.List<PdfCleanUpContentChunk> chunks
-
contextStack
private java.util.Stack<PdfCleanUpContext> contextStack
-
strNumber
private int strNumber
-
unfilteredCurrentPath
private Path unfilteredCurrentPath
-
currentStrokePath
private Path currentStrokePath
-
currentFillPath
private Path currentFillPath
-
newClippingPath
private Path newClippingPath
-
clipPath
private boolean clipPath
-
clippingRule
private int clippingRule
-
-
Constructor Detail
-
PdfCleanUpRenderListener
public PdfCleanUpRenderListener(PdfStamper pdfStamper, PdfCleanUpRegionFilter filter)
-
-
Method Detail
-
renderText
public void renderText(TextRenderInfo renderInfo)
Description copied from interface:RenderListener
Called when text should be rendered- Specified by:
renderText
in interfaceRenderListener
- Parameters:
renderInfo
- information specifying what to render
-
renderImage
public void renderImage(ImageRenderInfo renderInfo)
Description copied from interface:RenderListener
Called when image should be rendered- Specified by:
renderImage
in interfaceRenderListener
- Parameters:
renderInfo
- information specifying what to render
-
beginTextBlock
public void beginTextBlock()
Description copied from interface:RenderListener
Called when a new text block is beginning (i.e. BT)- Specified by:
beginTextBlock
in interfaceRenderListener
-
endTextBlock
public void endTextBlock()
Description copied from interface:RenderListener
Called when a text block has ended (i.e. ET)- Specified by:
endTextBlock
in interfaceRenderListener
-
modifyPath
public void modifyPath(PathConstructionRenderInfo renderInfo)
Description copied from interface:ExtRenderListener
Called when the current path is being modified. E.g. new segment is being added, new subpath is being started etc.- Specified by:
modifyPath
in interfaceExtRenderListener
- Parameters:
renderInfo
- Contains information about the path segment being added to the current path.
-
renderPath
public Path renderPath(PathPaintingRenderInfo renderInfo)
Description copied from interface:ExtRenderListener
Called when the current path should be rendered.- Specified by:
renderPath
in interfaceExtRenderListener
- Parameters:
renderInfo
- Contains information about the current path which should be rendered.- Returns:
- The path which can be used as a new clipping path.
-
clipPath
public void clipPath(int rule)
Description copied from interface:ExtRenderListener
Called when the current path should be set as a new clipping path.- Specified by:
clipPath
in interfaceExtRenderListener
- Parameters:
rule
- EitherPathPaintingRenderInfo.EVEN_ODD_RULE
orPathPaintingRenderInfo.NONZERO_WINDING_RULE
-
isClipped
public boolean isClipped()
-
setClipped
public void setClipped(boolean clipPath)
-
getClippingRule
public int getClippingRule()
-
getCurrentStrokePath
public Path getCurrentStrokePath()
-
getCurrentFillPath
public Path getCurrentFillPath()
-
getNewClipPath
public Path getNewClipPath()
-
getChunks
public java.util.List<PdfCleanUpContentChunk> getChunks()
-
getContext
public PdfCleanUpContext getContext()
-
registerNewContext
public void registerNewContext(PdfDictionary resources, PdfContentByte canvas)
-
popContext
public void popContext()
-
clearChunks
public void clearChunks()
-
getImageAreasToBeCleaned
private java.util.List<Rectangle> getImageAreasToBeCleaned(ImageRenderInfo renderInfo)
- Returns:
- null if the image is not allowed (either it is fully covered or ctm == null). List of covered image areas otherwise.
-
processImage
private byte[] processImage(byte[] imageBytes, java.util.List<Rectangle> areasToBeCleaned)
-
cleanImage
private void cleanImage(java.awt.image.BufferedImage image, java.util.List<Rectangle> areasToBeCleaned)
-
getJPGBytes
private byte[] getJPGBytes(java.awt.image.BufferedImage image)
-
filterCurrentPath
private Path filterCurrentPath(Matrix ctm, boolean stroke, int fillingRule, float lineWidth, int lineCapStyle, int lineJoinStyle, float miterLimit, LineDashPattern lineDashPattern)
- Parameters:
fillingRule
- If the path is contour, pass any value.
-
closeOutputStream
private void closeOutputStream(java.io.OutputStream os)
-
-