RadGrid export to PDF Fonts

6 posts, 1 answers
  1. Grigory
    Grigory avatar
    12 posts
    Member since:
    Nov 2011

    Posted 29 May 2012 Link to this post

    Hello ! I have RadGrid with PDF exporting button on my page. All fonts on the page are "SegoeUI" and in the RadGrid too, but when I export grid data to PDF document the fonts in the table becomes like "Times New Roman"..  

    Tryied to add styles to RawHtml on PdfExporting event but nothing happened. 
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 29 May 2012 Link to this post

    Hello Grigory,

    Try setting the font style in ItemCommand event as shown below.
    C#:
    void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {  
     if (e.CommandName == RadGrid.ExportToPdfCommandName)
     {
       foreach(GridDataItem item in RadGrid1.Items)
       {
         foreach (TableCell cell in item.Cells)
         {
            cell.Style["font-family"] = "Segoe UI";
         }
       }
     }
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Grigory
    Grigory avatar
    12 posts
    Member since:
    Nov 2011

    Posted 29 May 2012 Link to this post

    I have custom button and on the on click event I have grid1.MasterTableView.ExportToPdf() command.

    Tried to add this code block on button click event before ExportToPDF() but this didn't help me.
    Also tried to add this code to the ItemCreatedEvent but this didn't help me too.

    P.S. In RadGrid on my aspx page all is okay , all fonts are SegoeUI.
  5. Answer
    Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 29 May 2012 Link to this post

    Hello,

    Please try with below code snippet.

    <ExportSettings>
                    <Pdf DefaultFontFamily="YourFontName" />
                </ExportSettings>


    Thanks,
    Jayesh Goyani
  6. Grigory
    Grigory avatar
    12 posts
    Member since:
    Nov 2011

    Posted 29 May 2012 Link to this post

    Thanks a lot , this helped me .
  7. Travis
    Travis avatar
    3 posts
    Member since:
    Jun 2008

    Posted 01 Jul 2014 in reply to Jayesh Goyani Link to this post

    Hi Jayesh,

    I tried the below mentioned tips but still no luck to export to pdf with desired font family.

    1-

    <ExportSettings>
                        <Pdf DefaultFontFamily="Gill Sans MT" />
     </ExportSettings>

    2-

    <MasterTableView Font-Names="Gill Sans MT" >

    3-

    <style type="text/css">
        .rgMasterTable
        {
            font-family: Gill Sans MT !important;
        }
    </style>

    4-

    protected void btnpdfCard_Click(object sender, ImageClickEventArgs e)
        {
           
            foreach (GridDataItem item in rgExportGrid.Items)
            {
                item.Style["font-family"] = "Gill Sans MT";
              
            }
     }

    I am able to see the correct font in browser and export to excel. But when exported to PDF, it sets the font to like Times New Roman. Any idea, why I am not successful to export with "Gill Sans MT" pdf?

    Thanks in advance.


Back to Top
UI for ASP.NET Ajax is Ready for VS 2017