Hi Robert,

Thank you very much for your answer. That helped me to get it half way. I
was able to set border and border colour to the table. *But I am still not
sure how to set padding top, padding bottom and align center of the table
column values* in the table. The method I used to generate a sample table
is:

public void generateSiteVariantTable(RtfSection sect) throws IOException {
        
        RtfTable tbl = sect.newTable(new DummyTableColumnsInfo());
        
        FOPRtfAttributes attrs = new FOPRtfAttributes();
        attrs.set(IBorderAttributes.BORDER_COLOR, new Color(200,200,200));
        attrs.set(IBorderAttributes.BORDER_SINGLE_THICKNESS);
        attrs.set(IBorderAttributes.BORDER_WIDTH, 3);
        attrs.set(ITableAttributes.ATTR_CELL_U_PADDING_TOP, 10);
        attrs.set(ITableAttributes.ATTR_CELL_U_PADDING_BOTTOM, 5);
        attrs.set(ITableAttributes.ATTR_CELL_PADDING_TOP, 10);
        attrs.set(ITableAttributes.ATTR_CELL_PADDING_BOTTOM, 5);
        attrs.set(ITableAttributes.ATTR_CELL_VERT_ALIGN_CENTER);
        
        
        RtfAttributes atr = new RtfAttributes();
        atr.set(ITableAttributes.CELL_BORDER_TOP, attrs)
                        .set(ITableAttributes.CELL_BORDER_BOTTOM, attrs)
                        .set(ITableAttributes.CELL_BORDER_LEFT, attrs)
                        .set(ITableAttributes.CELL_BORDER_RIGHT, attrs)
                        .set(ITableAttributes.ATTR_CELL_PADDING_TOP, attrs)
                        .set(ITableAttributes.ATTR_CELL_PADDING_BOTTOM, attrs)
                        .set(ITableAttributes.ATTR_CELL_VERT_ALIGN_CENTER, 
attrs);

        tbl.setBorderAttributes(atr);
        RtfTableRow header = tbl.newTableRow();

        RtfTableCell hCol1 = header.newTableCell(INCH_TO_TWIPS*1);
        hCol1.getRtfAttributes().set(ITableAttributes.CELL_BORDER_TOP,
attrs)
                .set(ITableAttributes.CELL_BORDER_BOTTOM, attrs)
                .set(ITableAttributes.CELL_BORDER_LEFT, attrs)
                .set(ITableAttributes.CELL_BORDER_RIGHT, attrs)
                .set(ITableAttributes.ATTR_CELL_PADDING_TOP, attrs)
                .set(ITableAttributes.ATTR_CELL_PADDING_BOTTOM, attrs)
                .set(ITableAttributes.ATTR_CELL_U_PADDING_TOP, attrs)
                .set(ITableAttributes.ATTR_CELL_U_PADDING_BOTTOM, attrs)
                .set(ITableAttributes.ATTR_CELL_VERT_ALIGN_CENTER, attrs);
        hCol1.newParagraph().newText("GENE", attr_bold_center);
        RtfTableCell hCol2 = header.newTableCell(INCH_TO_TWIPS*2);
        hCol2.getRtfAttributes().set(ITableAttributes.CELL_BORDER_TOP,
attrs)
                .set(ITableAttributes.CELL_BORDER_BOTTOM, attrs)
                .set(ITableAttributes.CELL_BORDER_LEFT, attrs)
                .set(ITableAttributes.CELL_BORDER_RIGHT, attrs)
                .set(ITableAttributes.ATTR_CELL_PADDING_TOP, attrs)
                .set(ITableAttributes.ATTR_CELL_PADDING_BOTTOM, attrs)
                .set(ITableAttributes.ATTR_CELL_U_PADDING_TOP, attrs)
                .set(ITableAttributes.ATTR_CELL_U_PADDING_BOTTOM, attrs)
                .set(ITableAttributes.ATTR_CELL_VERT_ALIGN_CENTER, attrs);
        hCol2.newParagraph().newText("TRANSLATION", attr_bold_center);
        RtfTableCell hCol3 = header.newTableCell(INCH_TO_TWIPS*3);
        hCol3.getRtfAttributes().set(ITableAttributes.CELL_BORDER_TOP,
attrs)
                .set(ITableAttributes.CELL_BORDER_BOTTOM, attrs)
                .set(ITableAttributes.CELL_BORDER_LEFT, attrs)
                .set(ITableAttributes.CELL_BORDER_RIGHT, attrs)
                .set(ITableAttributes.ATTR_CELL_PADDING_TOP, attrs)
                .set(ITableAttributes.ATTR_CELL_PADDING_BOTTOM, attrs)
                .set(ITableAttributes.ATTR_CELL_U_PADDING_TOP, attrs)
                .set(ITableAttributes.ATTR_CELL_U_PADDING_BOTTOM, attrs)
                .set(ITableAttributes.ATTR_CELL_VERT_ALIGN_CENTER, attrs);
        hCol3.newParagraph().newText("TRANSCRIPT", attr_bold_center);
        
        for (int row = 0; row < MAX_ROW; row++) {
            RtfTableRow r=tbl.newTableRow();

            RtfTableCell col1 = r.newTableCell(INCH_TO_TWIPS*1);
            col1.getRtfAttributes().set(ITableAttributes.CELL_BORDER_TOP,
attrs)
                .set(ITableAttributes.CELL_BORDER_BOTTOM, attrs)
                .set(ITableAttributes.CELL_BORDER_LEFT, attrs)
                .set(ITableAttributes.CELL_BORDER_RIGHT, attrs);
            col1.newParagraph().newText("SLC26A2", attr_tbl_center);
            
            RtfTableCell col2 = r.newTableCell(INCH_TO_TWIPS*2);
            col2.getRtfAttributes().set(ITableAttributes.CELL_BORDER_TOP,
attrs)
                .set(ITableAttributes.CELL_BORDER_BOTTOM, attrs)
                .set(ITableAttributes.CELL_BORDER_LEFT, attrs)
                .set(ITableAttributes.CELL_BORDER_RIGHT, attrs);
            col2.newParagraph().newText("p.Thr689Ser", attr_tbl_center);
            
            RtfTableCell col3 = r.newTableCell(INCH_TO_TWIPS*3);
            col3.getRtfAttributes().set(ITableAttributes.CELL_BORDER_TOP,
attrs)
                .set(ITableAttributes.CELL_BORDER_BOTTOM, attrs)
                .set(ITableAttributes.CELL_BORDER_LEFT, attrs)
                .set(ITableAttributes.CELL_BORDER_RIGHT, attrs);
            col3.newParagraph().newText("ENST00000286298", attr_tbl_center);
        }
    }

Thanks again for your kind help.

Sreejith



--
View this message in context: 
http://apache-fop.1065347.n5.nabble.com/Formatting-a-RtfTable-using-RTFLib-tp40808p40822.html
Sent from the FOP - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org

Reply via email to