Images are shown rotated in documentEditor

Good day,

I'm facing an issue where a .docx file that contains embedded images shows them rotated 90 degrees in the js document editor.

If I open the same file with MS Word, the images are shown in their original, unrotated form. I attached a 3-page sample file to show the problem.

I'm using the latets Syncfusion.EJ2.Javascript package v.19.1.0.59

Is this a bug or I'm missing something?
Thank you!
Alex



Attachment: Test_Image_Rotated_6325a8c8.zip

7 Replies 1 reply marked as answer

SM Suriya Murugan Syncfusion Team May 13, 2021 05:50 AM UTC

Hi Alejandro, 

Syncfusion Greetings! 

Currently, Documenteditor doesn’t have support for image rotation feature. We have already logged the feature request for this. We will implement it in any of our upcoming release. We will update the status of the feedback link once it is taken for implementation. We will update you once feature implemented. You can also track the feature status from below link.  


Regards, 
Suriya M. 



AL Alejandro May 13, 2021 10:46 AM UTC

Hello Suriya,

Thank you for your prompt reply.

I understand that document editor does not have support for image rotation yet, and I'm not asking whether rotating an image in the editor is possible.

I'm asking whether the images are shown rotated:
a) because of a bug in the component?
or 
b) because they're indeed rotated inside the .docx and MS word shows them as they were at 0 degrees because of some microsoft page setup or anything else?

Thanks again
Alex





SM Suriya Murugan Syncfusion Team May 14, 2021 06:25 AM UTC

Hi Alejandro, 

In provided document, image is rotated in 90 degree. Please check below table for reference: 

 
 


Documenteditor component doesn’t have support for this feature. So, it render in zero degree. 

 
 


Please let us know if you have any questions. 

Regards, 
Suriya M. 


Marked as answer

AL Alejandro May 14, 2021 11:07 AM UTC

Hello Suriya, 

My bad for not checking that screen in Word.

You've been very helpful, thank you very much!

Have a good day
Alex




SM Suriya Murugan Syncfusion Team May 17, 2021 04:10 AM UTC

Hi Alejandro, 

Thanks for your update. 

Regards, 
Suriya M. 



RL Remi Lebegue October 21, 2024 08:47 AM UTC

For someone need a solution to this Issue i have do this and its work perfec for me :


In my context i create an File Upload in my form, for dowload multiple image at same time and resize it to a custom height with this method :


Html & Razor :

<div class="col-3">

@Html.Label("Importation des Images", "Importation des Images", new { @class = "form-label" })

<br />

<input type="file" id="insertImageButton" class="form-control-sm" accept=".jpg,.jpeg,.png,.bmp,.svg" multiple />

</div>

<div class="col-3">

@Html.Label("Hauteur des images", "Hauteur des images", new { @class = "form-label" })

<br />

@Html.TextBox("ImageMaxHeight", 220, new { @class = "form-control" })

</div>


Jquery :

document.getElementById("insertImageButton").addEventListener('change', onInsertImage);


function onInsertImage(args) {

    ImportImages = $(this)[0].files;

    for (var key in ImportImages) {

        if (typeof (ImportImages[key]) === 'object') {

            var path = ImportImages[key];

            LoadFileReader(path, "" + key);

        }

    }

}

function LoadFileReader(path, index) {

    var reader = new FileReader();

    reader.onload = function (frEvent) {

        RotateImage90RightAndResize(frEvent, index);

    };

    reader.readAsDataURL(path);

}

function RotateImage90RightAndResize(frEvent, index) {


    var base64data = frEvent.target.result;


    var image = document.createElement('img');

    image.setAttribute('crossorigin', 'anonymous');


    var heightMax = 220; // default resized Height

    //widthMax 172 //if necessary the same its possible with the Width


    var ImageMaxHeight = $("#ImageMaxHeight") //this is my textbox on my form

    if (ImageMaxHeight.length > 0) {

        var tmpHeight = ImageMaxHeight.val();

        if (tmpHeight > 0) {

            heightMax = tmpHeight;

        }

    }


    image.addEventListener('load', function () {

//Here we create a canvas an we rotate the image to 90° right to resolved the issue

        var offScreenCanvas = document.createElement('canvas');

        offScreenCanvasCtx = offScreenCanvas.getContext('2d');

        offScreenCanvas.height = image.height;

        offScreenCanvas.width = image.width;


        offScreenCanvasCtx.drawImage(image, 0, 0, image.width, image.height);

        offScreenCanvasCtx.save();

        offScreenCanvasCtx.translate(offScreenCanvas.width / 2, offScreenCanvas.height / 2)

        offScreenCanvasCtx.rotate(90 * Math.PI / 180);

        offScreenCanvasCtx.translate(-offScreenCanvas.width / 2, -offScreenCanvas.height / 2)

        offScreenCanvasCtx.restore();


        var ratio = heightMax / this.height

        var height = this.height * ratio;

        var width = this.width * ratio;


        var base64Canvas = offScreenCanvas.toDataURL("image/jpeg"); //If an Issue the image are Full Black or Error Icon

//Sending the image rotated to the DocumentEditor and insert it.

        LoadImageOnDocEditor(base64Canvas, width, height, index);

    });

    image.src = base64data;

}

function LoadImageOnDocEditor(base64Canvas, width, height, index) {

    var documenteditorElement = document.getElementById('DocumentEditor');

    container = documenteditorElement.ej2_instances[0];

    documenteditor = container.documentEditor;

    documenteditor.editor.insertImage(base64Canvas, width, height);

    documenteditor.editor.insertText("\t");

}


Regard



AD Aravind Dharani Syncfusion Team October 22, 2024 06:47 AM UTC

Hi,


Thanks for your update. 


Regards, 
Aravind D

Loader.
Up arrow icon