Grid export to PDF - Column width control

Hello

When exporting from a grid to PDF, is it possible to set the column widths in the exported PDF file. Currently the columns are exported with equal widths.

Thanks



5 Replies 1 reply marked as answer

RN Rahul Narayanasamy Syncfusion Team October 14, 2020 11:18 AM UTC

Hi Ditchford, 

Greetings from Syncfusion. 

Query: When exporting from a grid to PDF, is it possible to set the column widths in the exported PDF file. Currently the columns are exported with equal widths.  

We have validated the reported query and we are able to reproduce the reported behavior at our end. We have already confirmed it is a bug and logged the defect report for the same “All Column have same width in exported Pdf file irrespective to width define in GridColumn” . Thank you for taking the time to report this issue and helping us improve our product .Fix for the issue will be included in our weekly patch release which is expected to be rolled on or before end of October 2020.        
   
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.       
   
   
Till then we appreciate your patience.    

Regards, 
Rahul 



DI Ditchford October 15, 2020 02:35 AM UTC

Hello Raul

That's good to know.  Thank you. Just a follow up question,  Regardless of the column widths in the DataGrid is it possible to control the width of the columns in the exported PDF?

Thanks


LA Landy October 19, 2020 01:02 PM UTC

I'm also following this. I have the same requirement.


RN Rahul Narayanasamy Syncfusion Team October 20, 2020 02:11 PM UTC

Hi Ditchford & Landy, 

Thanks for the update . 

Query: Regardless of the column widths in the DataGrid is it possible to control the width of the columns in the exported PDF? 

We have validated your query and yes, you can also achieve this requirement once the above issue included. The fix for the issue will be included in our weekly patch release which is expected to be rolled on or before end of October 2020. 

Until then we appreciate your patience. 

Regards, 
Rahul 



RN Rahul Narayanasamy Syncfusion Team November 17, 2020 12:09 PM UTC

Hi Ditchford & Landy, 

We are glad to announce that our patch release 18.3.0.48 has been rolled out successfully and we have provided fix for “All Column have same width in exported Pdf file irrespective to width define in GridColumn” in this release. So kindly update your NuGet (Syncfusion.Blazor) to our latest version 18.3.0.48 to resolve the reported query. 

Please find the Nuget package from below 


DisableAutoFitWidth property of PdfExportProperties has to be enabled to achieve your requirement. Please find the below code snippet and the sample for your reference. 

@using Syncfusion.Blazor.Buttons 
@using Syncfusion.Blazor.Grids 
 
<SfButton OnClick="PdfExport" Content="Pdf Export"></SfButton> 
<SfGrid @ref="DefaultGrid" DataSource="@Orders" AllowPdfExport="true" AllowPaging="true"> 
    <GridColumns> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn> 
        <GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn> 
    </GridColumns> 
</SfGrid> 
 
@code{ 
 
    public async Task PdfExport() 
    { 
        PdfExportProperties ExportProperties = new PdfExportProperties(); 
        ExportProperties.DisableAutoFitWidth = true; 
//Below code is to customize the columns width for the pdf exported grid irrespective of the actual grid columns width 
        ExportProperties.Columns = new List<GridColumn>() 
        { 
                new GridColumn(){ Field="OrderID", HeaderText="Sprint Plan ID", TextAlign=TextAlign.Left, Width="300"}, 
                new GridColumn(){ Field="CustomerID", HeaderText="CustomerID", TextAlign=TextAlign.Left, Width="100"}, 
                new GridColumn(){ Field="OrderDate", HeaderText=" Date", TextAlign=TextAlign.Left, Width="80"} 
        }; 
        await this.DefaultGrid.PdfExport(ExportProperties); 
    } 
} 


We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.  

Regards, 
Rahul 


Marked as answer
Loader.
Up arrow icon