Document doc = new Document(iTextSharp.text.PageSize.LETTER, 3, 3, 10, 5); PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream("C:\\Users\\J\\Desktop\\MBJ\\"+name+ext,FileMode.Create)); doc.Open(); table = new PdfPTable(dataGridView1.Columns.Count); table.WidthPercentage = 100; iTextSharp.text.Font font5 = iTextSharp.text.FontFactory.GetFont(FontFactory.TIMES_ROMAN, 4); par = new PdfPCell(new Phrase("CHARGE ACCOUNT OF CLIENTS CLIENT" + " " + name)); par.Colspan = dataGridView1.Columns.Count; par.HorizontalAlignment = 0; table.AddCell(par); //cell.AddElement(imgs); //table.AddCell(cell); foreach (DataGridViewColumn c in dataGridView1.Columns) { cell = new PdfPCell(new Phrase(new Chunk(c.HeaderText, font5))); cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; cell.VerticalAlignment = PdfPCell.ALIGN_LEFT; cell.BackgroundColor = new iTextSharp.text.BaseColor(240, 240, 240); table.AddCell(cell); } PdfPCell par1 = new PdfPCell(new Phrase("Duriation")); par1.Colspan = 2; par1.HorizontalAlignment = 0; table.AddCell(par1); if (dataGridView1.Rows.Count > 0) { for (int i = 0; i < dataGridView1.Rows.Count; i++) { PdfPCell[] objcell = new PdfPCell[dataGridView1.Columns.Count]; MemoryStream ms = new MemoryStream((byte[])dataGridView1.CurrentRow.Cells[16].Value); iTextSharp.text.Image imgs = iTextSharp.text.Image.GetInstance(ms); PdfPCell tempcell = new PdfPCell(); tempcell.Image = iTextSharp.text.Image.GetInstance(ms); for (int j = 0; j < dataGridView1.Columns.Count - 0; j++) { cell = new PdfPCell(new Phrase(dataGridView1.Rows[i].Cells[j].Value.ToString(), font5)); objcell[j] = cell; cell = new PdfPCell(); tempcell.Image.ScalePercent(10); } PdfPRow newrow = new PdfPRow(objcell); table.Rows.Add(newrow); table.AddCell(tempcell); } } doc.Add(table); doc.Close(); */ } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)