Displaying Base64 Images in Word RRS feed

  • Question

  • I am using Office.js to build a Word add-in. There's a web app where users can insert base64 images along with some text to create an article. So this the add-in is used to display the article in Word. I can get to display the text without a problem, however the images are broken. Can't Word display base64 images? If so is there a way to correctly convert the images into a displayable format and insert them back to Word?

    Appreciate any help. Thanks.

    • Edited by Immysl Friday, March 10, 2017 5:26 AM changed display to displaying in the title
    Friday, March 10, 2017 5:25 AM

All replies

  • Hi Immysl,

    you can try to use "insertInlinePictureFromBase64".


    var img = '' //a base64 encoded string
    // Run a batch operation against the Word object model. (context) {
        // Create a proxy object for the document body.
        var body = context.document.body;
        // Queue a command to insert the image.
        body.insertInlinePictureFromBase64(img, 'End');
        // Synchronize the document state by executing the queued commands,
        // and return a promise to indicate task completion.
        return context.sync().then(function () {
            app.showNotification('Image inserted successfully.');
    .catch(function (error) {
        app.showNotification("Error: " + JSON.stringify(error));
        if (error instanceof OfficeExtension.Error) {
            app.showNotification("Debug info: " + JSON.stringify(error.debugInfo));


    Inserting a base64 encoded image into a Word 2016 document

    Other references:

    InlinePicture object (JavaScript API for Word)

    Body object (JavaScript API for Word)



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Monday, March 13, 2017 7:22 AM