We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Column size when exported to PDF

Thread ID:

Created:

Updated:

Platform:

Replies:

140995 Nov 17,2018 08:01 PM UTC Nov 22,2018 06:42 AM UTC Xamarin.iOS 3
loading
Tags: SfDataGrid
Michael
Asked On November 17, 2018 08:01 PM UTC

Hi,

I'm exporting my grid to PDF. I have one column in the center of the grid wich seperates the grid in a left and right half. This column is just 20px wide.
If I now export this grid in the following way:

            DataGridPdfExportingController pdfGridExport = new DataGridPdfExportingController();
            DataGridPdfExportOption exportOption = new DataGridPdfExportOption
                                                   {
                                                       FitAllColumnsInOnePage = true,
                                                       PdfDocument            = pdfDoc,
                                                       StartPoint                  = new PointF(0, currentYPos),
                                                       ApplyGridStyle         = true,
                                                       AutoFitRowHeight   = true,
                                                       RepeatHeaders          = true
                                                   };

            pdfGridExport.ExportToPdf(_grid, exportOption);

All columns are then evenly spreaded over the page. But I want to set that "seperator column" to a very small size and only the rest should be spread.
If I set FitAllColumnsInOnePage=false the original size of all columns are retained which is good but then the whole grid doesn't fit to the page.

How can I set one specific column to a certain width and at the same time let the grid fit to the page?

Regards
Michael

Vigneshkumar Ramasamy [Syncfusion]
Replied On November 19, 2018 07:29 AM UTC

Hi Michael,  
 
Thanks for contacting Syncfusion Support.  
 
We checked your query and your requirement to export the columns for the given width can be achieved by usingDataGridPdfExportOption.ExportColumnWidth. Please refer the below UG for more details on exporting with ColumnWidth.  
 
 
   
 
Regards,  
Vigneshkumar R 


Michael
Replied On November 21, 2018 04:54 PM UTC

Hi Vigneshkumar,

thanks for your help, but that doesn't work.

If I set your suggested option:
DataGridPdfExportOption exportOption = new DataGridPdfExportOption
                                                   {
                                                       FitAllColumnsInOnePage = false,
                                                       PdfDocument            = pdfDoc,
                                                       StartPoint                  = new PointF(0, currentYPos),
                                                       ApplyGridStyle         = true,
                                                       AutoFitRowHeight   = true,
                                                       RepeatHeaders          = true,
                                                       ExportColumnWidth = true
                                                   };
the columns are exported with their original width, but then the grid doesn't fit on the page!

If I set FitAllColumnsInOnePage = true and ExportColumnWidth = true
the exportcolumnwidth option is ignored.

I want either that all columns are fit to the page with their original width relation or I want to set one specific column to a certain size only for the export.

Is this possible?

Thanks
Michael



Vigneshkumar Ramasamy [Syncfusion]
Replied On November 22, 2018 06:42 AM UTC

Hi Micheal,  
  
Thanks for your update.   
  
Your requirement “to set one specific column to a certain size only for the export” can be achieved by usingDataGridPdfExportingController.RowExporting event. Please find the code snippet of the same below.  
  
DataGridPdfExportingController pdfExport = new DataGridPdfExportingController();  
pdfExport.RowExporting += PdfExport_RowExporting;  
  
private void PdfExport_RowExporting(object sender, DataGridRowPdfExportingEventArgs e)  
{  
    e.PdfGrid.Columns[2].Width = 200;  
}  
  
We have prepared the sample based on your requirement, you can download the same from the below link.  
 
  
Regards,  
Vigneshkumar R   


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;