How to set header font style as bold for the header of the table in a pdf file, in jsf
- by Radhika
Hi
I have used PdfPTable to convert table data into a pdf file using
com.itextpdf.text.pdf.PdfPTable.
Table is displaying, but table data and the header are in same style.
To make difference i have to set the header font style to bold.
can anybody help me out in this,
I have attached my code here..
Thanks in advance
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import javax.faces.model.ListDataModel;
import com.mypackage.core.filter.domainobject.FilterResultDO;
import com.itextpdf.text.Font;
import com.itextpdf.text.FontFactory;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.pdf.PdfPTable;
public class PDFGenerator {
//This method will generate PDF for Filter Result Screen (only DataTable level)
@SuppressWarnings("unchecked")
public static PdfPTable generatePDF(PdfPTable table,List filterResultDOList ,List filterResultHeaderList )
{
//Initialize the table with number of columns required for the Datatable header
int numberOfFilterLabelCols = filterResultHeaderList.size();
//PDF Table Frame
table = new PdfPTable(numberOfFilterLabelCols);
//Getting Filter Detail Table Heading
for(int i = 0 ; i < numberOfFilterLabelCols; i++)
{
ColumnHeader commandHeaderObj = filterResultHeaderList.get(i);
table.addCell(commandHeaderObj.getLabel());
}
//Getting Filter Detail Data (Rows X Cols)
FilterResultDO filterResultDOObj = filterResultDOList.get(0);
List filterResultDataList = filterResultDOObj.getFilterResultLst();
int numberOfFilterDataRows = filterResultDataList.size();
//each row iteration
for(int row = 0; row < numberOfFilterDataRows; row++)
{
List filterResultCols = filterResultDataList.get(row);
int numberOfFilterDataCols = filterResultCols.size();
//columns iteration of each row
for(int col = 0; col < numberOfFilterDataCols ; col++)
{
String filterColumnsValues = (String) filterResultCols.get(col);
table.addCell(filterColumnsValues);
}
}
return table;
}//generatePDF
}