i am creating C# Application in which i am using external class to print dataGridView
. with this class i am able to print document pdf but i am unable to save the file to disk. i know this can be achieved by printDocument1.PrinterSettings.PrintToFile=true
and printDocument1.PrinterSettings.PrintFileName = path
but as i mentioned that i am using external class for that i am not able to do that. i am posting code that i am using to print the grid and the link to external class is also posted. please help me how to adjust this according to my need
DGVPrinter printer = new DGVPrinter();
//if (tbReportSchoolName.Text == string.Empty)
//{
printer.Title = "The Punjab School";
//}
//else { printer.Title = tbReportSchoolName.Text.Trim(); } //school name
//if (tbReportHeader.Text == string.Empty)
//{
printer.SubTitle = "Absent Student Report | " + dtpTo.Value.ToShortDateString();
//}
//else { printer.SubTitle = tbReportHeader.Text.Trim() + "|" + dtpTo.Value.ToShortDateString(); }
printer.SubTitleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip;
printer.PageNumbers = true;
printer.PageNumberInHeader = false;
printer.PorportionalColumns = true;
printer.HeaderCellAlignment = StringAlignment.Near;
//if (tbReportFooter.Text == string.Empty)
//{
printer.Footer = "Allied School, A Project of Punjab Group of Colleges.";
//}
//else { printer.Footer = tbReportFooter.Text.Trim(); }
printer.FooterSpacing = 15;
printer.PrintDataGridView(reportGrid);
Class name is DGVPrinter and grid name is dgv Link to class:
https://drive.google.com/file/d/0BwBxpfm3kmmgci1aSnZ6T0RudGc/view