[iText-questions] problem with rounded corners
Hi, I have problems with rounded corners. If I use the cb directly here and don't create a Pdftemplate everythings works fine with the rounded corners but if the background I set every block in my page will get them. cell.setCellEvent( new PdfPCellEvent(){ public void cellLayout(PdfPCell cell, Rectangle rect,PdfContentByte[] canvas) { // Here I have tried to just add it to the PdfContentByte but then every block // is the color of the last block. I've tried cb.saveState() and restoreState() but without luck PdfContentByte cb = canvas[PdfPTable.LINECANVAS]; PdfTemplate template = cb.createTemplate( rect.getWidth() , rect.getHeight()); if( getBorder() != null ){ template.setLineWidth( MeasurementUtil.millimetersToPostscriptPoints( getBorder().getThickness()) ); template.setColorStroke( getPage().getPdfDocument().getColors().get( getBorder().getColorReference() )); } if( getBackgroundReference() != null ){ template.setColorFill( getPage().getPdfDocument().getColors().get( getBackgroundReference() )); } 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()); }}); -- View this message in context: http://old.nabble.com/problem-with-rounded-corners-tp28328340p28328340.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/
Re: [iText-questions] problem with rounded corners
can anyone give me some pointer on why PdfTemplate.roundRectangle() doesn't make fine edges as PdfContentByte does? -- View this message in context: http://old.nabble.com/problem-with-rounded-corners-tp28328340p28329580.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/
Re: [iText-questions] problem with rounded corners
PdfTemplate extends PdfContentByte, there's no reason why the results shouldn't be the same. It would be helpful to see a pdf with those differences. Paulo From: Mathias Nilsson [wicket.program...@gmail.com] Sent: Thursday, April 22, 2010 3:22 PM To: itext-questions@lists.sourceforge.net Subject: Re: [iText-questions] problem with rounded corners can anyone give me some pointer on why PdfTemplate.roundRectangle() doesn't make fine edges as PdfContentByte does? -- View this message in context: http://old.nabble.com/problem-with-rounded-corners-tp28328340p28329580.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/ Aviso Legal: Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem. Disclaimer: This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message. -- ___ 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/
Re: [iText-questions] problem with rounded corners
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