List of usage examples for com.itextpdf.text.pdf PdfContentByte newPath
public void newPath()
From source file:mkl.testarea.itext5.pdfcleanup.StrictPdfCleanUpProcessor.java
License:Open Source License
private void insertFormXObj(PdfContentByte canvas, PdfDictionary pageDict, PdfStream formXObj, List<Rectangle> clippingRects, Rectangle annotRect) throws IOException { PdfName xobjName = generateNameForXObj(pageDict); canvas.saveState();//from www. j av a 2 s . c om for (Rectangle rect : clippingRects) { canvas.rectangle(rect.getLeft(), rect.getBottom(), rect.getWidth(), rect.getHeight()); } canvas.clip(); canvas.newPath(); canvas.addFormXObj(formXObj, xobjName, 1, 0, 0, 1, annotRect.getLeft(), annotRect.getBottom()); canvas.restoreState(); }
From source file:org.frobic.colorednodes.renderers.NewNodeRenderer.java
License:Open Source License
@Override public void renderPDF(Item item, PDFTarget target, PreviewProperties properties) { Float x = item.getData(NodeItem.X); Float y = item.getData(NodeItem.Y); Float size = item.getData(NodeItem.SIZE); Float angle = item.getData(NodeItem.ANGLE); size /= 2f;/*from w w w . j a v a2 s .c om*/ Color color = item.getData(NodeItem.COLOR); Integer nbcolors = item.getData(NodeItem.NBCOLOR); Color[] colors = item.getData(NodeItem.COLORS); Color borderColor = ((DependantColor) properties.getValue(PreviewProperty.NODE_BORDER_COLOR)) .getColor(color); float borderSize = properties.getFloatValue(PreviewProperty.NODE_BORDER_WIDTH); float alpha = properties.getIntValue(PreviewProperty.NODE_OPACITY) / 100f; PdfContentByte cb = target.getContentByte(); cb.setRGBColorStroke(borderColor.getRed(), borderColor.getGreen(), borderColor.getBlue()); cb.setLineWidth(borderSize); cb.setRGBColorFill(color.getRed(), color.getGreen(), color.getBlue()); if (alpha < 1f) { cb.saveState(); PdfGState gState = new PdfGState(); gState.setFillOpacity(alpha); gState.setStrokeOpacity(alpha); cb.setGState(gState); } for (int i = 0; i < nbcolors; i++) { cb.setRGBColorFill(colors[nbcolors - i - 1].getRed(), colors[nbcolors - i - 1].getGreen(), colors[nbcolors - i - 1].getBlue()); if (size >= 0.5) { cb.newPath(); ArrayList ar = cb.bezierArc(x - size, -y + size, x + size, 0 - size - y, 360f * (nbcolors - i - 1) / nbcolors + (360f / 6.28f) * angle, 360f * (1) / nbcolors); //cb.arc(x-size,-y+size,x+size,0-size-y,360f*(nbcolors-i-1)/nbcolors+angle,360f*(1)/nbcolors) ; cb.moveTo(x, -y); float pt[] = (float[]) ar.get(0); cb.moveTo(pt[0], pt[1]); for (int k = 0; k < ar.size(); ++k) { pt = (float[]) ar.get(k); cb.curveTo(pt[2], pt[3], pt[4], pt[5], pt[6], pt[7]); } cb.lineTo(x, -y); //strokeAndFill(); // cb.ClosePathFillStroke(); if (borderSize > 0) { cb.fill(); } else { cb.fill(); } if (borderSize > 0) { cb.circle(x, -y, size); cb.stroke(); } } } if (alpha < 1f) { cb.restoreState(); } }