I have a problem and I can not find a solution, I'm using itextesharp in a windowsfroms application, I've created a table with 7 cells and I would like to align some right and others centered. unfortunately I can only align all the cells to the right or the left. through the table.DefaultCell.HorizontalAlignment = 0; I'll post the code. Thank you in advance for your help.
PdfPTable tabela = new PdfPTable(7);
PdfPCell celula = new PdfPCell();
tabela.TotalWidth = 790f;
// celula.HorizontalAlignment = 1;
tabela.DefaultCell.HorizontalAlignment = 0;
tabela.LockedWidth = true;
float[] widths = new float[] { 16F, 40f,45F,60F,15f, 15f, 15f };
tabela.SetWidths(widths);
tabela.HorizontalAlignment = 0;
celula.HorizontalAlignment = 0;
strSql= " ";
con = new SqlConnection(strcon);
SqlCommand cmd2 = new SqlCommand(strSql, con);
cmd2.Parameters.AddWithValue("@DataI", DateTime.Parse(mtbDtInicial.Text));
cmd2.Parameters.AddWithValue("@DataF", DateTime.Parse(mtbDtFinal.Text));
cmd2.Parameters.AddWithValue("@ifd", emn1);
con.Open();
SqlDataReader ler = cmd2.ExecuteReader();
while (ler.Read())
{
tabela.AddCell (ler[4].ToString()); //conta a direita
tabela.AddCell(ler[0].ToString());//título a direita
tabela.AddCell(ler[1].ToString());//subtitulo a direita
tabela.AddCell(ler[2].ToString());//descr a direita
tabela.AddCell(ler[6].ToString());//valor centralizado
tabela.AddCell(ler[7].ToString());//perce centralizado
tabela.AddCell(ler[8].ToString());//desp centralizado
}
document2.Add(tabela);