Exporting grid to PDF with őű characters

Hi!


I'm trying to export my grid content to .pdf using the built-in grid.pdfExport(); function. It is working fine, but when the grid data contains an 'ő' or 'ű' character in any of the cells, the export throws an error: "Uncaught (in promise)".


I'm using the standard export functions from the toolbar:


grid.toolbarClick = function(args) {

    if (args['item'].id === 'ej2grid_excelexport') {

        grid.excelExport();

    }

    if (args['item'].id === 'ej2grid_pdfexport') {

        grid.pdfExport();

    }

}


The grid's config:


var grid = new ej.grids.Grid({

    allowSorting: '1',

    allowFiltering: '1',

    allowPaging: '1',

    pageSettings: { pageSize: 3 },

    dataSource: data,

    columns: ...,

    filterSettings: {

        mode: 'Immediate',

        enableCaseSensitivity: true

    },

    allowExcelExport: '1',

    allowPdfExport: '1',

    toolbar: JSON.parse('["ExcelExport","PdfExport"]'),

    queryCellInfo: setButtonColumn,

    allowTextWrap: true

});


Do I have to set something else?


Thank you!


3 Replies 1 reply marked as answer

RR Rajapandi Ravi Syncfusion Team February 23, 2021 12:28 PM UTC

Hi Kulcsár, 

Greetings from syncfusion support 

We have analyzed your query and we could see that you like to use your custom font characters in the Grid and also export the same in pdf document. The mentioned problem is reproduced when we used custom character in grid (header, content) which is not supported by the default fonts.  

To change the default font of Grid header, content and caption cells in the exported document we suggest you to use ‘theme’ property of PdfExportProperties property. Please refer the below code example, sample and documentation for more information.  

 
let grid: Grid = new Grid( 
        { 
            dataSource: orderDetails, 
            allowExcelExport: true, 
            allowPdfExport: true, 
            allowPaging: true, 
            toolbar: ['PdfExport'], 
            pageSettings: { pageCount: 5 }, 
            columns: [ 
                .  .  .  .  .  .  .  . 
                .  .  .  .  .  .  .  . 
            ] 
        }); 
    grid.appendTo('#Grid'); 
    grid.toolbarClick = (args: ClickEventArgs) => { 
        if (args.item.id === 'Grid_pdfexport') { 
           let pdfExportProperties = {  
                theme: {  
                    header: { font: new PdfTrueTypeFont(adventProFont, 12) },  
                    caption: { font: new PdfTrueTypeFont(adventProFont, 10) },  
                    record: { font: new PdfTrueTypeFont(adventProFont, 9) }  
                }  
            };  
            grid.pdfExport(pdfExportProperties); 
        } 
    }; 
 
 



Screenshot: 

 

Note: PdfTrueTypeFont accepts base 64 format of the Custom Font. 

Regards, 
Rajapandi R 


Marked as answer

KN Kulcsár Norbert February 24, 2021 10:07 AM UTC

Hi Rajapandi!

I have changed the font, and the export function is working with the Hungarian characters too.

Thank you!


RR Rajapandi Ravi Syncfusion Team February 25, 2021 05:11 AM UTC

Hi Kulcsár, 

Thanks for the update. 

We are happy to hear that the provided solution was helpful to achieve your requirement. 

Please get back to us if you need further assistance. 

Regards, 
RajapandiR 


Loader.
Up arrow icon