Embed RadHtmlChart in PDF on the Server Side
The most straightforward way to export RadHtmlChart is to do it client-side as the control renders entirely in the browser. Exporting RadHtmlChart to PDF on the server side, though, requires that first the SVG rendering of the chart is transferred to the server. In this article, you will find different options to export RadHtmlChart to PDF on the server so you can choose the one that fits your scenario the best:
Export RadHtmlChart via RadPDFProcessing
By utilizing the RadPdfProcessing API you can easily create a document containing the RadHtmlChart control by rendering it as an image, generated by the canvas object of the control. You can watch a live demo demonstrating this approach: Export RadHtmlChart to PDF sever-side via RadPdfProcessing.
Export RadHtmlChart via Telerik Reporting
You can also export the RadHtmlChart loaded on the page to a Telerik report, which is processed and rendered on the server. In order to achieve this you will need to save the loaded on the page chart as an
byte on the server, which allows you to load it in a PictureBox item afterwards. A similar approach incorporating the Kendo UI Chart widget is demonstrated in this code library:
Display Telerik Kendo UI Chart in a Telerik Reporting PictureBox item.
Another possible way to embed RadHtmlChart in a Telerik Reporting document is to load the passed to the server chart image through a user function: Telerik Reporting User Functions.
Export RadHtmlChart via Third-party Library
You can also export RadHtmlChart by using a third party library (like InkScape) that can convert the chart’s SVG image to a more common user format such as PNG or PDF. A code library showing how to achieve this is available here: Export RadHtmlChart to PDF server-side via third-party library.
Generate and Export RadHtmlChart Entirely Sever Side
As stated in the beginning of the article, RadHtmlChart is rendered on the client side, so you will need to render it in a browser in order to capture the control’s SVG data and pass it to the server. Whether you open this browser on the client machine and send the image/svg
base64 string to the server or you open the browser on the server (and use other scripts and tools to save the image), is the same.
There are several tools (like Phantom.js) that can be used in order to load the chart in a virtual browser and export it to PDF directly, avoiding the visible browser rendering of the control.