This is a migrated thread and some comments may be shown as answers.

Export to PDF have problem with polish chars

3 Answers 397 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Janusz
Top achievements
Rank 1
Janusz asked on 23 Jan 2015, 10:44 AM
From the version 2014.3.1119 we have got export to PDF.  This feature is really nice, but I cannot find a way to correctly display polish charactes in PDF. Probably in other languages it will be the same. Export to Excel from then same place works fine. I've tried on your demo (Kendo.Mvc.Demo) changing unit pdf_export.cshtml. below is the changed code and the screens.
[code]@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.EmployeeViewModel>()
.Name("grid")
.HtmlAttributes(new { style = "width: 900px; font-family: Arial Unicode MS" })
.Columns(columns =>
{
columns.Bound(e => e.EmployeeID).Width(140).Title("Zdjęcie");
columns.Bound(e => e.Title).Width(400).Title("Szczegóły");
............................
.ToolBar(tools => tools.Pdf())
.Pdf(pdf => pdf
.FileName("Kendo UI Grid Export.pdf")
.ProxyURL(Url.Action("Pdf_Export_Save", "Grid"))
)
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("Pdf_Export_Read", "Grid"))
)
..............................[/code]
Controler I've reminded unchanged. In webbrowse as well as in PDF Complete (and other pdf viewers) the polish characters are display wrong. Export to XLS  is OK. Is it possible in MVC to change default font name only for export to PDF.

3 Answers, 1 is accepted

Sort by
0
Janusz
Top achievements
Rank 1
answered on 23 Jan 2015, 01:59 PM
Meanwhile I've found a solution. 
...............................
<script>
    kendo.pdf.defineFont({
        "Verdana": "@Url.Content("~/Content/fonts/verdana.ttf")",
        "Verdana|Bold": "@Url.Content("~/Content/fonts/verdanab.ttf")",
        "Verdana|Bold|Italic": "@Url.Content("~/Content/fonts/verdanaz.ttf")",
        "Verdana|Italic": "@Url.Content("~/Content/fonts/verdanai.ttf")"
    });
</script>
..........................
0
Janusz
Top achievements
Rank 1
answered on 23 Jan 2015, 02:46 PM
Second solution is using CSS attribute @font-face like below.
...................
@font-face {
    font-family: "Segoe UI";
    src: url("fonts/segoeui.ttf") format("truetype");
}

@font-face {
    font-family: "Segoe UI";
    src: url("fonts/segoeuib.ttf") format("truetype");
    font-weight: bold;
}

@font-face {
    font-family: "Segoe UI";
    src: url("fonts/segoeuii.ttf") format("truetype");
    font-style: italic;
}

@font-face {
    font-family: "Segoe UI";
    src: url("fonts/segoeuiz.ttf") format("truetype");
    font-weight: bold;
    font-style: italic;
}
................
And ensure that kendo grid uses the proper font.
...............
    .k-grid {
        font-family: "Segoe UI", "Arial", sans-serif;
    }
...............
0
Kiril Nikolov
Telerik team
answered on 26 Jan 2015, 10:36 AM

Hello Janusz,

Yes, this is viable solution. The same is explained here as well:

http://docs.telerik.com/kendo-ui/framework/drawing/drawing-dom#custom-fonts-and-pdf

Regards,
Kiril Nikolov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Janusz
Top achievements
Rank 1
Answers by
Janusz
Top achievements
Rank 1
Kiril Nikolov
Telerik team
Share this question
or