locked
Insert Html Canvas to Word RRS feed

  • Question

  • I created an apps for Office that has a canvas element. I would like to insert this canvas into Word document when a button is clicked. I use the following code. However, I have an "x" for the image in Word

     function setImageToDoc() {
                    var dataURL = circlecanvas.toDataURL();      
                    var imgHTML = "<img src='" + dataURL + "'" + " alt ='apps for Office image' img/>";

                    Office.context.document.setSelectedDataAsync(imgHTML, { coercionType: "html" },
                    function (asyncResult) {
                        var error = asyncResult.error;
                        if (asyncResult.status === "failed"){
                            write(error.name + ": " + error.message);
                        }
                    });

                }

     if I set  var dataURL = "http://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-53-99-metablogapi/2541.image_5F00_09118EB3.png";

    then the image shows in Word

    Thanks in advance.

    Monday, April 28, 2014 5:52 PM

Answers

  • Hi Kim,

    I reproduced this issue. But I found the URL from canvas is not a real URL. It is like a data encrypt like below:
    data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAABkCAYAAADDhn8LAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAD3SURBVHhe7dMxCoBAEATBPf//ZxUxlI5MDqoYmBf0Omfuwb/Ws/0d7wMfBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAJBIBAEAkEgEAQCQSAQBAIAAAAAAAAAAAAAAAAAAAAAAAAA7GrmAmnlApYZmAK5AAAAAElFTkSuQmCC

    This is not a limitation Of apps for Office but Word application. I suggest you submiting the feedback if you want Word application to support this feature. You can submit the feedback from link below:

    Submit Feedback

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, May 2, 2014 2:47 AM