How to export a word document in landscape format with jquery word export?

41 Views Asked by At

Im trying to export a word document in landscapte format due to i have a table with 10 columns and they don fit well, so i want to change the orientation of the page of the word document.

i tried with this:

<style>
    @@page { size: landscape; }
</style>

it only works with the print functionality but i want it to work with word export functionality im using jquery word export, in a proyect asp.net framework 4.7.2

here's what i have now:

    $("#btnExportarAWord").on("click", function () {
        // Convertir la imagen existente a base64
        var img = $("#imgRHE");
        var imgURL = img.attr('src');

        toDataURL(imgURL).then(dataUrl => {
            img.attr('src', dataUrl);

            // Obtener SVG del gráfico
            var chart = $('#chartHistoricoEvaluaciones').highcharts();

            ObtenerSVGHighcharts(chart).then(svg => {
                // Convertir SVG a base64
                var svgDataURL = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(svg)));

                // Crear un nuevo elemento img en tu página con el gráfico convertido
                var chartImage = $('<img>').attr('src', svgDataURL).attr('id', 'tempChartImg');

                // Añadir la imagen al final de #reportHistoricoEval antes de exportar
                $("#reportHistoricoEval").append(chartImage);
                $("#chartHistoricoEvaluaciones").hide();
                // Espera a que la imagen se cargue
                EsperarCargaDeImagen(chartImage).then(() => {
                    // Exportar a Word
                    $("#reportHistoricoEval").wordExport("ReporteEvaluaciones");
                    $("#chartHistoricoEvaluaciones").show();
                    // Eliminar la imagen base64 del gráfico del div
                    $("#tempChartImg").remove();

                }).catch(error => {
                    console.error("There was an issue:", error);
                });
            });
        });
    });
0

There are 0 best solutions below