Last active
August 29, 2015 14:21
-
-
Save beckettkev/1ab58e9101072c17ad39 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var img = document.createElement("img"); | |
img.src = "https://mycompany.sharepoint.com/lists/publishingimages/icons/home.png"; | |
var imgWidth = img.width; | |
var imgHeight = img.height; | |
var canvas = document.createElement('canvas'); | |
var ctx = canvas.getContext("2d"); | |
ctx.drawImage(img, 0, 0); | |
//remember if you want to use JPG, include the 'e' (image/jpeg) | |
var base64 = canvas.toDataURL("image/png"); | |
var img_html = "<img src='" + base64 + "' alt='icon image'/>"; | |
Office.context.document.setSelectedDataAsync(img_html, {coercionType: "html"}, function (asyncResult) { | |
if (asyncResult.status == "failed") { | |
write('Error: ' + asyncResult.error.message); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment