Grid's pdf export using custom true type font.

Hi,

I am having problem exporting data containing non English characters from Blazor grid to pdf file.


Uncaught (in promise) Error: ArgumentOutOfRangeException:index, The character is not supported by the font.
    at t.items (constants.js:93)
    at t.getCharWidthInternal (constants.js:93)
    at t.getLineWidth (constants.js:93)
    at e.getLineWidth (constants.js:93)
    at e.layoutLine (constants.js:93)
    at e.doLayout (constants.js:93)
    at e.layout (constants.js:93)
    at e.measureHeight (constants.js:93)
    at e.get [as height] (constants.js:93)
    at e.measureHeight (constants.js:93)


My preferred font is:

I would like to request an example implementing said font to PdfExportProperties.

Thanks ahead.

1 Reply

VN Vignesh Natarajan Syncfusion Team February 21, 2020 07:32 AM UTC

Hi Natchathat,  

Greetings from Syncfusion support.  

Query: “I would like to request an example implementing said font to PdfExportProperties.” 

We are able to reproduce the reported issue at our end. Since it is known issue, we have already logged a defect report “Provide PdfTrueTypeFont support in PdfExport method” for the same. Fix for the issue will be included in our next Bi- Weekly release which is expected to be rolled out on or before February 26, 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.   
 
 
Once above issue is resolved you can define the PdfTrueTypeFont as true in PdfExportProperties (like below). And also you can define the FontFamily as Sarabun by defining it in form of base64string.  
 
Refer the below code example.  
 
<EjsButton OnClick="PdfExport" Content="Pdf Export"></EjsButton> 
<EjsGrid @ref="DefaultGrid" DataSource="@Orders" AllowSorting="true" AllowPdfExport="true" AllowPaging="true"> 
. . . . 
</EjsGrid> 
 
@functions{ 
   . . . . . .. .  
  
    public void PdfExport() 
    { 
        PdfExportProperties ExportProperties = new PdfExportProperties(); 
        PdfTheme Theme = new PdfTheme(); 
        PdfThemeStyle RecordThemeStyle = new PdfThemeStyle() 
        { 
            FontColor = "#64FA50", 
            FontName = "Calibri", 
            FontSize = 17, 
            Font = new PdfGridFont() { IsTrueType=true, FontFamily = /*you fonts famiy in form of base64string*/ }  
        }; 
        Theme.Record = RecordThemeStyle;  
        ExportProperties.Theme = Theme; 
        this.DefaultGrid.PdfExport(ExportProperties); 
    } 
} 

  
Till then we appreciate your patience.   

Regards, 
Vignesh Natarajan.

Loader.
Up arrow icon