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>chunksprivate static java.awt.ColorCLEANED_AREA_FILL_COLORprivate booleanclipPathprivate intclippingRuleprivate java.util.Stack<PdfCleanUpContext>contextStackprivate PathcurrentFillPathprivate PathcurrentStrokePathprivate PdfCleanUpRegionFilterfilterprivate PathnewClippingPathprivate PdfStamperpdfStamperprivate intstrNumberprivate PathunfilteredCurrentPath
-
Constructor Summary
Constructors Constructor Description PdfCleanUpRenderListener(PdfStamper pdfStamper, PdfCleanUpRegionFilter filter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbeginTextBlock()Called when a new text block is beginning (i.e.private voidcleanImage(java.awt.image.BufferedImage image, java.util.List<Rectangle> areasToBeCleaned)voidclearChunks()voidclipPath(int rule)Called when the current path should be set as a new clipping path.private voidcloseOutputStream(java.io.OutputStream os)voidendTextBlock()Called when a text block has ended (i.e.private PathfilterCurrentPath(Matrix ctm, boolean stroke, int fillingRule, float lineWidth, int lineCapStyle, int lineJoinStyle, float miterLimit, LineDashPattern lineDashPattern)java.util.List<PdfCleanUpContentChunk>getChunks()intgetClippingRule()PdfCleanUpContextgetContext()PathgetCurrentFillPath()PathgetCurrentStrokePath()private java.util.List<Rectangle>getImageAreasToBeCleaned(ImageRenderInfo renderInfo)private byte[]getJPGBytes(java.awt.image.BufferedImage image)PathgetNewClipPath()booleanisClipped()voidmodifyPath(PathConstructionRenderInfo renderInfo)Called when the current path is being modified.voidpopContext()private byte[]processImage(byte[] imageBytes, java.util.List<Rectangle> areasToBeCleaned)voidregisterNewContext(PdfDictionary resources, PdfContentByte canvas)voidrenderImage(ImageRenderInfo renderInfo)Called when image should be renderedPathrenderPath(PathPaintingRenderInfo renderInfo)Called when the current path should be rendered.voidrenderText(TextRenderInfo renderInfo)Called when text should be renderedvoidsetClipped(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:RenderListenerCalled when text should be rendered- Specified by:
renderTextin interfaceRenderListener- Parameters:
renderInfo- information specifying what to render
-
renderImage
public void renderImage(ImageRenderInfo renderInfo)
Description copied from interface:RenderListenerCalled when image should be rendered- Specified by:
renderImagein interfaceRenderListener- Parameters:
renderInfo- information specifying what to render
-
beginTextBlock
public void beginTextBlock()
Description copied from interface:RenderListenerCalled when a new text block is beginning (i.e. BT)- Specified by:
beginTextBlockin interfaceRenderListener
-
endTextBlock
public void endTextBlock()
Description copied from interface:RenderListenerCalled when a text block has ended (i.e. ET)- Specified by:
endTextBlockin interfaceRenderListener
-
modifyPath
public void modifyPath(PathConstructionRenderInfo renderInfo)
Description copied from interface:ExtRenderListenerCalled when the current path is being modified. E.g. new segment is being added, new subpath is being started etc.- Specified by:
modifyPathin 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:ExtRenderListenerCalled when the current path should be rendered.- Specified by:
renderPathin 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:ExtRenderListenerCalled when the current path should be set as a new clipping path.- Specified by:
clipPathin interfaceExtRenderListener- Parameters:
rule- EitherPathPaintingRenderInfo.EVEN_ODD_RULEorPathPaintingRenderInfo.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)
-
-