将文本替换为图片 Google 脚本

Replace text with image Google Script?

本文关键字:Google 脚本 文本替换      更新时间:2023-09-26

我正在尝试使用此API对某些Google文档进行迭代。但是,我对Javascript的经验很少。如何将关键字(例如<"image">)替换为来自 URL 的实际内联图像?子索引是否支持段落中的索引?代码的奖励积分!

如果要

从URL添加实际的内联图像,请尝试以下操作:

var img_name_Url = "URL of the image";
var img_name_Blob = UrlFetchApp.fetch(img_name).getBlob().setName("img_name_Blob");

在文档中,您要在以下位置使用它:

htmlBody : "The content for the inline image <img src='cid:img_name'>",
       inlineImages:
       {
         img: img_name_Blob
       }