List of usage examples for com.itextpdf.text.pdf.parser PathPaintingRenderInfo NONZERO_WINDING_RULE
int NONZERO_WINDING_RULE
To view the source code for com.itextpdf.text.pdf.parser PathPaintingRenderInfo NONZERO_WINDING_RULE.
Click Source Link
From source file:mkl.testarea.itext5.pdfcleanup.PdfCleanUpContentOperator.java
License:Open Source License
private void writePath(String operatorStr, PdfContentByte canvas, PdfName strokeColorSpace) throws IOException { if (nwFillOperators.contains(operatorStr)) { writePath(cleanUpStrategy.getCurrentFillPath(), f, canvas); } else if (eoFillOperators.contains(operatorStr)) { writePath(cleanUpStrategy.getCurrentFillPath(), eoF, canvas); }//from w w w .ja va 2s . c om if (strokeOperators.contains(operatorStr)) { writeStroke(canvas, cleanUpStrategy.getCurrentStrokePath(), strokeColorSpace); } if (cleanUpStrategy.isClipped()) { if (!cleanUpStrategy.getNewClipPath().isEmpty()) { byte[] clippingOperator = (cleanUpStrategy .getClippingRule() == PathPaintingRenderInfo.NONZERO_WINDING_RULE) ? W : eoW; writePath(cleanUpStrategy.getNewClipPath(), clippingOperator, canvas); } else { // If the clipping path from the source document is cleaned (it happens when reduction // area covers the path completely), then you should treat it as an empty set (no points // are included in the path). Then the current clipping path (which is the intersection // between previous clipping path and the new one) is also empty set, which means that // there is no visible content at all. But at the same time as we removed the clipping // path, the invisible content would become visible. So, to emulate the correct result, // we would simply put a degenerate clipping path which consists of a single point at (0, 0). Path degeneratePath = new Path(); degeneratePath.moveTo(0, 0); writePath(degeneratePath, W, canvas); } canvas.getInternalBuffer().append(n); cleanUpStrategy.setClipped(false); } }
From source file:mkl.testarea.itext5.pdfcleanup.PdfCleanUpRegionFilter.java
License:Open Source License
protected Path filterStrokePath(Path sourcePath, Matrix ctm, float lineWidth, int lineCapStyle, int lineJoinStyle, float miterLimit, LineDashPattern lineDashPattern) { Path path = sourcePath;// w ww . j av a 2s . c om JoinType joinType = getJoinType(lineJoinStyle); EndType endType = getEndType(lineCapStyle); if (lineDashPattern != null) { if (!lineDashPattern.isSolid()) { path = applyDashPattern(path, lineDashPattern); } } ClipperOffset offset = new ClipperOffset(miterLimit, StrictPdfCleanUpProcessor.arcTolerance * StrictPdfCleanUpProcessor.floatMultiplier); List<Subpath> degenerateSubpaths = addPath(offset, path, joinType, endType); PolyTree resultTree = new PolyTree(); offset.execute(resultTree, lineWidth * StrictPdfCleanUpProcessor.floatMultiplier / 2); Path offsetedPath = convertToPath(resultTree); if (degenerateSubpaths.size() > 0) { if (endType == EndType.OPEN_ROUND) { List<Subpath> circles = convertToCircles(degenerateSubpaths, lineWidth / 2); offsetedPath.addSubpaths(circles); } else if (endType == EndType.OPEN_SQUARE && lineDashPattern != null) { List<Subpath> squares = convertToSquares(degenerateSubpaths, lineWidth, sourcePath); offsetedPath.addSubpaths(squares); } } return filterFillPath(offsetedPath, ctm, PathPaintingRenderInfo.NONZERO_WINDING_RULE); }