sfdatagrid pdfexport customize columns width

i´m triying to customize columns width when i export my sfdatagrid to pdf, but it seems imposible to me, if that´s not possible i could use original column size but proportional to the page width.


any of this options is possible??


thanks in advanced


4 Replies

SD Sethupathy Devarajan Syncfusion Team April 9, 2025 10:25 AM UTC

Hi Juan manuel,


You need to customize the column width when exporting your DataGrid to a PDF. You can achieve this using the CanExportColumnWidth  exporting option. We have defined the columns with different widths, and they exported correctly. We have shared a simple sample and exported document for your reference.

Ug Link:  CanExportColumnWidth

If you have any misunderstandings or if your needs differ, please provide clear details about your use case. You can include additional information regarding the expected behavior. This extra detail will enable us to thoroughly address your request and provide an appropriate solution.

Regards,
Sethupathy D.


Attachment: SfDataGridSample_4ae8b441.zip


JM juan manuel heredia gallardo April 11, 2025 04:50 PM UTC

i see your sample and columns appears fine in pdf, BUT, i want to see them on screen in a different size, your columns when execute app appears so small, and that´s the problem have a different size on screen and on pdf, it would acceptable if it was proportional, por example, 200 on screen is half on pdf.


thanks again



JM juan manuel heredia gallardo April 11, 2025 04:59 PM UTC

these are my options, to export pdf

DataGridPdfExportingOption option = new()

{

    CanFitAllColumnsInOnePage = true,

    CanRepeatHeaders = true,

    CanExportGroups = true,

    CanExportHeader = true,

    CanExportStackedHeaders = true,

    CanExportTableSummary = true,

    CanExportGroupSummary = true,

    CanApplyGridStyle = false,

    GridLineType = GridLineType.None,

    CanExportColumnWidth = true,

    CanExportSwitchColumnAsFormFields = true,


};

option.CanExportColumnWidth = true;

option.CanExportSwitchColumnAsFormFields = true;


you can see my screen, column looks cool


but my pdf is not good enough, there is so much space in paper to put email in 2 lines


Image_8072_1744390746390


Attachment: ExportFeature2_9b873652.pdf


SD Sethupathy Devarajan Syncfusion Team April 14, 2025 01:17 PM UTC

Hi Juan manuel,
 

The reason the export is not matching the output dataGrid result is because the dataGrid is rendered in a window where the width is greater than the height. When exported to an A4 sheet, the height is greater than the width, which is the reverse. With the setting fitAllColumnInOnePage = true, the columns' widths are shared evenly to fit all the columns on one page, which causes the email column to be truncated. This is the expected behavior of DataGrid exporting.


We can resolve your query by setting the page orientation to landscape; by default, it is portrait. We have shared the modified code snippet and a simple sample for your reference.


Regards.
Sethupathy D.



Attachment: SfDataGridSample_2c594e94.zip

Loader.
Up arrow icon