Hi, Yes I'm sure that there is something in my code making this but I can't find it. I have now managed to remove the sharp edges to smoth but with very odd settings. I must create a round rectangle twice to make it work.
@Override public void onRender( PdfContentByte cb ) throws PdfDocumentException{ float width = MeasurementUtil.millimetersToPostscriptPoints( getWidth()); float height = MeasurementUtil.millimetersToPostscriptPoints( getHeight() ); float left = getLeft(); float top = getTop(); if( getPage().getPdfDocument().getCutMark() != null ){ left += getPage().getPdfDocument().getCutMark().getWidth(); top -= getPage().getPdfDocument().getCutMark().getHeight(); } PdfTemplate tp = cb.createTemplate(width, height); tp.roundRectangle(0, 0, width, height, MeasurementUtil.millimetersToPostscriptPoints( getRadius() )); cb.addTemplate(tp, MeasurementUtil.millimetersToPostscriptPoints( left ), MeasurementUtil.millimetersToPostscriptPoints( getPage().getPdfDocument().getHeight() - ( top + getHeight()))); ColumnText ct = new ColumnText( cb ); ct.setSimpleColumn( MeasurementUtil.millimetersToPostscriptPoints( left ), MeasurementUtil.millimetersToPostscriptPoints( getPage().getPdfDocument().getHeight() - ( top + getHeight())), MeasurementUtil.millimetersToPostscriptPoints( left + getWidth() ), MeasurementUtil.millimetersToPostscriptPoints( getPage().getPdfDocument().getHeight() - top ), 0, Element.ALIGN_LEFT ); PdfPTable table = new PdfPTable(1); table.setTotalWidth(MeasurementUtil.millimetersToPostscriptPoints(getWidth())); table.setLockedWidth( true ); table.setSpacingBefore(0); table.setSpacingAfter(0); PdfPCell cell = new PdfPCell(); cell.setBorderWidth( 0 ); cell.setVerticalAlignment( getVerticalAlign().getAlignment() ); cell.setLeft(0); cell.setTop(0); cell.setRight( 0 ); cell.setBottom( 0 ); if( isUseAscender() != null ) cell.setUseAscender( isUseAscender() ); cell.setIndent(0); cell.setPaddingLeft( MeasurementUtil.millimetersToPostscriptPoints(marginLeft) ); cell.setPaddingBottom( MeasurementUtil.millimetersToPostscriptPoints(marginBottom) ); cell.setPaddingRight( MeasurementUtil.millimetersToPostscriptPoints(marginRight) ); cell.setPaddingTop( MeasurementUtil.millimetersToPostscriptPoints(marginTop) ); cell.setFixedHeight(MeasurementUtil.millimetersToPostscriptPoints(getHeight() )); cell.setBorder( 0 ); cell.setCellEvent( new PdfPCellEvent(){ public void cellLayout(PdfPCell cell, Rectangle rect,PdfContentByte[] canvas) { PdfContentByte cb = canvas[PdfPTable.LINECANVAS]; PdfTemplate template = cb.createTemplate( rect.getWidth() , rect.getHeight()); // HERE. If I remove this there will be no color template.roundRectangle(0, 0, rect.getWidth() ,rect.getHeight() , MeasurementUtil.millimetersToPostscriptPoints( getRadius() )); template.clip(); template.newPath(); if( getBackgroundReference() != null ){ template.setColorFill( getPage().getPdfDocument().getColors().get( getBackgroundReference() )); } if( getBorder() != null ){ template.setLineWidth( MeasurementUtil.millimetersToPostscriptPoints( getBorder().getThickness()) ); template.setColorStroke( getPage().getPdfDocument().getColors().get( getBorder().getColorReference() )); } template.roundRectangle(0, 0, rect.getWidth() ,rect.getHeight() , MeasurementUtil.millimetersToPostscriptPoints( getRadius() )); if( getBackgroundReference() != null || getBorder() != null ){ if( getBackgroundReference() != null && getBorder() != null ){ template.fillStroke(); }else if( getBackgroundReference() != null ){ template.fill(); }else{ template.stroke(); } } cb.addTemplate( template, rect.getLeft(), rect.getBottom()); } }); if( getRotation() != null ) cell.setRotation( getRotation() ); if( ! paragraphs.isEmpty() ){ for( AbstractParagraph paragraph : paragraphs ){ paragraph.onRender( cell ); } }else{ // Need to make this otherwise the block wont show com.lowagie.text.Paragraph pr = new com.lowagie.text.Paragraph(); Chunk chunk = new Chunk( " " ); pr.add( chunk ); cell.addElement( pr ); } table.addCell(cell); ct.addElement( table ); try { ct.go(); } catch (DocumentException e) { throw new PdfDocumentException( e ); } } -- View this message in context: http://old.nabble.com/problem-with-rounded-corners-tp28328340p28330366.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.itextpdf.com/book/ Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/