I am using this option to download the pdf format of the kendo diagram control. How can I add the language options, to download the PDF in different languages?
/Kumeri.
1 Answer, 1 is accepted
0
Nikolay
Telerik team
answered on 27 Feb 2025, 07:40 AM
Hi Kumeri,
When generating a PDF using Kendo Drawing (kendo.drawing.PDFOptions), the language is typically determined by the content inside the diagram, rather than a specific PDF setting. However, if you need to support multiple languages for your PDF export, you can achieve this in the following ways:
- Change Diagram Text Before Export
If your Kendo Diagram has text elements, you can dynamically update the text before exporting.
Example: Changing Text to a Different Language Before PDF Export
functionexportDiagramPDF(language) {
var diagram = $("#diagram").data("kendoDiagram");
// Example: Translate node texts based on selected languagevar translations = {
en: { node1: "Start", node2: "Process", node3: "End" },
fr: { node1: "Début", node2: "Processus", node3: "Fin" },
es: { node1: "Inicio", node2: "Proceso", node3: "Fin" }
};
// Update diagram text
diagram.shapes.forEach(function (shape, index) {
var textBlock = shape.content; // Get text content of shapeif (textBlock) {
textBlock.text(translations[language][`node${index + 1}`]); // Update text
}
});
// Redraw the diagram
diagram.refresh();
// Export to PDF
kendo.drawing.drawDOM($("#diagram")).then(function (group) {
kendo.drawing.pdf.saveAs(group, `Diagram_${language}.pdf`);
});
}
// Example: Export in French
exportDiagramPDF("fr");
- Create Multiple Language Versions of the Diagram
If you have static content and want to offer PDFs in multiple languages without modifying the diagram dynamically, you can predefine different versions of your diagram in various languages and switch before exporting.