I am designing a pdf report using itext library.I have implemented a paragraph in it.Now as per my requirement i have to set this paragraph inside rectangular box with backg
You need a Chunk
to do that:
Font f = new Font(FontFamily.TIMES_ROMAN, 25.0f, Font.BOLD, BaseColor.WHITE);
Chunk c = new Chunk("Total Cost:" + dbsumcallcost, f);
c.setBackground(BaseColor.RED);
Paragraph p = new Paragraph(c);
document.add(p);
See the ChunkBackground example and the resulting PDF document.
You can fine-tune the rectangle by using a slightly different setBackground()
method: http://api.itextpdf.com/itext/com/itextpdf/text/Chunk.html#setBackground%28com.itextpdf.text.BaseColor,%20float,%20float,%20float,%20float%29