if (!ErrorMessage)
{
try
{
PdfPTable pTable = new PdfPTable(Dgv6.Columns.Count);
pTable.DefaultCell.Padding = 3;
pTable.WidthPercentage = 150;
pTable.HorizontalAlignment = Element.ALIGN_LEFT;
foreach (DataGridViewColumn col in Dgv6.Columns)
{
PdfPCell pCell = new PdfPCell(new Phrase(col.HeaderText));
pTable.AddCell(pCell);
}
foreach (DataGridViewRow ViewRow in Dgv6.Rows)
{
foreach (DataGridViewCell dcell in ViewRow.Cells)
{
pTable.AddCell(dcell.Value.ToString());
}
}
using (FileStream fileStream = new FileStream(save.FileName, FileMode.Create))
{
//Document document = new Document(PageSize.A4, 8f, 16f, 16f, 8f);
Document document = new Document(PageSize.A4, 10.10f, 10.10f, 10.10f, 0.0f);
PdfWriter.GetInstance(document, fileStream);
document.Open();
document.Add(pTable);
document.Close();
fileStream.Close();
File_Prn = fileStream.Name;
}.
New contributor
Nick is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1