This code working fine
In line 7 and 8 are aligment for complete columns in table
How to set up each column alignment?
First column center, second column left, third column right
//Adding Header row
foreach (DataGridViewColumn column in ItemsDataGridView.Columns)
{
PdfPCell cell = new PdfPCell(new Phrase(column.HeaderText, calibri10bold3));
cell.HorizontalAlignment = Element.ALIGN_CENTER;
cell.VerticalAlignment = Element.ALIGN_CENTER;
cell.BackgroundColor = new iTextSharp.text.BaseColor(243, 70, 5);
pdfTable.AddCell(cell);
}
Amit MohantyPosted Jul 19, 2022, 9:28 AM
Goran BibicPosted Jul 19, 2022, 9:44 AM
This is ok, how to apply on rows?
//Adding DataRow
foreach (DataGridViewRow row in ItemsDataGridView.Rows)
{
foreach (DataGridViewCell cell in row.Cells)
{
PdfPCell cell2 = new PdfPCell(new Phrase(cell.Value.ToString(), calibri));
cell2.HorizontalAlignment = Element.ALIGN_RIGHT;
pdfTable.AddCell(cell2);
}
}