How to Add Images from Drive and the web into Google Doc with Apps Script one click UI menu

Adding images from the web and Drive to Google Docs UI menu item to dynamically add images like logos and others. Press the menu button and add an image. Images can be from Google Drive or from the web. Preselected images within your Doc

function onOpen() {

 DocumentApp.getUi().createMenu(‘adder’)

 .addItem(‘Logo’,’addLogo1′)

 .addItem(‘Logo GDrive’,’addLogo2′)

 .addItem(‘Svekis’,’addLogo3′)

 .addToUi();

}

function addLogo3(){

 const cur = DocumentApp.getActiveDocument().getCursor();

 if(cur){

   cur.insertInlineImage(DriveApp.getFileById(’14aV3wxHA–YTFr6zA3R0pz_WYPasE4Bt’).getBlob());

 }

}

function addLogo2(){

 const cur = DocumentApp.getActiveDocument().getCursor();

 if(cur){

   const id = ‘1DEmp6fkvHox2vh1LgquSJylmwhfIMETG’;

   const blob = DriveApp.getFileById(id).getBlob();

   cur.insertInlineImage(blob);

 }

}

function addLogo1(){

 const cur = DocumentApp.getActiveDocument().getCursor();

 if(cur){

   const url = ‘https://www.discoveryvip.com/img/d.png’;

   const blob = UrlFetchApp.fetch(url).getBlob();

   cur.insertInlineImage(blob);

   Logger.log(blob);

 }

}

Leave a Comment