Goran Bibic

Goran Bibic

  • 455
  • 2.9k
  • 178k

Itextsharp pdf column setup c#

Jun 2 2018 1:04 PM
Some help
 
Sql column type is date
datagrid setup preview 19.09.2017
 
Datetimepicker format short value 19.09.2017
 
I need column  date 19.09.2017 00:00:00 setup just date 19.09.2017
  1. //Creating iTextSharp Table from the DataTable data  
  2.            //Console.WriteLine(kifDataGridView.ColumnCount); test za itext sharp  
  3.            PdfPTable pdfTable = new PdfPTable(kifDataGridView.ColumnCount);  
  4.            pdfTable.DefaultCell.Padding = 3;  
  5.            pdfTable.WidthPercentage = 100;  
  6.            pdfTable.HorizontalAlignment = Element.ALIGN_LEFT;  
  7.            pdfTable.DefaultCell.BorderWidth = 1;  
  8.   
  9.            float[] sirina = new float[] { 0f, 15f, 40f, 70f, 80f, 0f, 0f, 0f, 0f, 0f, 45f, 40f, 30f, 45f, 45f, 40f, 30f, 25f, 25f, 40f, 30f };  
  10.            pdfTable.SetWidths(sirina);  
  11.            BaseFont bfCalibri = BaseFont.CreateFont("c:\\windows\\fonts\\calibri.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);  
  12.            iTextSharp.text.Font calibri = new iTextSharp.text.Font(bfCalibri, 8);  
  13.            iTextSharp.text.Font calibri2 = new iTextSharp.text.Font(bfCalibri, 7, iTextSharp.text.Font.NORMAL, iTextSharp.text.BaseColor.WHITE);  
  14.   
  15.   
  16.   
  17.            //Adding Header row  
  18.            foreach (DataGridViewColumn column in kifDataGridView.Columns)  
  19.            {  
  20.                PdfPCell cell = new PdfPCell(new Phrase(column.HeaderText, calibri2));  
  21.                cell.BackgroundColor = new iTextSharp.text.BaseColor(243,70,5);  
  22.                pdfTable.AddCell(cell);  
  23.            }  
  24.   
  25.            //Adding DataRow  
  26.            foreach (DataGridViewRow row in kifDataGridView.Rows)  
  27.            {  
  28.   
  29.                foreach (DataGridViewCell cell in row.Cells)  
  30.                {  
  31.   
  32.                    PdfPCell cell2 = new PdfPCell(new Phrase(cell.Value.ToString(), calibri));  
  33.                    pdfTable.AddCell(cell2);  
  34.                }  
  35.            } 
 

Answers (7)