Welcome to the WinForms feedback portal. We’re happy you’re here! If you have feedback on how to improve the WinForms, we’d love to hear it!

  • Check out the features or bugs others have reported and vote on your favorites. Feedback will be prioritized based on popularity.
  • If you have feedback that’s not listed yet, submit your own.

Thanks for joining our community and helping improve Syncfusion products!

1
Vote

Exporting Grid Data to PDF via SFDATAGRID Control by using  Following Commands for All Visible Columns where Page Width of the PDF is as per all columns size is not working properly. 


Right Side Width of the Last Column has more margin. If In Grid I have 12 Columns, and generating this report for first time then example after last column it has 2 Inch Margin.  After that if you remove some Columns or Hide some columns and then export the data to PDF, the right side margin will change from 2 Inch to 5 Inch to 10 Inch.. 


It is not showing properly.


Following is Link where posted in forum

https://www.syncfusion.com/forums/139189/exporting-to-pdf


Codes received for the same :


double width = 0; 
foreach (var columns in sfDataGrid1.Columns) 
    width += columns.ActualWidth; 
 
PdfDocument document = new PdfDocument(); 
 
Graphics g = this.sfDataGrid1.CreateGraphics(); 
width = (float)width * 72 / g.DpiX; 
g.Dispose(); 
document.PageSettings.Width = (float)width;    
 
 
var pdfOptions = new PdfExportingOptions(); 
pdfOptions.FitAllColumnsInOnePage = false; 
pdfOptions.Exporting += pdfOptions_Exporting; 
var page = document.Pages.Add(); 
var PDFGrid = sfDataGrid1.ExportToPdfGrid(sfDataGrid1.View, pdfOptions); 
PDFGrid.Draw(page, new PointF());          


 

You are requested to please check it and do the needful.

Thanks