PdfExportingOptions GridPdfExportingOptions = new(); private PdfExportingOptions PdfExportingOptions() { SkipColumns(); return GridPdfExportingOptions; }
private void SkipColumns() { if (ChkAddress.Checked) { GridPdfExportingOptions.ExcludeColumns.Add("Address"); } }
private void Export_Click (object sender, EventArgs e) { var document = new PdfDocument(); document.PageSettings.Orientation = PdfPageOrientation.Landscape; var page = document.Pages.Add(); var PDFGrid = DGV_Student.ExportToPdfGrid( DGV_Student .View, PdfExportingOptions()); var format = new PdfGridLayoutFormat() { Layout = PdfLayoutType.Paginate, Break = PdfLayoutBreakType.FitPage }; PDFGrid.Draw(page, new PointF(), format); SaveFileDialog saveFileDialog = new SaveFileDialog { Filter = "PDF Files(*.pdf)|*.pdf" }; if (saveFileDialog.ShowDialog() == DialogResult.OK) { using (Stream stream = saveFileDialog.OpenFile()) { document.Save(stream); } } } |