9 Answers, 1 is accepted
Client-side export to PDF is implemented. See this demo -- click the second button in the toolbar ("Export") and select PDF instead of XLSX.
However, I see that the API that allows to do that programmatically is not fully documented. You can use spreadsheet.saveAsPDF(options) to get the file; the options are documented here.
Regards,
Mihai
Telerik

Hello Mihai,
this demo works fine when I "click the second button in the toolbar ("Export") and select PDF instead of XLSX". However, it does not work every time if I use saveAsPDF() directly. Sometimes (I do not know why not every time) I just get an empty sheet (see attachment). It is more likely to get the empty sheet in Internet Explorer than in Edge. For saving as PDF I use the following code:
<div id="spreadsheet" style="width: 100%;"></div>
<button class="k-button k-primary" id="export_pdf" style="margin-top: 4em; float: left;">Export to PDF</button>
<script>
$(function() {
$("#export_pdf" ).kendoButton({
icon: "download"
});
$("#export_pdf").click(function(){
var kendoSpreadsheet = $("#spreadsheet").data("kendoSpreadsheet");
var firstSheet = kendoSpreadsheet.sheetByIndex(0);
kendoSpreadsheet.activeSheet(firstSheet);
kendoSpreadsheet.saveAsPDF({
area: "sheet",
fileName: "Printout.pdf",
fitWidth: true,
guidelines: true,
landscape: true,
hCenter: true,
paperSize: "A4"
});
});
What is the difference between using saveAsPDF() and clicking the second button in the toolbar ("Export") and selecting PDF instead of XLSX?
Thank you in advance!
Thank you for the code snippet and the “PrintOut.pdf” file. There is no difference in using saveAsPDF() vs Using the Export button in the toolbar and selecting PDF instead of XLSX. The export functionality in the toolbar is calling the saveAsPDF().
Based on the provided information, I would assume that the experienced issue is based on this issuе - #3525 logged in our official GitHub repository. Luckily the issue has been fixed and released with the today’s release of Kendo UI R2 2019.
Please, open this Dojo and try to reproduce the issue, you’ve reported. If everything is working fine, to avoid future unexpected behavior with the PDF export I would recommend to update the version of Kendo UI to 2019.2.514.
Regards,
Petar
Progress Telerik

Hi Petar,
Thank you very much! With the new version of Kendo UI the export to PDF is working fine.
After exporting to PDF the registered trade mark sign (®) is displayed as "fi" in the PDF-file. How can I export that sign correctly?
Thank you in advance!
The PDFexport needs to have access to the same fonts as the ones used by the browser to display the exportable content correctly. Based on the provided information I would assume that the PDFexport doesn’t have access to these fonts and this is why the trademark sign (®) is not displayed properly in the exported document. When there is no font set, the default one which is used for the generated document is one which uses only ASCII symbols. The trademark sign is not an ASCII symbol. More details about this issue could be read in this Pack Fonts for PDF Export article from our documentation. An example of how to apply a font for PDFexport could be found here: https://docs.telerik.com/kendo-ui/framework/drawing/drawing-dom#custom-fonts.
Looking forward to your reply.
Regards,
Petar
Progress Telerik

Hello Petar,
I tried packing fonts but it did not work. I checked also in the examples on the Kendo UI page. The server side PDF export there is working correctly (https://demos.telerik.com/kendo-ui/spreadsheet/server-side-pdf-export) but the client side export not (https://demos.telerik.com/kendo-ui/spreadsheet/events). I am not sure that the registered trademark sign is not an ASCII character. There are some ASCII tables containing the sign (https://theasciicode.com.ar/extended-ascii-code/registered-trademark-symbol-ascii-code-169.html). Can you change the example here https://demos.telerik.com/kendo-ui/spreadsheet/events to be able to export the sign ® ?
Kind regards,
Todor
Attached you will find a project based on the example you’ve linked.
What I've done is to add the following code in the example:
kendo.pdf.defineFont({
"DejaVu Sans"
:
"http://cdn.kendostatic.com/2019.2.619/styles/fonts/DejaVu/DejaVuSans.ttf"
,
"DejaVu Sans|Bold"
:
"http://cdn.kendostatic.com/2019.2.619/styles/fonts/DejaVu/DejaVuSans-Bold.ttf"
,
"DejaVu Sans|Bold|Italic"
:
"http://cdn.kendostatic.com/2019.2.619/styles/fonts/DejaVu/DejaVuSans-Oblique.ttf"
,
"DejaVu Sans|Italic"
:
"http://cdn.kendostatic.com/2019.2.619/styles/fonts/DejaVu/DejaVuSans-Oblique.ttf"
});
This approach is demonstrated in the link I previously sent but in the Header and Footer Templates section of the article.
I am sending this project in an attached file, not in Dojo because there are some restrictions in the Dojo which block the loading of the additional templates.
Looking forward to your reply.
Regards,
Petar
Progress Telerik

Hi,
I am happy to hear that! You are welcome!
Regards,
Petar
Progress Telerik