Multi language support for pdf export functionality

1 Answer 31 Views
Diagram Globalization
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Kumeri asked on 24 Feb 2025, 12:33 PM

kendo.drawing.PDFOptions

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

Sort by
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

function exportDiagramPDF(language) {
    var diagram = $("#diagram").data("kendoDiagram");

    // Example: Translate node texts based on selected language
    var 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 shape
        if (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.

$("#exportEnglish").click(function () {
    loadDiagram("en");
    exportDiagramPDF("en");
});

$("#exportFrench").click(function () {
    loadDiagram("fr");
    exportDiagramPDF("fr");
});

I hope this helps.

Regards,


Nikolay
Progress Telerik

Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!

Tags
Diagram Globalization
Asked by
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Answers by
Nikolay
Telerik team
Share this question
or